Tuesday, March 10, 2009 
Perdition House
Title: Perdition House
Author: Kathryn R. Wall
Rating: 3 stars out of 5
Publisher: St. Martin's Minotaur
Copyright: 2003
Pages: 295
Keywords: mystery
Reading period: 8–9 March, 2009

Bay Tanner is a young widow and aspiring private investigator from wealthy South Carolina stock. When a hitherto unknown shirt-tail cousin (fifth half cousin, specifically) bursts into Bay's life, she brings havoc in her train.

As one of the characters says, the plot sounds like a made-for-TV movie. Still, Bay is a feisty heroine and the background is not one that has been mined deeply.

posted on Wednesday, March 11, 2009 5:01:46 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Monday, March 09, 2009 
Cat Voyeurs

We were watching An Engineer's Guide to Cats on YouTube when I looked out the front window and spotted these two looking in. They climbed up the six-foot gooseberry frames to the windowsill.

Meet Whiskey and Guinness, from next door. They think they own the place. When it's hot in the summer, they've been known to stroll in and wander around our living room—while we're in it.

I left the back door open for a few minutes one Saturday morning, while packing the car. I came back in and found Whiskey just inside the back room. He scarpered when I yelled at him and I slammed the door behind him. It was then that I discovered that Guinness was now locked in. He tore past me, to get out the back door. He couldn't, so he tried to climb up and over the venetian blind. He got to the top before he realized that wasn't going to work either. Down he dropped from the ruined blind and back into the living room with him. I opened the door wide and stamped into the living room from the other side to drive him out.

Cheeky buggers. Almost as cheeky as the racoon who climbed up the gooseberry frames one night. We looked out to see a face staring in at us, startling us. We stepped outside with a flashlight and yelled at him, but he was quite reluctant to go.

posted on Tuesday, March 10, 2009 5:50:01 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [1]
Sunday, March 08, 2009 
">The Seafarer
Title: The Seafarer
Author: Conor McPherson
Rating: 4 stars out of 5

We saw The Seafarer at the Seattle Rep this afternoon. Two brothers, Richard and Sharkey, share a house in north Dublin. There's little love lost between them. Richard, recently blinded, is controlling and wheedling. Sharkey is trying to stay off the gargle and it's not easy when Richard and his crony Ivan drink like fishes.

Sharkey's old rival, Nicky, arrives on Christmas Eve, bringing a stranger with him, Mr. Lockhart. They settle down to a game of poker and Sharkey privately learns that he's met the stranger once before. For Mr. Lockhart is the devil and he wants to collect the old debt that Sharkey owes him and take Sharkey's soul.

The brothers fight and fight. Like all squabbling siblings, they know how to get under each other's skin. Ivan and the brothers are wasters, whose lives have been distorted by drink, and Nicky is little better.

The play is grim in places, but it's also very funny, rich with humor between the characters and sometimes at their expense.

The cast do a creditable job of Irish accents, particularly the Harkin brothers. There's a large, apparent difference in ages between the two actors, making them somewhat improbable as brothers.

Runs until March 28th.

posted on Monday, March 09, 2009 6:04:17 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Saturday, March 07, 2009 
reStructuredText syntax highlighting

Vim has had syntax highlighting since version 5.0 in 1998. It quickly became indispensable. It's hard to go back to looking at monochromatic source code after you've become accustomed to syntax highlighting.

The syntax highlighting is tied into Vim's support for colorschemes, which define colors for the fundamental syntax groups like Number, Comment, and String. The syntax highlighting for a particular language defines custom syntax groups for specific language features, such as cppExceptions or htmlEndTag,

The custom syntax groups are linked to the underlying fundamental syntax groups. Hence, if you change your colorscheme, your syntax highlighting is updated automatically.

The reStructuredText syntax highlighting in Vim 7.2 has some shortcomings, in my opinion. For example, *italic* shows up as italic in gVim, but in the same color as regular text, while **bold** shows up in a different color, but not bolded.

When you declare a syntax group, you can either link it to another gropu and pick up that's one color and fontstyle, or you can give it a concrete fontstyle and color. If you do that, then the syntax group won't change color when you change the colorscheme.

After much poking around, I found a way to set a syntax group's fontstyle and link it to another group's color: see hi def rstItalic and hi def rstBold below.

I also make use of certain Unicode characters in my reStructuredText source, such as endash and emdash, which are very hard to tell apart in a fixed-width font—even though an emdash (—) is twice as wide as an endash (–) in a proportional font. Worse, a non-breaking space is invisible and can't easily be distinguished from a normal space.

I provided custom highlighting for these Unicode characters and the various ‘curly’ “quotes”.

All of this goes into ~/.vim/syntax/rst.vim, which treats $VIMRUNTIME/syntax/rst.vim as a subroutine. I tried putting it into ~/.vim/after/syntax/rst.vim, which gets executed after $VIMRUNTIME/syntax/rst.vim completes, but then I can't provide non-overrideable definitions for rstEmphasis and rstStrongEmphasis.

function! s:SynFgColor(hlgrp)
    return synIDattr(synIDtrans(hlID(a:hlgrp)), 'fg')
endfun

function! s:SynBgColor(hlgrp)
    return synIDattr(synIDtrans(hlID(a:hlgrp)), 'bg')
endfun

syn match rstEnumeratedList /^\s*[0-9#]\{1,3}\.\s/
syn match rstBulletedList /^\s*[+*-]\s/
syn match rstNbsp /[\xA0]/
syn match rstEmDash /[\u2014]/
syn match rstUnicode /[\u2013\u2018\u2019\u201C\u201D]/ " – ‘ ’ “ ”

exec 'hi def rstBold    term=bold cterm=bold gui=bold guifg=' . s:SynFgColor('PreProc')
exec 'hi def rstItalic  term=italic cterm=italic gui=italic guifg=' . s:SynFgColor('Statement')
exec 'hi def rstNbsp    gui=underline guibg=' . s:SynBgColor('ErrorMsg')
exec 'hi def rstEmDash  gui=bold guifg=' . s:SynFgColor('Title') . ' guibg='. s:SynBgColor('Folded')
exec 'hi def rstUnicode guifg=' . s:SynFgColor('Number')

hi link rstEmphasis       rstItalic
hi link rstStrongEmphasis rstBold
hi link rstEnumeratedList Operator
hi link rstBulletedList   Operator

source $VIMRUNTIME/syntax/rst.vim

syn cluster rstCruft                contains=rstEmphasis,rstStrongEmphasis,
      \ rstInterpretedText,rstInlineLiteral,rstSubstitutionReference,
      \ rstInlineInternalTargets,rstFootnoteReference,rstHyperlinkReference,
      \ rstNbsp,rstEmDash,rstUnicode
posted on Saturday, March 07, 2009 8:56:02 AM (Pacific Standard Time, UTC-08:00) 
#    Comments [0]
Friday, March 06, 2009 
Watchmen
Title: Watchmen (film)
Director: Zach Snyder
Rating: 4.5 stars out of 5
Copyright: 2009

As promised yesterday, we saw the initial midnight showing of the Watchmen movie at the Pacific Science Center IMAX. And, lo, the geeks came in their numbers and they were greatly pleased. Some were dressed as Rorschach, one came as a smurf; no, I lie, he was Dr. Manhattan.

I summarized the plot in my review of the book. That still holds: the movie was largely faithful to the book. In many scenes, it was clear that the book had served as a storyboard. Too faithful in some ways at 165 minutes long. Some subplots were eliminated; no doubt they will resurface in the director's cut. The Tale of the Black Freighter has been made as a separate animated feature for the DVD. One crucial point about the ending was changed (to Peter's outrage), bringing it closer to The Dark Knight.

I found myself immersed in the movie, though sitting in front of a six-storey screen does tend to draw one in. It's a visual spectacle that couldn't have been made twenty years ago during the early attempts to turn it into a movie. It's violent, more so than the book and more shocking than the book. Unsurprisingly, much of that extra violence centers around Rorschach, the uncompromising sociopath.

The acting is adequate to the task. Nite Owl (Patrick Wilson) and Silk Spectre (Malin Akerman) are the two most normal characters and hold the moral center of the film. Jackie Earle Haley as Rorschach has the most difficult role, hidden behind a face-covering mask most of the time, trying to convey the character's tortured soul. Billy Crudup has little choice but to play Dr Manhattan as a blank cipher, while Jeffrey Dean Morgan hits the right note as the Comedian. Matthew Goode as Ozymandias comes off more as a cartoon villain than in the book.

Fans of the book will certainly enjoy it. I think newcomers will like it too.

posted on Friday, March 06, 2009 7:01:57 PM (Pacific Standard Time, UTC-08:00) 
#    Comments [0]
Thursday, March 05, 2009 
Watchmen poster

Quis custodiet ipsos custodes? (Who Watches the Watchmen?) asked Juvenal.

Answer: we do. The Watchmen movie, that is. Peter, Carol, Raven, Iain, Emma, and I are all going to see the midnight initial showing at the Pacific Science Center IMAX.

I'm not sure that I've ever been geeky enough to watch the midnight opening of a movie before. But it was Peter's idea.

Peter and I shared an apartment in 1990–92 when we were both grad students at Brown, and it was his copy of Watchmen that I first read.

And so the loop closes.

posted on Friday, March 06, 2009 2:48:09 AM (Pacific Standard Time, UTC-08:00) 
#    Comments [0]
Wednesday, March 04, 2009 
How Acne Develops

Zits. Somehow all those ads on TV for acne cream never quite tell you that zits continue after your teenage years.

This post was brought to you by the small but annoying pimple that appeared yesterday. Feh!

posted on Thursday, March 05, 2009 7:54:12 AM (Pacific Standard Time, UTC-08:00) 
#    Comments [0]
Tuesday, March 03, 2009 
George Clery

I knew three of my grandparents; they all died after I reached adulthood. My mother's father, George Victor Clery, died 12 days before I was born, on March 3rd, 1965. I was to be named Vincent after my father, [Charles] Vincent Reilly. Instead, I was christened George Vincent Reilly. I was the first grandchild for both the Clerys and the Reillys. I think I must have been a welcome distraction.

Ironically, my parents had gotten married on his birthday, March 30th, the previous year, and he didn't live to celebrate their first anniversary. The timing was partly in his honor and partly because it was Easter Monday. Catholics were not allowed to marry in Lent then.

I only know the man by repute. He worked, like many in his family, in a bank. His word was law in his household, but my mother adored him. He was very sociable: he'd invite clients to lunch in the bankhouse at the drop of a hat and my grandmother would have to figure out to feed them. His mother was told that he'd not live beyond infancy and his health was poor all of his life, but he was no hypochondriac. I see something of him in my uncles, Dick and Gabriel. Certainly the face and the moustache; also the gruffness.

George Clery, 1900-1965.

posted on Tuesday, March 03, 2009 8:27:25 AM (Pacific Standard Time, UTC-08:00) 
#    Comments [0]
Monday, March 02, 2009 
Worst-case hash table collisions

At lunch today, I told Eric about Hash Attacks: for many hash functions, it's possible to construct a large set of keys that collide. This can be used to cause a Denial of Service as hashtable operations can be induced to take O(n) time instead of O(1).

Crosby and Wallach successfully demonstrated this against a number of applications.

Andrew has a good writeup of Hash Algorithm Attacks.

There are various mitigations suggested. The one that I used when I first became aware of this problem is to use a salt to the hash function.

In other words, change:

unsigned hash(const char* s)
{
    unsigned h = 0;
    while (*s)
        h = h * 101 + (unsigned char*) *s++;
    return h;
}

to:

unsigned hash(const char* s)
{
    unsigned h = SALT;
    while (*s)
        h = h * 101 + (unsigned char*) *s++;
    return h;
}

where SALT is chosen randomly when the hash table is created or when the process starts. This should be enough to vary the order in which keys are distributed to buckets from run to run.

posted on Monday, March 02, 2009 8:04:28 AM (Pacific Standard Time, UTC-08:00) 
#    Comments [0]
Sunday, March 01, 2009 
Law of Conservation of Energy

A few years ago, after watching one too many whodunnit TV mysterys, I coined my

Law of Economy of Characters
The killer is innocuously introduced in the first 20 minutes

In real life, the killer may not be known until late in the investigation—if ever.

In a TV mystery, any non-recurring character who gets more than a few lines has to be a potential suspect—to the audience. The character is not there gratuitously. Their salary is being paid for a reason.

It's not universally true, but it works more often than not. It's less true in books, where throwaway characters are easy to introduce.

Googling around, I found the following, attributed to Roger Ebert:

Ebert's Law of Conservation of Characters
Any main character whose purpose is not readily apparent must be more important than he or she seems

I'm in good company.

posted on Monday, March 02, 2009 6:06:53 AM (Pacific Standard Time, UTC-08:00) 
#    Comments [0]
Saturday, February 28, 2009 
PBwiki

I use or participate in a handful of wikis hosted at PBwiki. A year ago, I wrote a PBwiki syntax highlighting plugin for Vim, modeled after the ones that I put together for the FlexWiki and SocialText wikis. Essentially, paste the wikitext into Vim, get syntax highlighting, edit the text, then paste it back into the multiline textbox. I find the WYSIWYG editors annoying.

PBwiki is forcing all wikis to switch over to v2.0 by March 9th. The good news is that the upgrade is painless and reliable. They offer new features, such as an improved editor, better access control, and a new look.

The bad news is that for cranks like me, there's no longer an advanced editor and wikitext. I can use the WYSIWYG editor or I can switch it to HTML source mode. Ick!

posted on Sunday, March 01, 2009 6:38:34 AM (Pacific Standard Time, UTC-08:00) 
#    Comments [2]
Friday, February 27, 2009 
Lucida Hybrid

One thing that's been bugging me since I started using Opera is that bold and italic text was showing as normal text in my personal blog. Yet other browsers were correctly displaying bold and italic on my blog.

I'm still not entirely sure why Mac Opera had a problem with it, but I fixed it by using the Lucida Hybrid stylesheet tweak.

I adjusted a few other things while I was at it. The most obvious is that the font size is larger.

Most RSS readers won't pick up the stylesheet, so take a look at the actual blog.

posted on Friday, February 27, 2009 11:18:18 AM (Pacific Standard Time, UTC-08:00) 
#    Comments [0]
Thursday, February 26, 2009 
Stack Overflow

I like Stack Overflow, Jeff Atwood's programming Q&A site. It's quickly become a go-to place for all kinds of programming questions. It's certainly easier to find a definitive answer there than trying to wade through a thread in a mailing list archive. The social dynamics seem to be working and a definite community has evolved.

I've been going there more often recently. I browse the hot questions and I often learn something from them.

I'm answering some questions too. I've been doing this for twenty years on Usenet and mailing lists. I might as well get a little credit for it on SO. My reputation is 131 as I write this: I expect it will grow.

posted on Friday, February 27, 2009 3:23:26 AM (Pacific Standard Time, UTC-08:00) 
#    Comments [0]
Wednesday, February 25, 2009 
Interviewing your next boss

Esther Schindler has a post about interviewing your next boss: should a candidate dev manager meet everyone who'll be reporting to them?

Yes. Definitely. If you want a successful, cohesive team, there has to be trust. A manager can make or break a team.

A new manager starts at a disadvantage, relative to a new individual contributor. The new dev is expected to ramp up and have time to build relationships with the team. The new manager has to build the relationships as soon as possible.

If the manager gets to interview with the team before being offered the job, both parties benefit. Why would you want to manage a team that you'd never met? Shouldn't the team have a chance to reject someone who's a bad fit?

I've interviewed “up” twice, once for a dev manager and once for a CTO, at different jobs. But those were the exceptions. Every other time there was a change of manager at any job, I was not consulted.

The two interviews were successful: I'd work for either of them again.

The dev manager went through several hours of interviews with the team, meeting us two or three at a time. We interviewed developer candidates similarly. We asked different questions of the manager, of course. I remember asking him if he had ever laid off or fired someone.

The CTO got to meet the entire engineering team en masse: a dozen or so of us grilled him for an hour and came away impressed.

I think that in either case if the teams had made serious objections, the candidate would not have been hired. Certainly, in both cases, the teams vetoed developer candidates.

It may be traditional, but I think it's a mistake for companies not to have managers be interviewed by their future reports.

posted on Thursday, February 26, 2009 6:43:14 AM (Pacific Standard Time, UTC-08:00) 
#    Comments [0]
Tuesday, February 24, 2009 
Safari 4 coverflow

Apple launched the public Safari 4 beta today.

It runs beautifully on Vista and it's the fastest browser that I've seen, noticeably faster than Chrome. Everything that I tried worked fairly well; I saw only a few minor glitches.

I installed it on my MacBook at home this evening. It crashes at startup every time that I attempt to run it. Fortunately, it comes with an uninstaller so that I could revert to Safari 3.21.

Back to Opera for now.

posted on Wednesday, February 25, 2009 7:18:48 AM (Pacific Standard Time, UTC-08:00) 
#    Comments [0]
Monday, February 23, 2009 
Programming Sudoku
Title: Programming Sudoku
Author: Wei-Ming Lee
Rating: 2.5 stars out of 5
Publisher: Apress
Copyright: 2006
Pages: 214
Keywords: programming, introductory
Reading period: 22 February, 2009

I was Toastmaster of the Day at this evening's meeting of Freely Speaking Toastmasters. My theme was software development and I wanted to give the non-developer audience a taste for what it's like to write a program. I talked about writing a simple Sudoku game.

Yesterday, I read Programming Sudoku for background. I bought this book for Emma after reading about it on Scott Hanselman's blog. It's targeted at beginning programmers and walks them through building a Sudoku game and solver. I was hoping to get Emma more interested in programming–unsuccessfully. She found it repetitious and a little confusing, and she found some typos in the code.

Pedagogically, the book is good. It starts by creating a simple WinForms application in Visual Basic to play a Sudoku game. Then it builds a solver for simple games and refines the solver to handle harder games. Next, it adds a puzzle generator. It concludes with a brief chapter on a similar game, Kakuro. The explanation of gameplay is clear; the approach seems reasonable.

The code, however, is horrible. It's ugly, it's verbose, and it's repetitive. Consider that the code for doing some operation to a row is almost identical to doing the same operation to a column, but no attempt is made to abstract such operations into helper functions.

Or how about this unexplained fragment to see if a column is complete, which is repeated often, with minor variations:

pattern = "123456789"
For r = 1 To 9
    pattern = pattern.Replace(actual(c,r).ToString(), String.Empty)
Next
If pattern.Length > 0 Then
    Return False
End If

To me, it's obvious that this is a poor man's set difference operation. To a novice programmer, I doubt it.

Examples should be exemplary and held to a higher standard than code that is not intended for public view. All too often, sample code ends up in production. When I wrote samples for classic ASP, I took care to make them good code.

The book is short. The author could have shown some ugly code as an initial solution, then cleaned it up and explained why the new code was better. That would have done his readers a greater service.

I cannot recommend this book to novices: they won't learn good habits from it.

posted on Monday, February 23, 2009 8:20:16 AM (Pacific Standard Time, UTC-08:00) 
#    Comments [0]
Sunday, February 22, 2009 
Watchmen (book)
Title: Watchmen (book)
Author: Alan Moore, Dave Gibbons
Rating: 4.5 stars out of 5
Publisher: DC Comics
Copyright: 1987
Pages: 416
Keywords: graphic novel, superheroes
Reading period: 14–22 February, 2009

Set in an alternate 1985 where costumed heroes are real—and outlawed—Watchmen follows six adventurers. Rorschach, half-mad, continues his vigilante activities. Nite Owl is retired and a worrywart. The former Ozymandias—the world's smartest man—is now one of the richest. The Comedian is murdered at the very beginning; after the Keene Act passed, he was allowed to continue operating as a government enforcer. Dr. Manhattan was transformed into a superbeing in a nuclear accident in 1959; he is America's strategic weapon in the arms race with the Soviets. And the former Silk Spectre is his girlfriend.

These people are not boy scouts, fighting for truth, justice, and the American Way. They are flawed individuals with motivations that are often murky, even to themselves.

Who watches the watchmen? Who indeed?

The very presence of masked adventurers over the last fifty years has transformed society. Dr. Manhattan is both responsible for many technological advances, such as flying cars, and the locus of much of the world's tension. When he disappears off the face of the earth, destabilizing the balance of power, the Soviets immediately invade Afghanistan and Pakistan.

Rorschach meanwhile is convinced that someone is going after masked adventurers, and investigates. He's right. There is something going on—something unspeakable.

Watchmen tells a complex story, weaving together many different strands into a tapestry that is a triumph of the comic book. The narrative moves back and forth across fifty years, collecting many viewpoints. And the comic within the comic–the Tale of the Black Freighter—accentuates the main storyline. The artwork too repays careful study. There's often two or three things going on in a single panel. Truly, a picture is worth a thousand words.

Originally published in twelve issues, Watchmen was promptly republished as a book. It is one of the titles that gave rise to the category of graphic novel, deserving the Hugo that it won. The film adaptation will be released in March.

Highly recommended.

posted on Sunday, February 22, 2009 8:07:47 PM (Pacific Standard Time, UTC-08:00) 
#    Comments [0]
Saturday, February 21, 2009 
Eric's hand over bingo cards

Emma, Eric, and I went to Gay Bingo this evening. It's a monthly fundraiser for the Lifelong AIDS Alliance. This is not your grandmother's church bingo: the Sisters of Perpetual Indulgence are the ushers and the show is MC'd by a drag queen.

Every Gay Bingo has a theme. Tonight's was the Love Boat, the campy 70's TV show. Many in the audience dress for the occasion. I wore the nearest thing to a lounge suit that I had; Emma accessorized a nautical top with a scarf. We brought Jill and Dick the last time we went. They have an enormous collection of costumes and they were some of their choice Fifties glad rags.

I've been there perhaps ten times over the last 15 years. For the first decade, it was held in the basement of a synagogue on Capitol Hill. It was always packed. Finally, they moved to a larger space, the South Lake Union Naval Reserve building, a few years ago. That's always packed too.

It's always a lot of fun. And for a good cause too.

posted on Sunday, February 22, 2009 7:37:24 AM (Pacific Standard Time, UTC-08:00) 
#    Comments [0]
Friday, February 20, 2009 
Procrastination

Aaron Swartz has a moderately interesting piece on productivity and procrastination.

We all procrastinate. I certainly procrastinate.

Sometimes my procrastination is tantamount to making sure that my pencils are very, very sharp. More often, I find myself surfing the web, free associating off in random directions. There's no end to the fascinating distractions.

In lesser cases, I procrastinate because I'm bored or not fully engaged in what I'm doing.

When I have a more severe case, I think fear is the root cause. I don't really know how to proceed, I don't really understand what it is that I'm supposed to be doing, and I don't really want to come to grips with it. And so I don't. My fear of the pain dissuades me.

When I finally do get over the hump, quite often, I'll find myself engaged in the problem and have difficulty tearing myself away. I develop a sense of accomplishment about the problem. At best, I find myself in a state of flow.

The key to my getting started seems to be to find some small, manageable piece that I can accomplish. The momentum gets me on to the next piece and then the next.

Easier said than done, alas.

posted on Friday, February 20, 2009 8:48:13 AM (Pacific Standard Time, UTC-08:00) 
#    Comments [2]