My first dashboard widget
Tuesday, May 25th, 2010These days I find myself converting between “coalescence units” (a time unit of 2Ne generations) and “substitution units” (time measured in expected number of substitutions) several times a day. It is not really much of a problem to do, but my brain is simply not wired to do arithmetic in my head, so I usually fire up R or Python for this.
I am learning Objective-C and Cocoa these days, more for fun than anything else, but I figured that I could write a small unit conversion application to get some use out of it. I mentioned this to Kasper, but he suggested that I write a dashboard widget instead.
I have never used Dashcode before, but I fired it up this morning before I headed for the office, to get a feeling for how it works, with the intention of writing a widget during the week. It turns out it is extremely easy to work with, though, and within half an hour I had a complete conversion widget coded up.
The only thing I don’t quite like about it yet is that when I do the conversions it doesn’t present the results in the text field in scientific notation, so I get stuff like 1000000 instead of 1e6 or 0.0001 instead of 1e-4, which makes the conversions somewhat harder to read.
I’m sure there is a way to format the numbers, but my Javascript-fu is not up to it. This widget is the first Javascript I have ever written.