Friday, February 27, 2009

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)
Thursday, February 26, 2009

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)
Wednesday, February 25, 2009

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)
Tuesday, February 24, 2009

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)
Monday, February 23, 2009
Title: Programming Sudoku
Author: Wei-Ming Lee
Rating: 2.5 stars out of 5
Publisher: Apress
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)
Sunday, February 22, 2009
Title: Watchmen (book)
Author: Alan Moore, Dave Gibbons
Rating: 4.5 stars out of 5
Publisher: DC Comics
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)
Saturday, February 21, 2009

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)
Friday, February 20, 2009

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)
Thursday, February 19, 2009

So how do I go from the Project Gutenberg etext to LaTeX?

Here's the Gutenberg text for the pictured fragment:

(BLOOM'S WEATHER. A SUNBURST APPEARS IN THE NORTHWEST.)

THE BISHOP OF DOWN AND CONNOR: I here present your undoubted emperor-
president and king-chairman, the most serene and potent and very puissant
ruler of this realm. God save Leopold the First!

ALL: God save Leopold the First!

BLOOM: (IN DALMATIC AND PURPLE MANTLE, TO THE BISHOP OF DOWN AND CONNOR,
WITH DIGNITY) Thanks, somewhat eminent sir.

WILLIAM, ARCHBISHOP OF ARMAGH: (IN PURPLE STOCK AND SHOVEL HAT) Will you
to your power cause law and mercy to be executed in all your judgments in
Ireland and territories thereunto belonging?

BLOOM: (PLACING HIS RIGHT HAND ON HIS TESTICLES, SWEARS) So may the
Creator deal with me. All this I promise to do.

MICHAEL, ARCHBISHOP OF ARMAGH: (POURS A CRUSE OF HAIROIL OVER BLOOM'S
HEAD) GAUDIUM MAGNUM ANNUNTIO VOBIS. HABEMUS CARNEFICEM. Leopold,
Patrick, Andrew, David, George, be thou anointed!


The Gutenberg transcriber has converted all italics to uppercase. All accents on letters have been lost (there were none in this fragment).

Here's the corresponding LaTeX that I derived from the above:

\stage{(Bloom's weather.
A sunburst appears in the northwest.)}

\DownConnor:
\gab{1470}
I here present your undoubted emperor-president and king-chairman,
the most serene and potent and very puissant ruler of this realm.
God save Leopold the First!

\All:
God save Leopold the First!

\Bloom:
\stage{(in dalmatic and purple mantle,
to the bishop of Down and Connor, with dignity)}
Thanks, somewhat eminent sir.

\WillArmagh:
\stage{(in purple stock and shovel hat)}
\gab{1480}
Will you to your power cause law and mercy to be executed
in all your judgments in Ireland and territories thereunto belonging?

\Bloom:
\stage{(placing his right hand on his testicles, swears)}
So may the Creator deal with me.
All this I promise to do.

\MikeArmagh:
\stage{(pours a cruse of hairoil over Bloom's head)}
\latin{Gaudium magnum annuntio vobis.
Habemus carneficem.}
Leopold, Patrick, Andrew, David, George, be thou anointed!


I could simply have used \em to get italics, but I'm a big believer in semantic markup, so I wrote a set of custom macros, like \stage and \latin. The name macros, like \Bloom and \All, are defined in terms of the \role macro. The \gab macro lists the line number in the Gabler edition of Ulysses. It's useful for looking up reference works and it would have been hard to do in reStructuredText.

\newcommand{\stage}[1]{\emph{#1}}
\newcommand{\role}[1]{{\textsc{#1}}}
\newcommand{\Bloom}{\role{Bloom}}
\newcommand{\gab}[1]{\marginpar{#1}}


I used Vim to massage the text.

• For my own sanity, I have broken each clause onto a separate line. Much of this can be done by substituting a newline after every period and right parenthesis. The other breaks require manual splitting and joining of lines.
• Transforming BLOOM: into \Bloom: is a trivial text substitution, :%s/^BLOOM: /\\Bloom:\r/
• All the uppercase text has been converted to mixed case. Much of it needs to be bracketed by \stage{} in this chapter. The rest needs to be treated as \latin{}, \hebrew{}, \french{}, and so on.

I used the following Vim macro to bracket the visual selection with \stage{}.

" ;s => SELECTION -> \stage{selection}
vnoremap <buffer> <silent> ;s u>a}<Esc><i\stage{<Esc>


Breaking it down, since that looks like line noise.

 vnoremap Visual-mode keymap; no further expansion of the right-hand side Buffer-local. Won't apply in other buffers. Mapping won't be echoed on the Vim command line ;s Mapping is bound to sequence ;s u Make highlighted text lowercase; cancels selection > Go to end of former visual selection a} Append } < Go to beginning of former visual selection i\stage{ Insert \stage{

It's necessary to append to the end of the selection first. Were I to first insert at the beginning, the append would happen seven characters (len('\stage{')) too early. (I picked this trick up from Christian Robinson's HTML macros.) Then I have to go back and convert a few characters to uppercase with the ~ operator.

This workflow isn't for everyone and it would be difficult if I had to hand it off to someone else. Most non-geeks would prefer to use a WYSIWYG tool like Word. I loathe Word and I want the control.

All of this is somewhat tedious, since even with useful Vim macros taking care of many of the changes, I still have to make manual tweaks on almost every line. But this is also a virtue, as it makes me intimately familiar with the text.

The hardest task—at least for me—is making the dramaturgical decisions. Usually, it can be hard to decide exactly to whom a particular line should be ascribed—making sense of Bloom's interior monologue, for example, or splitting a long stretch of narrative between several narrators. This year's chapter is written in the form of a play, so that particular problem is gone. Last year was the first time we abridged a chapter. This year, we have to reduce 60,000 words to 15–20,000 words. Whether that's by breaking the chapter into two or more readings, or by deep, deep cuts, I have yet to decide. And that's where the line-by-line familiarity is helpful.

posted on Thursday, February 19, 2009 8:38:21 AM (Pacific Standard Time, UTC-08:00)
Wednesday, February 18, 2009

I have a long-standing fascination with typography. In the late '80s and early '90s, I became quite adept with TeX and LaTeX, the well-known scientific typesetting system. When I was at ICPC, I think I read the TeXbook cover to cover—twice. I became the TeX administrator for the CS department while I was at Brown.

And then I moved to Seattle to work for Microsoft and entered the world of Windows, and I left TeX behind for more than 15 years.

I wrote the other day that I prepared the Bloomsday scripts in XML for several years, using XSLT to generate HTML. I used to send the HTML to the readers, but everyone's browser paginated differently when printing, which led to confusion at rehearsals. So I started giving them PDFs: problem solved except for the person who needed a large-print version.

Last year, I prepared the script with reStructuredText. Normally, I use reST to generate HTML, but reST can also generate LaTeX. I decided to use rst2latex to take advantage of LaTeX's superior typesetting.

I wasn't happy with the results. The script looked like a crappy technical paper from the '90s, thanks to the tired Computer Modern layout. CM works well for math, less well for text, in my opinion.

The MacTeX extras included XeTeX, a modern variant of TeX that supports Unicode and OpenType fonts. I experimented with using Hoefler to set the script. You can see the results above: it looks gorgeous.

More to come.

posted on Wednesday, February 18, 2009 8:11:43 AM (Pacific Standard Time, UTC-08:00)
Tuesday, February 17, 2009

On a mailing list, I saw a dumb question answered with a link to LetMeGoogleThatForYou.

In the old days, you might admonish someone to ask smart questions.

posted on Wednesday, February 18, 2009 7:14:26 AM (Pacific Standard Time, UTC-08:00)
Monday, February 16, 2009

I'm about halfway through the 60,000-word Circe chapter of Ulysses, converting it to LaTeX.

For several years, I took the plaintext from the Project Gutenberg etext, prepared the script in XML, used XSLT to transform it into HTML, tarted it up with CSS, and then saved it as a PDF. You can see a screenshot above.

I'll write up tomorrow why I switched to LaTeX last year.

posted on Monday, February 16, 2009 8:43:25 AM (Pacific Standard Time, UTC-08:00)
Sunday, February 15, 2009

My talented wife got back today from four days at the Madrona Fiber Arts Festival in Tacoma. As you can see from Emma's Flickr page, she's knit a lot of beautiful pieces.

I'm hoping she will revive her dormant blog and write more about some of her projects. She does have some writeups at Ravelry (Facebook for knitters) under her username Emma, but that's only visible to members.

posted on Sunday, February 15, 2009 9:10:24 AM (Pacific Standard Time, UTC-08:00)
Saturday, February 14, 2009
Title: Bleeding Kansas
Author: Sara Paretsky
Rating: 4 stars out of 5
Publisher: Signet
Pages: 593
Keywords: fiction
Reading period: 4–13 February, 2009

In the 1850s, three anti-slavery families settled next to each other in rural Kansas: the Grelliers, the Schapens, and the rich Fremantles. Seven generations later, the last of the Fremantles is gone, the Grelliers are progressive farmers, and the Schapens are belligerent fundamentalists. Gina Haring, a Wiccan lesbian from New York, housesits the Fremantle mansion, while she tries to pick up the pieces of her life. Inadvertently, she triggers a cascade of changes. Most notably, the Grellier son, at odds with his anti-war mother, enlists and is killed in Iraq, sending her into a deep depression.

Paretsky has moved her focus from her series of novels about V.I. Warshawski, a female PI in Chicago, to rural Kansas, where she grew up. It's her take on What's the Matter With Kansas?, the transformation of a populist anti-slavery state into a deep-red locus of reactionaries.

It's a mostly sympathetic portrait of beleagured farmers. The main characters, Jim Grellier; his 14-year-old daughter, Lara; and Robbie Schapen, the 14-year-old misfit, are well-drawn and believable. The romance that develops between Lara and Robbie is tender and touching. The rest of the Schapens, though, are something of a caricature.

posted on Sunday, February 15, 2009 7:19:25 AM (Pacific Standard Time, UTC-08:00)
Friday, February 13, 2009
Title: Gran Torino
Director: Clint Eastwood
Rating: 4 stars out of 5

Clint Eastwood directs himself as Walt Kowalski, a retired auto worker. Newly widowed, estranged from his sons, and haunted by his Korean War experiences, Walt is a bitter, racist old bastard.

He doesn't like the Hmong immigrants who live next door and he nearly shoots the teenage boy, Thao, when he catches Thao trying to steal his beloved 1972 Gran Torino. The theft was to be the reluctant Thao's gang initiation. The gang come by to punish Thao and Walt runs the “gooks” off his lawn at gunpoint. The Hmong neighbors start bringing over food and flowers in gratitude. Walt is confounded and wants to be left alone. Then Walt rescues Thao's sister, Sue, from some “spooks”, and she invites him over to a celebration.

Walt slowly thaws as he realizes that he has more in common with the Hmong than he does with his own children. Thao is sent over to work for Walt as penance for the attempted theft. You guessed it, Walt and Thao begin to bond. Things go well for a while, then the gang comes back.

Eastwood is convincing as the flinty-eyed old son of a bitch who can stare down gangbangers a quarter of his age. And convincing too as the damaged, lonely old man, with a good heart under the foul-mouthed exterior.

Less convincing was the overly neat ending, when Walt goes to deal with the gang.

Recommended.

posted on Saturday, February 14, 2009 7:35:17 AM (Pacific Standard Time, UTC-08:00)
Thursday, February 12, 2009

I mentioned in my post on reStructuredText that I use a little command-line tool, pbcopy, to pipe the output into the clipboard. I finally found a similar tool for Linux, xsel.

• Mac: pbcopy (UTF-8 aware, unlike the built-in version of pbcopy) copies its input to the pasteboard (Mac name for the clipboard); pbpaste writes the pasteboard to stdout.
• Linux: xsel gets and sets the X selection.
• Windows: winclip reads and writes the clipboard in a variety of formats. Use -m for UTF-8 text. The winclip binary is available as part of the outwit package.
posted on Thursday, February 12, 2009 8:51:18 AM (Pacific Standard Time, UTC-08:00)
Wednesday, February 11, 2009

A good piece in yesterday's New York Times about sugar in the American diet:

How sweet it is! The American diet, that is. While the current recommendation is a maximum intake of eight teaspoons of sugars a day, one 12-ounce can of regular soda (or a 20-ounce bottle of VitaminWater) delivers eight or nine teaspoons. That means you are at or over the limit before you’ve eaten a single cookie or container of fruit-flavored yogurt, or even some commercial tomato soups or salad dressings with added sugars. The result is an average daily intake of more than 20 teaspoons of sweet calories.

Marshall Brain demonstrated the amount of sugar in soda. Eight teaspoons of sugar is a startling amount when it's placed in one pile.

In the early to mid-90s, I drank about a liter of Coke a day. It caught up with me. I long ago kicked that particular habit, to the betterment of my waistline.

posted on Wednesday, February 11, 2009 8:01:59 AM (Pacific Standard Time, UTC-08:00)
Tuesday, February 10, 2009

This is, by far, the snowiest winter that I've ever experienced in Seattle—and I was in Ireland for the worst two weeks.

At least the snow that came down yesterday and today didn't stick.

posted on Wednesday, February 11, 2009 7:14:52 AM (Pacific Standard Time, UTC-08:00)
Monday, February 09, 2009

As you can see from the attached picture, I just created Facebook Groups for three social organizations that I'm involved in: Freely Speaking Toastmasters, Wild Geese Players of Seattle, and BiNet Seattle.

I set up a LinkedIn group for FSTM too.

posted on Tuesday, February 10, 2009 7:47:24 AM (Pacific Standard Time, UTC-08:00)
Sunday, February 08, 2009
Title: Taken
Director: Pierre Morel
Rating: 3 stars out of 5