The Winding Road of Procrastination

I sat down tonight to do some more learning about Ruby. I thought that I'd spend an hour or so and build something trivial, but useful. Well 90 minutes later and I have had an enjoyable evening, but I have yet to write a single line of Ruby code.

It started out with a Ruby tutorial which had a header on the first line with the standard directive pointing to the executable for the Ruby interpreter. That led me to realize I wasn't 100% sure where that executable was on a Mac. I remembered that there was some kind of command to find these exectuables so off I went to Google. My search results led mt to a Perl primer describing the use of the which command.

Having used the which command on my Mac and finding that it gave me exactly what I was looking for, the next logical step would be to continue with the tutorial. Unfortunately, that's not how my brain works. The next logical step for me was to put together a short blog post on the which command so that I would have a reference for myself at some future date.

Writing the blog post sent me to my terminal to test out the which command on my Ubuntu and CentOS machines to make sure it was a cross-platform as I thought. Research for the blog post also sent me to some documentation for which that I wanted to link in my article.

After posting the article I realized that the Markdown-to-HTML engine on my blog had converted the #!/usr/bin/ruby line in my blog post to a header because of the hash mark. This sent me in search of Markdown documentation which I found on the Markdown syntax page on Daring Fireball. I of course had to take a moment and peruse the DF site while I was there and found a reference to a recent episode of his podcast The Talk Show being sponsored by The Magazine.

Remembering that I had just subscribed to The Magazine earlier in the evening I picked up my iPhone to peruse the article titles and found that one was an update about The Magazine itself. Reading through that short update from Marco and that he had received tons of submissions for new article pitches reminded me that I had an article of my own to pitch. I fired up my email client and sent the pitch email off.

Remembering that I hadn't yet fixed my typo I jumped back to my blog to correct the error. Glancing at my browser sidebar I looked at all the open tabs, then up at the clock and realized it had been over an hour since I had intended to write some Ruby code. Thinking back over the activities of the past hour I realized that an article about procrastination might have made an even better pitch. So I wrote this up and am going to send that in right now.

Ubuntu School – which: Finding Ruby

I've been getting my feet wet with Ruby the past couple of days and decided to post this as much for my own recollection as anything else. When you're creating a .rb script file the first line (as with nearly all *nix script files) contains a reference to the executable which should be used to execute the script.




But what if you don't know precisely where that file lives? The which command will find it for you. Which is a command which provides you the fully qualified path to shell commands, and this includes script hosts like ruby.

callisto:~ kdmurray$ which ruby /usr/bin/ruby

This also works for Perl, Python and any number of other executables. Ever wonder where the pwd command lives? or nano? or which itself? Go explore! This command works on most *nix operating systems including most Linux OSes and Mac OS X.