Wednesday, August 29, 2007

Shed a Tear for Edward Lear

Edward Lear was a British Author and Poet I have recently re-discovered (You might know the poem "The Owl and the Pussycat"). I love his books of nonsense. They are wonderfully illustrated and are full of limericks, A form of poetry I am particularly fond of. In fact the limericks in Lear's nonsense books are given credit for popularizing the form. Lear was also an accomplished illustrator who's work was compared favorably with Audubon.

Here are some of his limericks and accompanying illustrations:


There was an Old Man of Coblenz,
The length of whose legs was immense;
He went with one prance from Turkey to France,
That surprising Old Man of Coblenz.





There was an Old Man on whose nose
Most birds of the air could repose;
But they all flew away at the closing of day,
Which relieved that Old Man and his nose.



There was an Old Person of Dutton,
Whose head was as small as a button;
So to make it look big he purchased a wig,
And rapidly rushed about Dutton.




All of the above examples are from project Gutenberg's collection of Lear's works. Here is a link to the book containing all the above limericks and illustrations.


I have written a quick limerick to commemorate this zany, zany giant of a limericker. Ahem.

Edward Lear was a man with a craze.
He would write only lim'ricks for days.
Then he'd drink himself silly
In a suit that was frilly.
And stumble back home in a haze.

Saturday, August 25, 2007

Using Regexp in Mocha Expectations

A while back I was writing some tests for a rake file. The task I was testing was just a bunch of file manipulation and one of my tests looked something like this:




Dir.glob('weblogic/adomain/*') do |file|
next unless test(?d, file)
FileUtils.expects(:cp_r).with(file,'new_server/weblogic/adomain')
end

To be honest I didn't want to be setting expectations in a loop. A regex would handle this much better, right? Turns out you can pass a block to the with clause that has a regex in it. That would look something like this:

FileUtils.expects(:cp_r).with() { |value| /new_server\/weblogic\/adomain/ === value}


That isn't too bad, but I think this is nicer:

FileUtils.expects(:cp_r).with(/new_server\/weblogic\/adomain/)

Unfortunately Mocha, the mocking framework I am using here doesn't let you. Sooo, I submitted a patch. I'm really hoping this makes it in as I think it is a handy thing. As a side note, it turns out there was already a similar patch against Mocha for this submitted by Wolfgang Schnerring. It had been ignored for about 7 months! I incorporated the best of both into one. Let's hope this one gets looked at sooner.

Wednesday, August 22, 2007

Home Sweet /Home


Have you ever re-installed your OS? Often that means setting up preferences again for all your applications, getting that look and feel back that you like, copying a bunch of files around. It is annoying and can take days! With Linux you don't ever have to deal with this if you know a simple trick. This probably doesn't come as a surprise to many Linux users, but it might to the newbies. The trick is to put your /home directory in a separate partition or even on a separate disk. I haven't had to setup any of my preferences for any of my applications in years, even across multiple Linux Distributions.

Here is an example of how awesome that is. Earlier this week I had a hard disk fail and it took my OS with it. Fortunately, I had my /home directory on a separate hard disk. I reinstalled my OS on an empty partition on the disk and pointed /home at my old /home partition and I was back up and running as if nothing had happened in half an hour. All my old preferences and files were there. My desktop was just as messy as it ever was! Home sweet home.

I'm not going to get into the details of how to partition a disk, but a hint is to go to the "manual partitioning" step on installation. I usually have 3 partitions: /,/home and a swap partition. Ping me if you need more info than that.

Tuesday, August 14, 2007

A Diagram is worth 1000 words.

My presentation at OSCON forced me to learn how to create diagrams. Now that I have a couple under my belt I find myself just doodling diagrams in my spare time. Here is one that incorporates an attempt at calligraphy, a cartoon, and a diagram.

Thursday, August 2, 2007

Unofficial Ubuntu


If you use Ubuntu you should definately have this link in your bookmarks: http://ubuntuguide.org/wiki/Ubuntu:Feisty This is a guide to making your OS do what you want it to do. I routinely copy and paste the commands from this page into my console when I am setting up a fresh Ubuntu machine. The biggest trick of all is just getting the proper set of apt repositories Once you have that being able to watch movies in your browser, getting the flash plugin, and other stuff becomes as simple as apt-get install package-name. Check it out!

OSCON Retrospective

Update 11/14/2008. Andy just sent me a link to this summary of our talk. Not too negative. Cool! It has been a week since Andy and I gave our presentation at OSCON so I thought it high time I got around to thinking about how things went. Happily the "Pimp My Build" presentation went very well. From the get go there were plenty of audience questions, and people with good experiences to share. The audience was mostly long time CruiseControl users and a handful of newbies. With that in mind we glossed over our introductory material and focused on some of the more advanced material. One area of interest was staged builds. There are several reasons why you might need a staged build, the most common being a functional test suite that takes a long time to run. In that case you have a quick build or set of smoke tests to give you early feedback, followed by a second stage that runs the full battery of tests. There was lots of discussion in this section and I hope that means people were getting some new ideas The other hot topic was visualization and sharing metrics with the team through cruise. Unfortunately we didn't have good demonstrations prepared for this so it was mostly just us describing the concept, but it seemed to give some people ideas.

This brings up some of the things we could have done better. We prepared for an audience that included more newbies, but they didn't show up. Had we known, we could have spent more time preparing content on things like metrics and visualization. Also there was my cc.rb sms notifier plugin debacle. I wrote a plugin for cc.rb that sends build status changes out to your phone via sms, however the sms were taking several hours to reach people. It was kind of embarrassing that my live demo (which was supposed to send messages to several audience members) didn't work. Although it was kind of funny to think that several hours after the presentation people were getting build status notifications.

Overall it was a great experience and it gave me a real appreciation for the amazing keynotes I watched on Friday morning. Jimmy Wales of Wikipedia fame gave an interesting talk on WikiaSearch which is supposed to be an open source Google killer. Another talk by James Larsson called Pimp My Garbage (I ripped off the name first, I swear!) was amazing. Here is a video that unfortunately doesn't show the videos James used to illustrate his hacks, so it is missing the best part: where you get to see him shooting at an old plotter with a BB gun, a steady hand game with 75,000 volts, and a hacked version of pong called "Leather Fetish Pong" that uses kinky women's boots as controllers.

Aside: Of the two conferences I have attended this year I really appreciated OSCON's breadth over the focus of RailsConf.

Annoying Weirdness in Mailcap File


Ever since i upgraded to Ubuntu 7.04 I have been unable to successfully run all the unit tests for our project. One particular test kept failing in a part of the system that handles email. Here was the stack trace I kept seeing.

java.lang.NullPointerException
[junit] at java.lang.String.concat(Ljava.lang.String;)Ljava.lang.String;(Unknown Source)
[junit] at com.sun.activation.registries.MailcapFile.parseLine(MailcapFile.java:234)
[junit] at com.sun.activation.registries.MailcapFile.parse(MailcapFile.java:198)
[junit] at com.sun.activation.registries.MailcapFile.createMailcapHash(MailcapFile.java:158)
[junit] at com.sun.activation.registries.MailcapFile.(MailcapFile.java:47)
[junit] at javax.activation.MailcapCommandMap.loadFile(MailcapCommandMap.java:171)
[junit] at javax.activation.MailcapCommandMap.(MailcapCommandMap.java:125)
[junit] at javax.activation.CommandMap.getDefaultCommandMap(CommandMap.java:54)
[junit] at javax.activation.DataHandler.initDefaultCommandMap(DataHandler.java:149)
[junit] at javax.activation.DataHandler.getDataContentHandler(DataHandler.java:615)
[junit] at javax.activation.DataHandler.getContent(DataHandler.java:540)
[junit] at javax.mail.internet.MimeMessage.getContent(MimeMessage.java:1068)


I figured out that there is a file called .mailcap in my home directory. In my case, for whatever reason, the first line of the file had some junk in it. There was a -e there. By deleting that line of the .mailcap the test passes. Totally lame. I don't know if this is an Ubuntu thing or PEBKAC, but at least it is easy to fix (if you know what is wrong).