05 Nov 2015
Pry is an interactive console, like IRB, which can be used to pause execution and inspect the current scope in your Rails web requests or tests. I’m going to show you how simple it is to drop it into your Rails apps and get better visibility over bugs.
Read more →
28 Oct 2014
Something I commonly want to do is evaluate a bit of code and insert the result into my Vim window. For example, if I want to generate a 40-character UID, I could use ruby’s SecureRandom class:
Read more →
18 Oct 2013
This is the third and final part of a tutorial for creating a cinch IRC bot game. If you haven’t read the first two parts then you can start it here.
Read more →
06 Sep 2013
Update: Brian VanLoo posted a very helpful comment explaining the behaviour I saw. Scroll down to the comments and read it to understand what’s going on here.
Read more →
29 Aug 2013
This is the second part of a tutorial for creating a cinch IRC bot game. If you haven’t read the first part then you can read it here.
Read more →
06 Aug 2013
This is a tutorial for creating a plugin with Cinch, in multiple parts. It will take you through the basics of working with Cinch, creating a plugin and turning it into a gem. Plus, it will give you a highly addictive word game at the end.
Read more →
01 Aug 2013
TL;DR
If you use sferik’s Twitter gem with multiple accounts in a rails app, or a ruby app that uses concurrency in some way, then you need to be using the thread safe configuration.
Read more →
29 Jul 2013
The other day, one of my colleagues said something that grabbed my attention, while working on one of our biggest rails apps.
Read more →
04 Jul 2013
If you’re a ruby developer, plugging a gem into a project is second nature. Most projects now use bundler to manage gem dependencies and versions, as it is so effective at doing so. If you’ve been doing this for long enough, then you will have come across the pessimistic version constraint operator, at least unknowingly.
Read more →
24 Jun 2013
I ran into an issue the other day that was exacerbated by the fact that blog posts on the subject seemed to be out of date. Therefore, this is an attempt to bring a more up-to-date solution.
Read more →
05 Apr 2013
The very first gem I ever created was actually pretty good. Apart from one thing: when you installed it, it didn’t install the dependencies (i.e. the other gems that it depended upon). This might seem like a pretty big oversight, and it was, but there’s a good reason. I actually did specify the dependencies - I just did it in the wrong place.
Read more →
13 Mar 2013
I had a miniature programming challenge earlier today, creating an algorithm to manipulate an array of integers in Ruby. The array can be any length, but it needed to be modified to contain a maximum of, say, 5 elements. So, if the array length is less than 5 just return it, otherwise do something so reduce it to exactly 5 elements. Also, the order had to be maintained (apart from elements that have been removed).
Read more →
03 Jan 2013
I’ve been involved in writing a rake task to migrate an old database schema to a similar but new schema in a Rails project. The new schema was similar enough that we could carry across all the primary keys from the old tables, and it saved a lot of time to re-use them. However, the problem with doing this is that the auto increment sequence does not get updated when you add a value - you have to manually reset it.
Read more →
03 Dec 2012
I’m currently working on a Ruby on Rails project where sub-domains come into play pretty heavily. Each account created on the site has its own sub-domain, which means that there is no pre-set list. I ran into some problems when writing functional tests and integration tests with Capybara, as I had no idea how to set the current domain and assert a change in sub-domain. Fortunately, after struggling through for a couple of hours, I found the solution and I’m putting it here for the benefit of anyone else!
Read more →
08 Nov 2012
I’ve been tearing my hair out for a couple of hours on this, so I thought I’d log the solution for everyone else’s benefit!
Read more →
08 Nov 2012
I’ve set up Nginx with Phusion Passenger to run my Rails apps in a development environment, as opposed to running rails server in a terminal every time. Setting the rails environment variable to “development” means that many code changes can be automatically integrated without a server restart, but every so often a full restart is required.
Read more →
21 Sep 2012
The other day, I was in the position where I had to recompile Vim (and GVim) on Ubuntu. I had installed the version from aptitude, which is perfectly good apart from the fact that it requires and installs the ruby 1.8.7 package. I actually use RVM for my ruby binary management, and I wanted to tell Vim to use the ruby 1.9.3 installed on my system via RVM.
Read more →