Good example of antiquity of some Core Ruby classes
Sep/090
A common pattern in Ruby is to call .to_s on an object when you want a String, even if the object itself might be a String. So, e.g., if you are getting NoMethodErrors on nils when you need a String, you might call .to_s to convert that nil into a String (”).
Well, you might want to do the same thing to convert Floats to BigDecimals. But guess what? BigDecimal doesn’t include a .to_d method! Oops. The BigDecimal class must be so old that this idiom hadn’t evolved.
Ruby inherited callback runs before subclass is loaded
Sep/090
Harrumph.
I wanted to call a class method on a subclass when the base class’s inherited callback is triggered.
But it doesn’t work, because the subclass isn’t loaded when this callback is triggered.
So the following doesn’t work (’boo’ prints instead of ‘foo’):
class Base
def self.permalink
'boo'
end
def self.inherited(c)
puts "permalink: #{c.permalink}"
end
end
class C < Base
def self.permalink
'foo'
end
end
You may be able to get what you want by forcing the class to load with Class.new:
class Base
def self.permalink
'boo'
end
def self.inherited(c)
puts "permalink: #{c.permalink}"
end
end
C = Class.new(Base) do
def self.permalink
'foo'
end
end
Nice post at Geezeo regarding BeatThat!
Mar/090
Geezeo — the community-driven personal finance site — did a nice blog post on our product BeatThat!
About the Kindle
Mar/090
So I bought the Kindle. My motivation was to stop buying books; I’m sick of accumulating the mass and killing the trees. It’s both less and more than I thought it would be.
On the “less” side, it is amazing what it can’t do. It can’t flip rapidly between pages. It isn’t super-easy to make notes or search (though you can do all of these things). . . . It is optimized for reading, that is, reading paragraphs of prose text, moving from page to page. Because of the small size of the screen, it wouldn’t be very good for reading computer manuals which frequently have important images or bits of code that shouldn’t wrap to the display. The fact that it is optimized for this particular kind of reading also means that it is really not a general tool for, say, students who want to conduct research. Apparently Amazon designed to do this one thing very very well (read prose, page by page); if you’re a student, you probably want your whole computer anyway, as you might have a PDF open in one window, a caculator or Excel or MATLAB open in another.
On the “more” side, the free network connectivity is going to be interesting. I’ll be taking a coast-to-coast train trip this summer, and I was wondering what I would do to rent an AirCard for the 10 days we’ll be traveling. Well, you can read your GMail just fine on the Kindle. And there are no charges for this connectivity — it’s included in the purchase price.
Another surprise is that there are quite a few Kindle books (4,000+) from Amazon that are free; most in the public domain. So I downloaded the Bible, Pope’s “Rape of the Lock,” and a few other goodies. Unfortunately, not all of these free editions have tables of contents, so my download of Fitzgerald’s Tales of the Jazz Age isn’t so useful if you want to jump right to “A Diamond as Big as the Ritz.” Still, that’s pretty neat.
DNS failover: Short TTL vs Multiple A Records?
Dec/080
Note to self:
Apparently the reason people do round-robin DNS with multiple A records is because Internet Explorer retires a bad IP better when the A Record disappears vs. the TTL expiring (worse case for the latter: 28 minutes!).
http://www.netwidget.net/books/apress/dns/info/failover.html
Know your compact fluorescent bulbs
Sep/081
Here’s a great post by my colleague Tom that explains which compact fluorescent bulbs are good:

Managing Two Network Providers: Using a PePlink Balance 30
Aug/081
At work we’ve been a Verizon customer for phone and network. We use a Cisco 800 Series router which gives us wireless and VPN. It has a horrible Java applet interface which is so bad I can’t recommend that router. In any case, we were saturating our bandwidth through this router, and everyone was being driven crazy by the effect on our network when someone would hog up the traffic when deploying software (mostly big transfers from Subversion using ssh — our Subversion server is on this office LAN managed by the Cisco router).
Now we’re all software developers. We’re a tiny company and don’t have anyone to manage our IT; we do it ourselves, and we have rather a lot of equipment and a simple but non-trivial network. Through the goodwill of friends and former colleagues we’ve gotten some advice, but, really, it’s not what we’re good at.
Recently we decided we wanted to augment our Verizon drop with a 2nd drop from Comcast. Comcast has some good deals providing a decent amount of bandwidth. So we bought the drop.
Now how to integrate this into our existing network? With the minimum amount of screwing around? Basically we wanted to leave the Cisco and its VPN alone. We also wanted the office traffic to go via the Comcast drop whenever possible.
This sounds easy, but it’s not. There are a lot of expensive devices that can help you manage “quality of service,” but, really, we wanted something cheap and easy.
After rather a lot of research we settled on the PePlink Balance 30. [Buy from Amazon]

It’s about the size of a conventional home router. It provides for 3 WAN links. So, typically, you would plug Verizon into one WAN port, Comcast into the second, and perhaps — if you have access to it — some free wireless network into the third. In other words, you want to provide to your office multiple ways to get to the outside world in case something goes down.
In our cast, we plugged the Cisco router into one WAN port, the cable from the Comcast modem into the other.
The next step was some custom routing rules. Basically we said that all traffic for the network and VPN managed by the Cisco should go there; and everything else to Comcast.
So far it seems to work great.
The device provides good stats showing WAN utilization, and we’re getting what we want. Some traceroutes look funny (like they’re going via the VPN), but I hope to have that fixed up pretty soon now.
There’s a review out there from SmallNetBuilder.
Reviews of BeatThat.com
Aug/080
A couple of fresh reviews of DigitalAdvisor’s new product BeatThat.com:
Teaching Ruby and Ruby on Rails again at Harvard
Aug/080
Once again, I’m pleased to be offering a course on Ruby and Ruby on Rails at Harvard: course; course site.
We’ll try to avoid this anti-pattern:
Indispensible Mac App: iCDc
May/080
You enter a CD into iTunes, and it goes off to the Gracenote CDDB to determine the album and song names. But wait, you have to pick from a list of choices! Hope you pick the right one . . . Recently I picked the wrong match. I think I got the English version of the album instead of the American, and the song titles weren’t right. So what to do?
The matches are stored in /Users/jgn/Library/Preferences/CD Info.cidb, but I couldn’t figure out an easy way to edit it. Fortunately, there is a program that lets you edit your CDDB data: iCDc, available here. Whew!
Doubtless there is something you can press when inserting the CD into iTunes that will force a new choice from Gracenote — or perhaps you can do it through “Get Info.” But as usually the documentation is minimalist, and it’s nice to have an editor anyway.

