My New Yorker subscription . . . and the paper it’s printed on

November 25, 2009

I own a Kindle. After I bought it, I vowed to buy books only on Kindle; and then when not available on the Kindle, buy sparingly in print, or go to the library. The idea is to reduce the amount of waste and clutter I generate. I’ve been very successful. So far.
But now I have [...]

Read the full article →

Michelle Wildgen, But Not For Long (Book Review)

November 17, 2009

Michelle Wildgen, But Not For Long (2009). $24.99. [Amazon]
I’m a sucker for a good “end times” novel (see my review of World Made by Hand). This book is about three housemates in a funky Madison, Wisconsin co-op dedicated to localism (as in local foods). 30-something Hal leads the house, with the help of 20-something Karen. [...]

Read the full article →

If you must rescue Exception . . .

October 29, 2009

Sometimes you see Ruby code that rescue an exception at the top of the hierarchy:

rescue Exception => e

If you must do that, how about providing a means to control-C, by putting this in the method with the rescue:

trap("INT") do
puts "Terminating . . . "
return # or maybe exit
end

Read the full article →

Good example of antiquity of some Core Ruby classes

September 22, 2009

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 [...]

Read the full article →

Ruby inherited callback runs before subclass is loaded

September 22, 2009

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)
[...]

Read the full article →

How to embed JRuby 1.9 into a Java class

August 20, 2009

It took awhile longer to figure this out than I would have liked, due to no on-line JavaDocs for JRuby (what’s up with that!?).
But here’s how to embed JRuby 1.9 into a Java class:

import org.jruby.Ruby;
import org.jruby.RubyRuntimeAdapter;
import org.jruby.javasupport.JavaEmbedUtils;
import org.jruby.RubyInstanceConfig;
import org.jruby.CompatVersion;

import java.util.ArrayList;

public class JRubyEmbedded {
public static void main(String[] args) {
RubyInstanceConfig ric [...]

Read the full article →

Evening of Day 4: St. Mary Lodge and Resort, St. Mary, Montana (near Glacier National Park)

July 11, 2009

After our tour of the Going-to-the-Sun Road on June 30, 2009, we went to the St. Mary Lodge and Resort in St. Mary, Montana. Calling this place a “Lodge and Resort” is a misnomer. It’s really just a multi-room hotel with some cabins, a store, a gas station, a decent restaurant, a gift shop, all [...]

Read the full article →

Day 4 (Tues., 30-June-2009): Going-to-the-Sun Road

July 8, 2009

It sure was nice to sleep in a stationary bed! We got up and went down to the restaurant in the Glacier Lodge, and had a buffet-style meal. We ate a lot because we thought we might skip lunch. The breakfast at Glacier Lodge wasn’t very special, but it was filling, and they had cereal [...]

Read the full article →

Day 3 (Mon., 29-June-2009): North Dakota; Montana; Glacier N.P.

July 7, 2009

Monday the 29th (Day 3) was all about finding things to do as we cruised through Western North Dakota and Eastern Montana. We woke up with the sunrise:

Caroline, the 6-yr. old, and John, the 40+ yr. old, were fighting it out for who could be more bored. Train travel with a soon-to-be-first-grader is tough. But [...]

Read the full article →

Day 2 (Sun., 28-June-2009): Chicago to the Dakotas on the Empire Builder

July 2, 2009

In our last installment, recall that we went to bed on board the Lake Shore Limited expecting to arrive in Chicago at around 9:45 AM. And we did.
As sleeping car ticket holders for the Empire Builder, we were allowed to use the Metropolitan Lounge at the Chicago Amtrak Station. This is no big honor, because [...]

Read the full article →