I wrote a small Rails app, which sends emails on a particular schedule. For example to send an email every week on monday and thursday at 7:00am Melbourne time.
However Heroku doesn’t have cron or good free alternative. I wrote a cron replacement in 5 minutes. This post shows how I did it. There are three parts:
The story starts with the RubyWeekly newsletter. Once signed up, every week you’ll receive a collection of curated links. It’s a great resource to learn Ruby. It could take a few hours to read through the interesting articles.
I found it hard to set aside 2-4 hours every week to read them in one go. So I wrote a script parses each week’s issue into an RSS feed. The feed had one item per link, which gave more granular control.
This book is very hyped this year. To summarise it's a detailed refactoring tutorial. It could also be called "Refactoring 1-on-1 for dummies".
I like that it goes through long and tedious process of proper TDD. I don't like for the exactly same reason and had to skim through it. People who are not familiar with TDD should find it very useful.
The book was a good detailed reminder of the refactoring process for me. However I wouldn't recommend it to myself.
Update 1: The article was translated to Japanese
Update 2: This post is featured in RubyWeekly #374
&. operator, added to Ruby 2.3, is handy and I’ve cleaned a lot of code with it. You can use it in conjunction with default operators as described in Ruby's New &.!= Operator.
Recently I introduced a bug when using
&.. First we had:
if start_date && start_date < start_of_month && end_date.nil? # … end
Unfortunately this presentation had a lot of transition and my recording failed, so please have a look at the transitions in video slides below.
A quick read which I would recommend to every mid rails developer and higher. It's common for developers to outgrow their tools. Rather than learn new skills, people start to blame the tools. Your heard those people: "Rails does not scale", "ActiveRecord is antipattern" etc. The books show few patterns which allow to build big Rails application with only small changes to standard 'Rails way'.
The book recommends active_type gem. I would recommend other gem active_interaction instead. active_interaction gem is more superior in my opinion and I've successfully used it in multiple projects over the last 2 years.
As for the CSS structuring, BEM is definitely a good choice to get control over your styles. Only issue with it, if not enforced it loosed its value, so every developer should be very diciplined to follow BEM.
There is only 1 option which is better than BEM, it's css modules. I only used it with ember.js, not Rails though. It automates steps that you have to do with BEM. However css modules require deep integration into the tools you use, which makes it harder to bring into the project.
This quick and easy to read book I would recommend to every developer. It talks about all the little things which are often neglected and what developers deal with every day. Naming methods and variables, extracting business logic, code comments, aesthetics and code readability.
This knowledge is language agnostic and the best mastered over reading lots of code, or reading this book :)
I will continue to expand the features in the pagelet_rails gem. Since it offers a new way of composition in Rails I've found that there are so many new things we can do. In this post, I will focus on the parallel rendering. Yes, that's right, parallel rendering in Rails. Although, it may sound advanced the concepts behind it are extremely simple. This post however is only relevant to web page rendering.
Update 2: This post was featured in RubyWeekly #318
Download Slides PDF or read more
I've been asking people for the gems they would recommend to others at Rails Camp 19. This is a compiled list of answers.
Last friday one of my friend gave me a math challenge. You've given four numbers 6, 6, 5 and 2, you need to find 3 math operations to get 17 as a result. You have to use all four numbers and only once each. Order of numbers can be any.
I couldn't figure it out in my head so have to write a ruby script to iterate over all combinations, which turned out as a great coding exercise.
The bystander effect, or bystander apathy, is a social psychological phenomenon that refers to cases in which individuals do not offer any means of help to a victim when other people are present. The probability of help is inversely related to the number of bystanders. In other words, the greater the number of bystanders, the less likely it is that any one of them will help.
After reading the title Embedding a Test Suite in a Single-file Ruby App (Part 1) I thought: aha! finally somebody has done it and used ruby data block to store tests. However I was disappointed as there was another approach, which I think is less elegant.
Below I show you a proof of concept of embedding tests in ruby code.
Looking for static site generator? Look no more, use Rails!
Recently at Opensight we had weird issue with our integration tests. When we run single test it succeeds, but when whole suit it fails.
It was failing on the same "terms and conditions" page where we expect 'Accept' button:
could not find element Accept
This is an interesing bug I've encountered this week. While our Rails application was working in development it was completely broken in UAT environment (which is 99% production like)
We were getting
Circular dependency detected while autoloading constant error on all of our reports.
Then you should know what browser profiles are.
Are you tired of seeing yet another project on github while there are ten others which do exactly the same thing? In this post I suggest we start to diffirentiate our projects.
I'm using POW as a proxy to my local dev server in development. That gives me nice local *.dev domain names. However I've noticed that it takes 10 seconds to load a singe page in Chrome. Of course, I thought, It does like 80 requests as each asset is served as a separate file in development. But after investigating it a bit more DNS lookup for each request was 3 seconds and for some reasons it was like that for every single http request.
NewRelic service is great for application monitoring and errors tracking. However it doesn't track rake exceptions by default. You can use AirBrake gem and service, but sometimes it's too much for you. Fortunately with a bit of ruby it's easy to do it yourself.
The first version of RubyMine with Zeus support was released last week. This is a small tip how to get it working.
Today was trying to figure out why my query was running very and very slow.
If you installed the latest mysql with homebrew, my version of mysql was 5.6.12. I couldn't install mysql2 gem
gem install mysql2
You can use RubyMine for editing but still run tests in terminal. With this tip you can click path in terminal and open that file in RubyMine.