Tuesday, March 31, 2009 
House from Southwest Corner

Our neighborhood was built in spurts. The brick Tudors, like ours, were built in the 1930s. The houses adjoining mine were built in the years after World War II.

There's a house for sale a few doors down that's very like ours. We snooped around on Sunday during the open house.

Our house was built in 1931; the other, the year before. Ours is slightly deeper, but the floor plans are very similar. Theirs has no eyecatching yellow brick trim. Our kitchen was remodeled in the sixties, taking over part of the next room. Theirs never was and it's tiny. Our basement is half finished and it had a bathroom added in the seventies. Their basement is unfinished. Our dormers upstairs are walk-in closets; their dormers are unfinished attic. Our living room and dining room windows were replaced with picture windows, while they still have leaded panes.

Dark wood trim predominates in their house, the electrical outlets and light switches look like the originals, and the paintwork was shabby. In short, it had changed little in the eight decades since it was built.

Quite an eerie experience, seeing our house much as it started out.

posted on Wednesday, April 01, 2009 6:59:51 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Monday, March 30, 2009 
Big Ben

The Cozi Tech Blog needed some love, so I wrote a post on augmenting Python's strftime.

posted on Tuesday, March 31, 2009 6:17:58 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Sunday, March 29, 2009 
Black Dossier
Title: Black Dossier: The League of Extraordinary Gentlemen, Volume 3
Author: Alan Moore, Kevin O'Neill
Rating: 3.5 stars out of 5
Publisher: America's Best Comics
Copyright: 2007
Keywords: graphic novel
Reading period: 28 March, 2009

England, 1958: an alternate universe where famous fictional characters really lived and the regime of Big Brother has just come to an end. Sixty years ago, the British Crown gathered together the Murray Group, extraordinary adventurers charged with sensitive missions. The remnants of the group fled England in World War II. Now they've come back to steal their dossier from MI-5, a dossier that could lead the Government back to them, a dossier that details the exploits of earlier groups over the last 300 years.

LXG3 pulls in everything, from Gulliver's Travels to James Bond, Orlando to Fanny Hill, Prospero to Toyland, Dan Dare to Billy Bunter, and Bertie Wooster and Jeeves battling Cthulhu. It's way over the top. Mostly it's fun.

posted on Monday, March 30, 2009 5:34:35 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Saturday, March 28, 2009 
By Myself
Title: By Myself
Author: Lauren Bacall
Rating: 4.5 stars out of 5
Publisher: Knopf
Copyright: 1978
Pages: 378
Keywords: autobiography, movies
Reading period: 10–28 March, 2009

Betty Bacal is an only child, abandoned by her father, raised by her Rumanian Jewish mother in New York. Stagestruck from an early age, she takes acting classes for years but gets little stage work. Modeling work is a fallback. A cover shot for Harper's Bazaar leads Howard Hawks to bring her out to Hollywood. Within months, Hawks' protogée, now Lauren Bacall, is the lead in “To Have or Have Not” and falling in love with her costar, Humphrey Bogart. Bogie is 45 to her 20, but it doesn't matter. He's married too; that doesn't matter either. They marry, of course, and have a dozen great years together until Bogie's death of cancer in ’57. She's devastated but she has two young children. On the rebound, she takes up with Frank Sinatra. It's not right for either of them and Sinatra dumps her. She spends the Sixties married to Jason Robards. Like Bogie, he's a drinker and that marriage falls apart, leaving her with a son. Her movie and theatre career has been hit or miss for years, but revives in the Seventies with a long-running stage hit in Applause (the musical version of All About Eve).

Bacall writes frankly about her life and shortcomings, looking back with hard-earned wisdom from middle age. She spends half of her girlhood at a high emotional pitch. When she plunges into something, it's total commitment; no holding back, for better or worse. Her early screen persona was as a knowing sexpot; in reality, she was unsure and inexperienced. The “Look”, her trademark upward tilting look with her chin pressed against her chest, was born of the need to still her nervous shaking.

She tells a good story, pulling the reader along. She drops many big names, having moved in high-powered circles all her adult life. The Hollywood elite of the 40s and 50s are there. Katie Hepburn becomes a close friend after The African Queen. She was close to Adlai Stevenson when he ran for President in 1952. Bobby Kennedy was a friend. The book becomes most affecting when she writes of the death of Bogie and of her beloved mother in 1969, of those last, lingering months of denial and her wrenching pain afterwards.

Highly recommended.

posted on Saturday, March 28, 2009 8:43:14 PM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Friday, March 27, 2009 
Toastmasters Competition

I've been to a few Toastmasters competitions in the past. Tonight was the first time that I helped out at one, as one of the timers. It was the combined Area 35 and 36 competition.

A typical Toastmasters competition has two parts, a speech competition and an evaluation competition. In the speech competition, the competitors give a prepared speech on a topic of their own choosing. Some speech competitions are humorous; tonight's wasn't. In the evaluation competition, the invited speaker gives a speech heard by all the competitors. They are taken out of the room, then one at a time, they come back in and evaluate that speech.

The speech competition is always fun. You get to hear several good speeches. I heard speeches tonight about a teenage boxing experience, watching a mother's peaceful death in a hospice, our collective obsession with "better", and choosing a high school for a son.

In the evaluation competition, it's interesting to hear different people's take on the same speech.

posted on Saturday, March 28, 2009 6:58:19 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Thursday, March 26, 2009 
Seattle, early evening

For various reasons, I hadn't cycled to work in about three weeks, just before the clock went forward.

It was very pleasant to cycle home in broad daylight for a change. Very pleasant.

posted on Friday, March 27, 2009 2:05:18 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Wednesday, March 25, 2009 
Ack!

On a StackOverflow question about favorite Vim plugins, I learned about Ack, a replacement for grep that's smarter about searching source trees.

Ack is written in Perl. The built-in :vimgrep is rather slow. It seems to have some Vim-specific overhead, such as creating swap files and executing BufRead autocmds. Ack is noticeably faster, though somewhat slower than GNU grep.

Which would you rather type to search a tree, ignoring the .svn and .git subtrees?

$ ack -i -l foobar
$ grep --exclude='*.svn*' --exclude='*.git*' -i -l -r foobar .

The ack takes 6 seconds to search 4500 files, while the grep completes in 2. This does not count the time that I spent trying to figure out the correct syntax and argument quoting for --exclude. The help says both --regexp=PATTERN and --exclude=PATTERN, but the latter is a glob (file wildcard pattern).

On Windows, I wrapped ack with pl2bat.

posted on Wednesday, March 25, 2009 8:40:10 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Tuesday, March 24, 2009 
Refinancing

When we bought our house in 2000, our interest rate was about 8.5% on a 30-year loan. A couple of years later, we refinanced it down to 6.875%, which reduced our monthly payments by several hundred dollars.

Today, we signed the paperwork to refinance it again, down to 4.75% over 20 years. That drops our monthly payment by another $300, which is most welcome, as Emma's unemployed.

All of these are fixed-rate mortgages. We're really not fans of adjustable-rate mortgages: too many horror stories about people starting out a low rate and not being able to cope when the rates go up.

We went through the same guy each time, Sanjay Pitroda of MetLife Home Loans in Kirkland.

posted on Wednesday, March 25, 2009 3:52:40 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Monday, March 23, 2009 
Exuberant Ctags

Exuberant Ctags is an essential complement to Vim: it generates an index of symbol names (tags) for a set of source files. In Vim, just place the cursor on a function name and type C-] to go to its definition.

Ctags works well for most of the languages that I deal with, but falls down badly on modern JavaScript. Its built-in parser simply doesn't handle declarations like these:

Sizzle.selectors.filters.animated = function(elem) { // ...
ajaxSetup: function( settings ) {

I came across Unbad's workaround earlier tonight. His code didn't work for me, so I hacked on it until it did:

--langdef=js
--langmap=js:.js
--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\{/\1/,object/
--regex-js=/([A-Za-z0-9._$()]+)[ \t]*[:=][ \t]*function[ \t]*\(/\1/,function/
--regex-js=/function[ \t]+([A-Za-z0-9._$]+)[ \t]*\(([^)])\)/\1/,function/
--regex-js=/([A-Za-z0-9._$]+)[ \t]*[:=][ \t]*\[/\1/,array/
--regex-js=/([^= ]+)[ \t]*=[ \t]*[^"]'[^']*/\1/,string/
--regex-js=/([^= ]+)[ \t]*=[ \t]*[^']"[^"]*/\1/,string/

Simply add the above to ~/.ctags or $HOME/ctags.cnf.

posted on Monday, March 23, 2009 7:08:18 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Sunday, March 22, 2009 
No Country for Old Men
Title: No Country for Old Men
Author: Cormac McCarthy
Rating: 4.5 stars out of 5
Publisher: Picador
Copyright: 2005
Pages: 309
Keywords: fiction
Reading period: 20–22 March, 2009

Rural Texas, 1980. Llewelyn Moss, out hunting in the middle of nowhere, finds the remains of a drug buy that went wrong: dead bodies, shot-up cars, black tar heroin. And a satchel with two million dollars in cash. Moss takes the money and runs. He knows it's stupid, he knows that people will come after him, and he does it anyway.

Anton Chigurh is the worst of the killers on his trail. Relentless, remorseless, untroubled by conscience, and offended by the wrongness of Moss's act. He and Moss will be locked in a dance of death.

The bodies were found in Sheriff Bell's patch. Ed Tom Bell is near retirement, an old-school lawman at odds with modern life. Bell is slow, deliberate, and perceptive. He wants to catch Moss before Chigurh does.

McCarthy's prose is spare and evocative, as dry as the harsh landscape. These men are laconic, not given to frivolous chitchat.

Highly recommended. I'll have to get around to the Coen Brothers' movie soon.

posted on Monday, March 23, 2009 5:54:00 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Saturday, March 21, 2009 
Irish Rugby Football Union logo

I grew up hating rugby. I spent eleven years at a rugger-bugger school in Dublin. I couldn't stand the game. I was a small, unathletic child with no interest in sports. Rugby, even the modified rugby that they teach seven-year-olds, was violent and unpleasant and involved running around cold, wet fields. I had a big operation on my feet when I was 10 and I parlayed that into an excuse never to play rugby again.

I can't remember when I last watched a rugby match, but it was surely back in the '80s, as I doubt I've seen one over the 20 years that I've been in the States.

So imagine the improbability of my watching rugby today. Truly a historic occasion. But not just for me, but for Ireland too. The Irish team won the Grand Slam for the first time in 61 years.

Some Irish friends invited us over for a big Irish breakfast and to watch the match. To be honest, I was more tempted by the food than the match, but I ended up enjoying the game. It was a close game and a nail-biting finish. It was the first time that Emma had watched rugby and she thought it was more interesting than the slow, staged plays of American Football.

I was also reminded why I had never wanted to play rugby. It is often said that rugby is a hooligan's game played by gentlemen, while soccer is a gentlemen's game played by hooligans, and the former was borne out today. A dangerous, bloody game.

posted on Saturday, March 21, 2009 7:51:56 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Friday, March 20, 2009 
List Comprehension

Python has list comprehensions, syntactic sugar for building lists from an expression.

>>> [2 * i for i in (2, 3, 5, 7, 11)]
[4, 6, 10, 14, 22]

This doesn't work so well when the comprehension expression is itself a list: you end up with a list of lists.

>>> def gen():
...     for l in [['a', 'b'], ['c'], ['d', 'e', 'f']]:
...         yield l
...
>>> [l for l in gen()]
[['a', 'b'], ['c'], ['d', 'e', 'f']]

This is ugly. Here's one way to build a flattened list, but it's less elegant than the comprehension.

>>> x = []
>>> for l in gen():
...     x.extend(l)
...
>>> x
['a', 'b', 'c', 'd', 'e', 'f']

It took me a while to find a readable list comprehension, with a little help from Google. Use sum() on the outer list and prime it with an empty list, []. Python will concatenate the inner lists, producing a flattened list.

>>> sum([l for l in gen()], [])
['a', 'b', 'c', 'd', 'e', 'f']

Alternatively, you can use itertools.chain().

>>> import itertools
>>> list(itertools.chain(*gen()))
['a', 'b', 'c', 'd', 'e', 'f']

That might be slightly more efficient, though I find the sum() to be a little more readable.

>>> import itertools
>>> list(itertools.chain(*gen()))
['a', 'b', 'c', 'd', 'e', 'f']

That might be slightly more efficient, though I find the sum() to be a little more readable.

Edit: I forgot about nested comprehensions

>>> [inner
...     for outer in gen()
...         for inner in outer]
['a', 'b', 'c', 'd', 'e', 'f']

Somewhat cryptic on one line however:

>>> [j for i in gen() for j in i]
['a', 'b', 'c', 'd', 'e', 'f']
posted on Friday, March 20, 2009 7:05:07 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Thursday, March 19, 2009 
The Choirboys
Title: The Choirboys
Author: Joseph Wambaugh
Rating: 3.5 stars out of 5
Publisher: Dell
Copyright: 1975
Pages: 387
Keywords: crime, fiction
Reading period: 17–19 March, 2009

Ten LAPD patrolmen congregate regularly in MacArthur Park for “choir practice”: late-night bitchfests, marathon boozing, and group sex with a couple of cocktail waitresses.

LA's finest are not exactly fine specimens of humanity, but then neither are the people they serve, whom they consider little better than the ones they arrest. The choirboys include an idealist, a psychopath, a prankster, and a world-class mooch. They fight and they drink and they argue: everything but discuss the things that really bother them. Wambaugh lampoons the choirboys, but he reserves his full contempt for their supervisors, martinets concerned more with coverups than justice.

There isn't much of a plot. It's more of a series of anecdotes about his characters, sometimes grim, often hilarious, frequently profane.

posted on Friday, March 20, 2009 5:42:28 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Wednesday, March 18, 2009 
James Joyce

I am co-directing this year's reading of Ulysses with Helen. We have decided to do the first half of the chapter with some light cuts. The Circe character, Bella Cohen, will not be seen until next year, as we'll be stopping shortly before she makes her entrance.

We had a readthrough-cum-planning meeting ten days ago at Helen's and a rehearsal tonight at my house. We'll need several more rehearsals, but it's starting to come together.

We'll be reading at the University Bookstore on Saturday, June 13th.

posted on Wednesday, March 18, 2009 7:00:19 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Tuesday, March 17, 2009 
AIG

It takes a special … talent? … chutzpah? … to fuck up the global economic system to the point where you need four enormous bailouts totaling $170 billion and then to give your senior people $165 million in bonuses.

It's like they're taunting the lynch mob.

posted on Tuesday, March 17, 2009 7:40:29 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Monday, March 16, 2009 
Fleshmarket Close
Title: Fleshmarket Close
Author: Ian Rankin
Rating: 4 stars out of 5
Publisher: Orion
Copyright: 2004
Pages: 484
Keywords: crime, fiction
Reading period: 14–16 March, 2009

DI John Rebus investigates the murder of an illegal immigrant, who had ties to asylum seekers in Edinburgh. DS Siobhan Clarke looks into the disappearance of a teenaged girl; soon, the rapist of the girl's sister is murdered.

Rebus and Siobhan struggle with the uglier side of life in Edinburgh, notably, racism, latter-day slavery, and the increasing numbers of asylum seekers. As usual, their personal lives are in a mess: Rebus drinks too much; Siobhan falls asleep with a tub of ice cream.

As in other Rebus books, the two investigations end up being linked somewhat too neatly for my liking.

posted on Tuesday, March 17, 2009 6:25:05 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Sunday, March 15, 2009 
Bistrot Bistro

We discovered Bistrot Bistro in Kitsilano on a previous visit to Vancouver. It's an agreeable little French restaurant just south of downtown. Emma suggested that we eat there again for my birthday, and it was a fine choice.

We ate from the prix fixe menu for $26 apiece. She had the carrot soup, roast chicken, and raspberry sorbet; I had the pate de campagne, a peppercorn steak, and a chocolate mousse. The prix fixe included a sizeable quantity of pommes frites. We added Brussel sprouts, a baguette with olive tapenade, and a half-litre of Pinot Gris, and walked away two hours later, pleasantly sated.

The last time we were there, it was full. This time, there were plenty of seats. I suspect a combination of Sunday night, wet weather, and the economy. The food was still good.

posted on Monday, March 16, 2009 5:56:33 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Saturday, March 14, 2009 
Vancouver

We drove up to Vancouver today. We'll be here until Tuesday. It's my birthday tomorrow and I have two days of vacation that I have to use by the end of March or lose them, so why not.

I always like Vancouver. It's unequivocally a major city. Vancouver feels more urban than Seattle, where people have only been moving into high-density downtown condos and apartments for a few years.

We're staying at the Sunset Inn and Suites in the West End. We stayed here before. It's relatively cheap, clean, and centrally located. No particular charm either.

Tomorrow, we see my great-uncle Dick and his wife Margaret. They're both 92 and about to move into a retirement center. We'll have a nice dinner in the evening for my birthday.

posted on Sunday, March 15, 2009 6:33:45 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Friday, March 13, 2009 
Grease Monkeys

Ow! Ow! Ow! It's Friday the 13th and I ransomed my car this evening from the shop for over two grand—more than half of it labor. I think I'm in the wrong line of business. Maybe I should be a greasemonkey instead.

The clutch was worn out and the flywheel needed replacing, which required taking out the transmission.

We've only had one other comparable bill with this car and it has over 90,000 miles. We're not doing too badly overall, except that the other bill was late last year.

Feh.

posted on Saturday, March 14, 2009 5:52:45 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Thursday, March 12, 2009 

Via Tor.com, Lex Luthor asking the president for a bailout.

posted on Friday, March 13, 2009 2:02:59 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
Wednesday, March 11, 2009 
Looting

In today's New York Times, David Leonhardt writes, of a sixteen-year-old economics paper:

In the paper, they argued that several financial crises in the 1980s, like the Texas real estate bust, had been the result of private investors taking advantage of the government. The investors had borrowed huge amounts of money, made big profits when times were good and then left the government holding the bag for their eventual (and predictable) losses.

In a word, the investors looted. Someone trying to make an honest profit, Professors Akerlof and Romer said, would have operated in a completely different manner. The investors displayed a “total disregard for even the most basic principles of lending,” failing to verify standard information about their borrowers or, in some cases, even to ask for that information.

The investors “acted as if future losses were somebody else’s problem,” the economists wrote. “They were right.”

He goes on to distinguish between classic moral hazard and looting:

With moral hazard, bankers are making real wagers. If those wagers pay off, the government has no role in the transaction. With looting, the government’s involvement is crucial to the whole enterprise.

Ryan Chittum at CJR has a good take on the piece.

It's clear that the system that led to the current economic clusterfuck needs some fundamental reform and regulation. The incentives to loot show up the hollow promise of the markets self regulating.

posted on Thursday, March 12, 2009 5:04:53 AM (Pacific Daylight Time, UTC-07:00) 
#    Comments [0]
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]