A Game Against the PC at Home

Not so very bad until move 18, when I had a sudden attack of craziness. Sacrifices have their place, but not without some support!

Another week another chess game

Here's a game I played last week. I didn't play as badly as I thought, though I did make a couple of spectacular blunders. Analysis shows my opponent also made mistakes and the game could have gone the other way with just a little better play on my part.

Experiment: Chess Game

An experiment: here's a game I played (and lost) back in July. Presented courtesy of pgn4web.

Why Software Engineering is Hard

Many software engineering problems live in a space of solutions that twists and turns like a blanket hastily thrown onto the floor. [...] If the problem is complex enough (and software design and software process decisions can be very complex indeed), there is no best way to find this best solution.

From Making Software edited by Andy Oram and Greg Wilson. (Emphasis is mine.)

Make Your Own Passport Photos

Just a quick link to an article I wrote on how to make your own passport photos using a digital camera, the Gimp and some elbow grease.

Some Editor Tricks

Here's the scenario (fictional, but not too far removed from real life): I want to munge some data I have into code. Let's say I have this in my editor:

The Comedy of Errors
Much Ado About Nothing
Twelfth Night

and the result I want is this:

THE_COMEDY_OF_ERRORS = "The Comedy of Errors"
MUCH_ADO_ABOUT_NOTHING = "Much Ado About Nothing"
TWELFTH_NIGHT = "Twelfth Night"

My editor of choice is vim and I like to run in a Unix (these days that usually means Linux) environment. Given those tools, here's one way to do it.

In command mode, I type 3yy (yank three lines), move the cursor to the line where I want to put them and hit p (for put).

The Comedy of Errors
Much Ado About Nothing
Twelfth Night

The Comedy of Errors
Much Ado About Nothing
Twelfth Night

I use the bang command to pipe the first three lines through sed 's/ /_/g'. (To pipe three lines through a shell command, type 3!! in command mode, then type the command at the colon prompt at the bottom of the screen.) This sed command replaces all spaces with underscores, leaving:


The Comedy of Errors
Much Ado About Nothing
Twelfth Night

I pipe the first three lines through perl -pe 's/\w+/uc($&)/e'. This forces all letters to uppercase, leaving:


The Comedy of Errors
Much Ado About Nothing
Twelfth Night

I pipe the last three lines through awk '{ print " = \"" $0 "\""}'. This inserts an equals sign and surrounds the original lines with (simple) double quotes.


 = "The Comedy of Errors"
 = "Much Ado About Nothing"
 = "Twelfth Night"

At this point, it's a simple process to move the lines to their correct places using a combination of dd (delete line) and p (put line) and J (join lines) to get my desired result.

Things that really help when using this kind of approach:

  • an open shell window nearby to try one-liners on test data
  • trustworthy multiple levels of undo/redo
  • lots of practice with editor basics

Getting Back Online

Recently, we had a lightning strike that hit a tree in the garden. We also got an electricity spike that looks like it came in through the phone line. That spike took out the DSL modem, the router and the motherboard on my PC.

While recovering from that I made some mistakes that I'll summarize here. Maybe other people can avoid those mistakes or maybe I'll remember better next time.

Lesson One -- Buy a Surge Protector

...*and use it*. We had surge protectors on all the PC equipment. The DSL modem was in another room and there was nothing between it and the phone jack. Since the incident I've bought one of the power strips that includes the protector for the phone line. It's too late for this time of course, but it's early in the year yet and we will have many storms during the summer.

Keep the DSL Account Information

... in an accessible place. I was mostly okay here, but the password I had was wrong or out of date.

Avoid "Wizard" Setups

I bought a replacement modem in a store. This was in part because I've had problems with deliveries of items requiring a signature before where I've had to drive to some remote depot to pick up the item. I hooked it up, went through the setup "wizard" web interface and ran into an authentication problem because the password was wrong.

For the record, the modem was a D-Link DSL-2320B. After I ran through the "wizard" setup once, several of the original options were no longer available. It turned out that this was the key to my problems.

Again, for the record, a way to configure the modem for AT&T DSL that works is as follows:

  1. untick the "DSL Auto-connect" checkbox
  2. leave the VPI setting at 0
  3. leave the VCI setting at 35
  4. choose PPPoE if connecting directly to a PC; choose Bridging if connecting to a home router
  5. leave "Encapsulation Mode" as "LLC/SNAP BRIDGING"
  6. leave LAN settings at default or change them to taste if you know what you're doing

Use the Pinhole Reset Button If You Run Into Trouble

It's on the back of the modem and you press it with a pen or a pin for ten seconds to reset everything to factory defaults. It seems that this is what it took to get the modem to really forget the original, incorrect password and use the new, reset password I was entering through the web interface.

Beware of Premium Cost Services

... unless you enjoy paying for someone to read you their script over the phone. AT&T's initial phone support was actually pretty good — I got through to a second level support person who knew what he was talking about and was helpful, even though I was not using a supported modem. When I called again a couple of days later, I allowed myself to be browbeaten into signing up for the Tech Connect service, at well over $100. I figured I'd get even better support from a networking pro. Instead I was connected to a newbie who clearly didn't know anything beyond the script. After a long time going through the usual rigmarole of turning the modem off and on and checking the lights, the script eventually had me do the pinhole reset, which fixed the problem.

It's possible that, had I spent even more time on the phone and still not fixed the problem, I would have got to a second level of (paid) support. As it was, I was left kicking myself for not trying this myself.

The Internet is Your Friend

... even when the problem is connecting to the Internet. If I had made better use of other ways to connect, I could have saved myself some trouble. After I got my initial connection, I figured out how to get the home router up and running with hints from forum postings. (Basically, make the modem as stupid as it can be, just a bridge, and let the router take care of the PPPoE authentication.)

Phone support in general is slow and limited. The world wide web is, for DSL troubleshooting as for other things, vast and quick to search.

In Sum

Don't do like I did. First of all, protect yourself against lightning. Don't rely on your provider for support beyond the basics (connection information etc.).

Oh, and if you do run into trouble, post so others can learn from your experience.

Sinatra Hints

I've been caught by this for at least the second time: haml views and CSS files not being found in a brand new Sinatra app. The configuration is (to me) somewhat obscure, so I'm documenting the fix here.

To get the views and public directories working properly, be sure to configure app_file (set to nil by default in Sinatra::Base):

configure do
  set :app_file, __FILE__

To get static files working properly, configure static (set to false by default in Sinatra::Base):

configure do
  set :app_file, __FILE__
  set :static, true

Notes on Talking with Slides

I gave an internal company talk reporting on my trip to OOPSLA this year. Here are some notes on the experience.

Things I Would Do Again

Focus on some small, interesting topics

The conference lasted for five days (including the Sunday before the "official" start). I attended mostly tutorials but also a limited number of conference talks. Instead of trying to summarize everything I saw, I picked five topics that interested me. In the end I only presented four.

Avoid Wasting Time With Slideware

This time I created my slides using something called S5, so it was all one big HTML file. This meant I was editing using a tool I know well (my favourite text editor, vim). S5 has its quirks -- notably, it seems to behave differently in different browsers -- but the file format is relatively transparent and easy to modify.

Allow Plenty of Time for Preparation

I decided in advance that I was not going to rehash the material I had already seen. I had a CD with the slides of the presentations I had seen. Instead of copying those I researched the background and came up with my own take on the ideas. This meant many evenings and weekends googling for and reading references.

Break Up the Talk

I gave four mini talks, not directly related to one another. They varied in length and style. There was a good chance that most people found at least one part interesting.

Involve the Audience

I did steal two questions from a "Jeopardy"-style quiz that the OOPLSA organizers staged one evening. I started out the talk with these two questions. If nothing else, it gave me a chance to ensure that at least a few people were awake.

Put the Question on a Slide But Not the Answer

One effective way to motivate the audience is to tweak their curiosity. Putting the answers on the slides makes them complacent. If the answer isn't on a slide they have to listen to get the answer.

Move Material From Slides to Notes

There is a strong temptation to make the slides an outline of the entire talk. This has a powerful soporific effect on the audience. The slides should be a small part of the talk, only drawing attention from time to time.

Changes I Would Make If I Did It Again

Cut Ruthlessly

This means fewer slides and less material on each slide. I figured initially that a minute a slide ought to be about right on average. I didn't run out of time but I did rush the last part of the talk with one eye on the clock.

Avoid Abstraction and Generalities

People tend to understand specific, concrete examples better than more general, abstract statements. This seems to be even truer when they are listening to a talk. Even worse, the general and abstract seems to send people to sleep (not literally but their attention drifts).

Plan More Occasions to Engage the Audience

This would give me a chance to wake them up if necessary. It would also be a chance for me to see how much they are getting it.

Make Sure I Understand Everything I Plan to Say

Towards the end of my talk I came across a slide that included a point that didn't make sense to me when I read it in front of my audience. I stumbled and it was noticed and I'm sure it cost me some credibility. The emphasis is on everything. This means reviewing everything, especially the stuff that's written last thing at night. During the review, I want to make sure I agree with and can support with everything I plan to say.

Break Up Monotony in the Slides

I had very few images in my slides, mostly because I found the amount of work to create my own images burdensome and I found it hard to think of existing images that I could use that would be relevant. In future I'll look into something like Inkscape.

Ruby Notes


In order to install the mongo_ext gem, I had to first ruby1.8-dev package.

Explicit Breakpoints

Nice to examine a failing rspec test: just insert require "rubygems"; require "ruby-debug"; debugger at the relevant point in the code. (From an rspec mailing list)