Archive for January, 2009

Weekend Project(s): Cardboard Cat Chaise / Greasemonkey Unit Conversion Script

Saturday, January 3rd, 2009

Every once in a while I like doing some DIY stuff just for the fun of it — I suppose it’s my deeply buried need to create something that is physical and not source code, for a change. Some time ago, I came across building instructions for a cardboard cat chaise, and I thought it might be fun to make. Besides, I had no doubts my cats would like it, as they’ve always demonstrated an evident fetish for cardboard boxes.

So, the day came yesterday — I got a big cardboard box, prepared the tools, arranged a workspace on the floor, and began reading the instructions. To my disappointment, all the dimensions in the text turned out to have been given in inches, which seemed perverted for a normal, healthy, metric-oriented person that I am.

Of course, it wouldn’t be a big deal if I just took a calculator, did a few multiplications, and got the respective values in centimetres. Or I could use the mighty unit conversion capabilities of Google search. But then I thought to myself — hey, isn’t this the 21st century, Web 2.0, and stuff? I shouldn’t be forced to do such a tedious task of entering numbers and doing the calculations, this bloody machine/Web/whatever should do it for me. With this in mind, I turned to Userscripts.org to see if there was a Greasemonkey script that could parse those awful inches and convert them to lovely centimetres right there on the webpage. But, bummer — it seemed there was no such script.

This is where my need to create something physical had to retreat for a while, as the more powerful need to immediately transform the idea for a conversion script into an implementation was taking over. I quickly coded a basic script that converted inches, feet, yards, and miles into centimetres, metres, and kilometres, and displayed the result in a tooltip when the mouse cursor was placed over the value in question, like this:

US to Metric

To make the script a bit more useful, I also added conversion rules for units of mass (ounces and pounds to grams and kilograms) and temperature (Fahrenheit degrees to Celsius). If you want to give it a try, you can grab it from Userscripts.org.

And the chaise? It turned out quite well, and the cats started using it instantly. Here’s one satisfied customer:

Happy cat on a chaise

If you compare my result with the original one from the article, you’ll notice I went with a more primitive IKEA-ish design, but my cats are just simple unpretencious DSHs and they don’t like fancy furniture.