May, 2007

  • The Old New Thing

    Store Wars and the Meatrix


    Store Wars is a propaganda video for the Organic Trade Association, starring vegetables and bad puns. ("Darth Tater" indeed.) Yes, it's a propaganda video, but at least it's an entertaining propaganda video.

    The same company also created The Meatrix, in conjunction with (deep breath now) the Global Resource Action Center for the Environment. The difference is that The Meatrix isn't funny.

  • The Old New Thing

    We're all in this together: No good deed goes unpunished, redux


    There were several suggestions as to how I could avoid being tagged as the owner of an issue because I helped route the problem. Many of them involved assigning the bug back to the testers to "teach them a lesson".

    Punishing the tester doesn't help the product.

    Remember, we're all in this together. The goal is to fix bugs and ship a quality product.† Being vindictive doesn't further that goal. Especially one suggestion which was to resolve the bug as "Won't fix" with the reason "Tester is an idiot." That may make you feel better, but it is a total disservice to your customers.

    It's almost certainly a sign of dysfunction in a product when the team members spend more time sniping at each other than they do actually working on the product. It's a team effort. Let's try to act like a team.

    Pre-emptive snarky comment: "Hey, bozos! Why not try doing it for once!"

  • The Old New Thing

    Please refer to the instructions that don't exist


    I bought myself a wireless mouse and was setting it up. Step 1: Insert the batteries. Check. Step 2: Position the receiver.

    Make sure the distance between the mouse and receiver is within the wireless range specified on the packaging.

    I wanted to put the receiver on the floor, off of my desk, so I had to make sure it would still be in range of the mouse on my desk. Let's look at the packaging.

    Nope, no mention of the receiver range.

    I guess this proves that nobody reads the installation instructions.

  • The Old New Thing

    Why are console windows limited to Lucida Console and raster fonts?


    In Windows 95, we experimented with other fonts for the console window, and it was a disaster.

    In order to be a usable font for the console window, the font needs to be more than merely monospace. It also needs to support all the characters in the OEM code page. Testing this is easy for SBCS code pages, since they have only 256 characters. But for DBCS code pages, testing all the characters means testing tens of thousands of code points. The OEM code page test already rules out a lot of fonts, because the 437 code page (default in the United States) contains oddball characters like the box-drawing characters and a few astronomical symbols which most Windows fonts don't bother to include.

    But checking whether the font supports all the necessary characters is a red herring. The most common reason why a font ends up unsuitable for use in a console window is that the font contains characters with negative A- or C-widths. These A- and C-width values come from the ABC structure and represent the amount of under- and overhang a character consumes.

    Consider, for example, the capital letter W. In many fonts, this character contains both under- and overhang:

    X      X       X
    X     X  X     X
     X    X  X    X 
     X    X  X    X 
     X    X  X    X 
      X  X    X X   
      X  X    X X   
      X  X    X X   
        X      X    
        X      X    

    Notice how the left and right stems "stick out" beyond the putative cell boundaries.

    I wrote code in Windows 95 to allow any monospace font to be used in console windows, and the ink was hardly even dry on the CD before the bugs started pouring in. "When I choose Courier New as my font, my console window looks like a Jackson Pollock painting with splotches of pixels everywhere, and parts of other characters get cut off." (Except that they didn't use words as nice as "splotches of pixels".)

    The reason is those overhang pixels. The console rendering model assumes each character fits neatly inside its fixed-sized cell. When a new character is written to a cell, the old cell is overprinted with the new character, but if the old character has overhang or underhang, those extra pixels are left behind since they "spilled over" the required cell and infected neighbor cells. Similarly, if a neighboring character "spilled over", those "spillover pixels" would get erased.

    The set of fonts that could be used in the console window was trimmed to the fonts that were tested and known to work acceptably in console windows. For English systems, this brought us down to Lucida Console and Terminal.

    "Why isn't there an interface for choosing a replacement font, with a big annoying message box warning you that 'Choosing a font not on the list above may result in really ugly results. Don't blame me!'?"

    First of all, because we know that nobody reads those warnings anyway. Second, because a poor choice of font results in the console window looking so ugly that everybody would rightly claim that it was a bug.

    "No, it's not a bug. You brought this upon yourself by choosing a font that results in painting artifacts when used in a console window."

    "Well, that's stupid. You should've stopped me from choosing a font that so clearly results in nonsense."

    And that's what we did.

    Of course, if you're a super-geek and are willing to shoulder the blame if the font you pick happens not to be suitable for use in a console window, you can follow the instructions in this Knowledge Base article to add your font to the list. But if you end up creating a work of modern art, well, you asked for it.

    Nitpicker's corner

    In the title of this entry, s/console windows/Windows console windows/†

    †s/Windows console windows/Windows console windows when displayed inside a GUI window, as opposed to consoles that have gone to hardware fullscreen, which is another matter entirely/.

  • The Old New Thing

    Get Sea-Tac flight information (including gate and baggage claim) via email


    There are lots of flight status sites out there. (My favorite is FlightAware because it's the geekiest of them.) Many of them will send you email alerts when flight information changes, but the one from the Port of Seattle is the only one I know of that will also tell you when the arrival gate and baggage claim carousel number change, which is handy when you're picking up someone at the airport. (Main entry page here.)

    A useful site if you're departing from the airport is the TSA's Security Checkpoint Wait Times site, which gives you estimates of wait times based on data collected in the most recent few weeks.

    When you arrive at Seattle-Tacoma International Airport, a friendly voice welcomes you via a pre-recorded message. Historically, the voice has been that of the mayor of the city of Seattle, but a few years ago, it changed to that of the President of the Port Commission. I don't know what prompted the change, but I guess some sort of gentleman's agreement fell apart.

  • The Old New Thing

    Command lines need to be quoted; paths don't


    While it's true that one category of problems comes from failing to quote spaces in command lines, it is a false statement that "path names in the registry should have quotation marks around them for obvious reasons." In fact it's the opposite. Path names should not be quoted.

    Think about it: Quotation marks are a parsing issue, not a file name issue. The quotation marks are not part of the file name. If you type dir or open the folder in Explorer, you don't see any quotation marks. You can't pass quotation marks to CreateFile or GetFileAttributes since they aren't actually part of the file name.

    Quotation marks indicate to code that is parsing a command line that a space should not be interpreted as the end of the command line token. Therefore, you need quotation marks when the string will be interpreted as a command line, such as in the lpCommandLine parameter to CreateProcess (but not the lpApplicationName parameter). Many places in the registry allow you to specify a command line, such as in the Run key or in the registration of static verbs. If the string will be used as a command line, then you need to quote the spaces so that the command line parser knows where the program name ends and the command line arguments begin.

    In the example in the linked comment, the registry key in question is a list of paths to files, not a list of command lines. Since it's not a command line, quotation marks would result in an invalid file name, since quotation marks are not legal file name characters.

    The correct statement of the rule is that command lines in the registry should have quotation marks to protect spaces. Path names, on the other hand, not only do not require quotation marks, but in fact must not have quotation marks, because the quotation mark is not a part of the file name.

    Nitpicker's corner

    Observe that at no point did I claim that Microsoft employees are perfect. Microsoft employees make mistakes, too.

  • The Old New Thing

    Service required * Brewer error *


    Last year, one of the fancy-dancy iCup devices (yes that's its name, I kid you not) in the kitchen of my building went on the fritz. Things break, that's to be expected. The screen which normally guides you through the selection process instead displayed an error message.

    Service required
    * Brewer error *

    The problem was not that it was out of coffee; when that happens, a much more specific error is displayed. Something like, um, "Out of coffee". No, this time, there was some sort of weird internal error that prevented the machine from working. Fortunately, this was only one machine in a two-machine cluster, so the second machine could assume the extra load without interrupting service.

    This didn't stop people from making jokes about it, though. Attached to the machine was a note that read


    Another joker wrote

    Java runtime

    Computer programmers think they're so clever.

    (Meanwhile, Matt Sampson is not convinced that everything that comes out of the coffee machine is actually coffee.)

  • The Old New Thing

    Evergreen Philharmonic Baroque Festival 2007


    The Evergreen Philharmonic Orchestra is a student orchestra consisting of the best high school musicians in the Issaquah School District.† Last weekend I attended their annual Baroque Festival, although there was only one Baroque piece on the program. (False advertising, maybe, but I'll let it slide.) Why was I at a high school student concert? Did I know somebody in the orchestra? Nope. A group of us attended because many of the members in the orchestra are former students of my friend the seventh grade teacher, and I figured it'd be interesting.

    Of course, since it's a high school student orchestra, you have to set your expectations accordingly. What I wasn't expecting was how tentatively most of the students performed; it was as if they were scared of the music. I'll have to chalk that up to performance anxiety. The orchestra started playing with more confidence once we reached the part of the concert where the orchestra took the role of accompanist to various soloists, ironically, the moment at which the orchestra needed to play more subdued!

    Not everyone responded to the pressure by playing softly. One‡ of the soloists responded by rushing through a cadenza faster than I've ever heard it played before. Oh, and a little performance tip for the other two soloists: Resist the urge to have a chat during the first soloist's big cadenza.

    Aside: When I was a student, I recall being nervous up there on stage, but once each piece started, I entered some heightened state of focus, and the audience simply disappeared. I remember once, between pieces, I peeked out into the audience, and it was so scary, I promised never to do it again.

    One student emerged as the standout. The second piece on the concert, the Scherzo from Dvořák's Serenade for Strings, was performed without a conductor, but I noticed that the first violinist was practically motionless. How was he managing to keep the ensemble together? Then I noticed two other performers who were noticeably more expressive. One was a bit too expressive, as if dancing to a piece of pop music secretly piped in via headphones. The other was the lead violist, who clearly was the one in charge. She cued the tempo changes, telegraphed entrances, and generally did the work of keeping the group together. She was a soloist for the next piece, and her talent really shone. She played with confidence and poise, and it was hardly a surprise to read in the program that she is heading off to college on a viola scholarship.

    I've made a note to check up in about four years to see if she's made a name for herself.

    Nitpicker's corner

    †s/musicians/orchestral musicians/. I mean, it's an orchestra. Did I really have to clarify that?

    ‡Students are not named due to their age.

  • The Old New Thing

    Performing an operation in each subdirectory of a directory tree from batch


    To execute a command in each subdirectory of a directory tree from a batch file, you can adapt the following:

    for /f "delims=" %%i in ('dir /ad/s/b') do echo %%i

    (If you want to play with this command from the command prompt, then undouble the percent signs.)

    The /F option enables various special behaviors of the FOR command. The most important change is that a string in single-quotation marks causes the contents to be interpreted as a command whose output is to be parsed. (This behavior changes if you use the usebackq option, but I'm not using that here.) Therefore, the FOR command will run the dir /ad/s/b command and parse the output. The dir /ad/s/b command performs a recursive listing of only directories, printing just the names of the directories found.

    The option we provide, delims= changes the default delimiter from a space to nothing. This means that the entire line is to be read into the %i variable. (Normally, only the first word is assigned to %i.) Therefore, the FOR loop executes once for each subdirectory, with the %i variable set to the subdirectory name.

    The command request to be performed for each line is simply echoing the directory name. In real life, you would probably put something more interesting here. For example, to dump the security descriptor of each directory (which was the original problem that inspired this entry), you can type this on the command line:

    for /f "delims=" %i in ('dir /ad/s/b') do cacls "%i" >>"%TEMP%\cacls.log"

    Nitpicker's corner

    I doubt anybody actually enjoys working with batch files, but that doesn't mean tips on using it more effectively aren't valid.

  • The Old New Thing

    Email tip: Don't ask the same question multiple times in different groups


    If you have a question and you want to ask multiple people or groups, do not send the question individually to each group. Just send the question once with your recipient list on the To line.

    If you send it individually, then each recipient will not know that you asked the question to other groups as well. This in turn creates wasted effort because one group won't know that another group already answered your question (or has already started researching it).

    For example, one person asked the same question on a shell-related discussion group, again on a Windows 2000 discussion group, and a third time on a Windows XP discussion group. I research the problem and responded on the Windows XP discussion group. Meanwhile, one of my colleagues researched the problem and responded on the shell discussion group. (The two answers were the same.) Congratulations, you created twice as much work as necessary. To prevent it from going to a triple, I replied on the Windows 2000 group saying that the issue has been taken care of.

    Just because we don't charge billable hours to your team doesn't mean that our time is free.

    I see a variation of this happening in blog comments as well. Somebody will ask the exact same question to Larry Osterman, Michael Kaplan, and me. Now, first of all, I specifically do not provide technical support (it's spelled out in the Contact Page), but that doesn't stop people from trying anyway. Even if you think your question is of general interest and put it into the Suggestion Box, that doesn't mean that I'll agree with your assessment, and even if I do, given the historical rate at which I accept topics from the Suggestion Box, you won't get an answer for around three years.

    One particularly insistent person not only sent the question to Larry and me, they even did it after opening a case with Microsoft developer support! (How do I know? Because developer support forwarded the question to my team.)

Page 3 of 5 (44 items) 12345