When i was first learning Ruby i, like most people, picked up two books. The first was the wonderful pickaxe book; the second, the no-less-wonderful Poignant Guide to Ruby by everyone’s favorite mad scientist – Why the lucky stiff.
When virtually flipping through why’s lovely creation one of the things that caught my eye was a a statement early on in which he simply asked us readers to “read the following aloud to yourself” and followed it with a small block of ruby code:
5.times { print "Odelay!" } |
I, being in the comfort of my own home late at night, obeyed and read “five times print odelay!”. I chuckled and moved on. But he persisted asking that i then read another block of code:
exit unless "restaurant".include? "aura" |
And once more i obeyed chuckling even more at the concept of a restaurant aura. I’ve often used this as one of the reasons why i love Ruby. When written right it just sort of makes sense. You can read it and understand it more-often-than-not. It’s not the insane business speak like COBOL or the drawn-out run-on sentences of Java, but just simple little statements that do their best to not confuse the reader.

Why is all this interesting? Well i was wandering about the bundles menu in TextMate today and stumbled across the ability to Speak Selection. I hastily highlighted a line of the Javascript library i was working on and hit Speak Selection. What i got was something between a three-year-old telling you about their day and a speech synthesizer being circuit bent. I copied in Why’s first example and did the same and was rewarded with “five dot times print Odelay!”. Not exactly how i had read it but still mostly understandable.
So this begs the question: could ’speakability’ be a viable way to determine if code is understandable? If you can actually read your code aloud – and have it explain in more-or-less english what it is attempting to do – it would seem that there is a much greater chance that the next person to look at your code will be able to interpret it as well.

iTunes 8 has a new feature i’d been wanting for a while – grid view. Giving you the ability to view your music in a simple grid, much like iPhoto, grouped by album, artist, or genre. Normally you’ll see album artwork in this view; switching to genre view, however, shows some campy artwork for certain popular genres (pop, rock, hip-hop, etc) but is missing artwork for more specific / niche genres. A post on the iLounge forum details how to create custom genre artwork but it’s a little more verbose than need be and geared at the Windows audience. So here’s the briefer version for OS X.
- Close iTunes if it is running.
- Open your Applications folder (⌘⇧A).
- Control- / Right- Click on the iTunes icon.
- Select “Show Package Contents” – this will open a new Finder window.
- Open the “Contents” directory. Here you will find JPG images that begin with “genre-”, these are the files iTunes uses for its genre artwork. Those ending in ‘M’ are for movies.
- Copy one of these files to your Desktop by dragging it and holding Option (⌥).
- Edit this file to your liking and rename it to the genre of your choice, for example “genre-metal.jpg” for metal.
- Move it back into the Contents folder.
- Now open “genres.plist” in your favourite text editor (TextEdit will work).
- Copy one of the
<dict> entries and paste it into the list (making sure to do this between other entries, that is after a closing tag: </dict>).
<dict>
<key>matchString</key><string>rock</string>
<key>resourceFile</key><string>genre-rock.jpg</string>
</dict> |
- Now edit the entry you just pasted to match the genre you are replacing. The
matchString (in this case “rock”) becomes the word or phrase you want itunes to search for1 and the resourceFile (in this case “genre-rock.jpg”) becomes the name of the image you just copied into the Contents directory.
- Save the file and launch iTunes. You should see your new genre art in the grid view now.
1: The matchString appears to match around special characters. For instance the entry for R&B is “r b” but still matches the string “R&B” in iTunes. Also note that this string does not need to be a perfect match. A matchString of “metal” would also match the string “Epic Metal” or “Power Metal”.
Filed under things i’m not sure how i lived without, the Copy as RTF bundle for TextMate is absolutely amazing. Between work and our local ruby brigade (757.rb) i’m always copying little snippets of code into Keynote or emails, or something, now i get to keep my syntax highlighting instead of formatting by hand (ick!) or pasting screenshots of code (also ick!). Yeah, it’s kind of old news but still figured i’d throw it out there since it deserves some recognition. Thanks Dr. Nic!