Tuesday, July 3, 2012

Notification from long-running tasks

Yesterday I thought of a technique which has become a real time-saver for me. (I'm sure I'm not the first person to think of this; I remember reading something similar in Time Management for System Administrators.)

You can get notification from any long-running task on the command line like this:

do_my_task && make_a_sound

For example, using Rake on a Mac:

rake db:reseed && say 'done'

Now I can kick of the database to be rebuilt and move to another window, knowing that I'll get audible notification when that task is complete.

Monday, June 18, 2012


I like to imagine that somewhere in Silicon Valley, there is a sandwich shop which caters to nerds. They send out special deals via RSS feed. Naturally, they call this the PubsubHubbub Sub Club.

Based on the special they're running, they keep extra ingredients handy to satisfy demand. Each morning, they must fill the PubsubHubbub Sub Club Grub Tub.

At the end of the day, they clean it out and wash it thoroughly. They do this, of course, using the PubsubHubbub Sub Club Grub Tub Scrub Nub.

Thursday, May 24, 2012

Programming music: Afriki Djigui Theatri

I've been meaning to write a post about music I like to listen to while programming. My main criteria is that it doesn't have words I can understand, because that triggers the language part of my brain, which makes it impossible for me to decide what to call my variable.

A full post will have to wait, but the moment, I'm really enjoying a radio station full of African music. I found it in iTunes: Radio -> International/World > Afriki Djigui Theatri. They also have a website: http://www.djigui.org/

It's beautiful, most of it has a nice beat, and I can't understand a word.

Sunday, April 29, 2012

New gem: Authority

I recently released a new Ruby gem for authorization in Rails apps. It's called Authority.

You can find the code and extensive documentation on Github; the gem is hosted on RubyGems.

I also wrote a blog post on RubySource explaining the ideas behind the gem.

Check it out!

Wednesday, February 1, 2012

The beauty of xargs

Every time we deploy our Rails application, our deployment tool creates a new folder based on the date and time, puts the right files in it, and when everything is ready to go, updates a symlink to point to the newest release.

Yesterday I found that I couldn't deploy because we were out of disk space. I needed to delete some of the old release folders.

When I sshed into the server and looked in the releases folder, it had a ton of folders named like this:
Here you see some from 2012, but they went back all the way to 2010. I wanted to delete everything older than 2012.

Enter the magic of xargs. It lets you take the output of one command and input each line of it as an argument to another command.

Here's what I did:
ls # shows me all the folders
ls | grep ^201[01] # shows only the ones starting with 2010 or 2011
ls | grep ^201[01] | xargs rm -rf # delete all those
Building up the command bit-by-bit lets me verify that I'm going to delete the right things. And xargs knocks it out.

Here's another useful example. Vim creates a temporary .swp files that sometimes don't get cleaned up. To find and delete them all out of a folder:
find . -name '*.swp' | xargs rm