Monday, August 13, 2007

In the name of homeland security?

My new DSL modem is being held hostage by the government. Or...something.
Update: apparently this just means the UPS driver couldn't deliver the package because of a locked gate. Odd.

Thursday, August 2, 2007

/* People celebrate: "We love our President!" */

I've noticed that often when I am tempted to make witty comments (== lame puns) in code it means that there's a better way of doing it. For example, today I wrote this:
parser = OptionParser(usage=usage)
parser.add_option('-d', '--delay', action='append', dest='delay',
help='Delay, in milliseconds, to configure link')
parser.add_option('-b', '--buffer', action='append', dest='buf',
help='Size of traffic-shaping buffer for link, -1 to leave unset')
parser.add_option('-s', '--speed', action='append', dest='speed',
help='Speed of link, -1 to leave unset')

...snip...

(options, args) = parser.parse_args(sys.argv)

...snip...

# we want empty lists, not Nones. The Nones, of course, being either the
# fifth or the seventh of the month in the Roman calendar.

if not options.delay:
options.delay = []
if not options.buf:
options.buf = []
if not options.speed:
options.speed = []

I had forgotten that the OptionParser lets you specify a default value for the options.

I don't know what you can infer from this. But it's interesting.

The title is the comment that precedes the function tcp_try_undo_recovery in net/ipv4/tcp_input.c in the linux kernel. It's actually more documentation than most of the functions in the linux TCP stack have. I never thought I'd actually want to see a Glen-style header again...