• The Old New Thing

    Would a team of midgets be the greatest offense in baseball history?


    Todd Gallagher answers the weird sports questions you always wondered but knew were too stupid even to ask. Think of it as the sports version of Mythbusters.

    • Would a team of midgets be the greatest offense in baseball history, because they would draw walk after walk after walk?
    • Could a morbidly obese goalie shut out an NHL team?
    • Could an average person beat a professional tennis player if the pro had to use a frying pan instead of a racquet?

    Well, he sort of gives away the answer to the last question in the title of his book, Andy Roddick Beat Me with a Frying Pan. The stories behind how he set about finding the answers to these absurd questions are even more entertaining than the answers themselves! Here's an interview with Only a Game's Bill Littlefield. [Direct link - Real format]

    On a somewhat concidental note, tonight I'm going to watch the Seattle Thunderbirds take on the Tri-City Americans, making good on my earlier admission of the possibility of seeing another hockey game. Hopefully with normal-sized goalies.

  • The Old New Thing

    Christmas lights in the Dyker Heights neighborhood


    If you come to New York City in December, you'll find the festive Christmas season throughout the town. Skaters wobble beneath the giant tree in Rockefeller Center. Giant snowflakes adorn the upper floors of the Saks Fifth Avenue store while animated Christmas-themed window displays entertain visitors on the ground floor of Saks, as well as Macy's (where Santa takes a roller coaster ride), Lord and Taylor, and many other stores.

    But somewhat overlooked in all this extravagance are the amateur efforts of the residents of Dyker Heights. (Take the R to 86th then make the 20-minute walk or catch the B64 bus to 11th Avenue.) There is no line for tickets; there is no entrance. You just wander through the streets admiring the Christmas lights, inflatable snowmen, Nativity displays, and other decorations, be they tasteful and reverential or (what you're more likely to notice) ostentatious and mind-boggling.

    There were a lot of extravagant displays, but the one that took the cake was the large house with a 15-foot-tall Santa flanked by 20-foot tall nutcracker soldiers, accompanied by two merry-go-rounds and life-size figures waving to passers-by from the upper balcony.

    Visit in the early evening, say from 5pm to 7pm. This hits the sweet spot between "late enough that night has fallen" and "catch them before the lights are turned off." We visited during a weekday and there were barely any people on the streets, and those we saw were locals just out for an evening stroll. There were a few cars driving slowly through the neighborhood, but not enough to disrupt that friendly neighborhood atmosphere. (I suspect things are much different on the weekends.) Remember, this is a residential neighborhood, not a commercial display, so don't make a lot of noise and please respect the residents' privacy.

  • The Old New Thing

    If control-specific messages belong to the WM_USER range, why are messages like BM_SETCHECK in the system message range?


    When I discussed which message numbers belong to whom, you may have noticed that the messages for edit boxes, buttons, list boxes, combo boxes, scroll bars, and static controls go into the system range even though they are control-specific. How did those messages end up there?

    They didn't start out there.

    In 16-bit windows, these control-specific messages were in the control-specific message range, as you would expect.

    #define LB_ADDSTRING      (WM_USER + 1)
    #define LB_INSERTSTRING   (WM_USER + 2)
    #define LB_DELETESTRING   (WM_USER + 3)
    #define LB_RESETCONTENT   (WM_USER + 5)
    #define LB_SETSEL         (WM_USER + 6)
    #define LB_SETCURSEL      (WM_USER + 7)
    #define LB_GETSEL         (WM_USER + 8)
    #define LB_GETCURSEL      (WM_USER + 9)
    #define LB_GETTEXT        (WM_USER + 10)

    Imagine what would have happened had these message numbers been preserved during the transition to Win32,

    (Giving you time to exercise your imagination.)

    Here's a hint. Since 16-bit Windows ran all programs in the same address space, programs could do things like this:

    char buffer[100];
    HWND hwndLB = <a list box that belongs to another process>
    SendMessage(hwndLB, LB_GETTEXT, 0, (LPARAM)(LPSTR)buffer);

    This reads the text of an item in a list box that belongs to another process. Since processes ran in the same address space, the address of the buffer in the sending process is valid in the receiving process, so that when the receiving list box copies the result to the buffer, it all works.

    Now go back and imagine what would have happened had these message numbers been preserved during the transition to Win32.

    (Giving you time to exercise your imagination.)

    Consider a 32-bit program that does exactly the same thing that the code fragment above does. The code probably was simply left unchanged when the program was ported from 16-bit to 32-bit code, since it doesn't generate any compiler warnings and therefore does nothing to draw attention to itself as needing special treatment.

    But since processes run in separate address spaces in Win32, the program now crashes. Well, more accurately, it crashes that other program, since it is the other program that tries to copy the text into the pointer that it was led to believe was a valid buffer but in fact was a pointer into the wrong address space.

    Just what you want. A perfectly legitimate program crashes because of somebody else's bug. If you're lucky, the programmers will catch this bug during testing, but how will they know what the problem is, since their program doesn't crash; it's some other program that crashes! If you're not lucky, the bug will slip through testing (for example, it might be in a rarely-executed code path), and the experience of the end user is "Microsoft Word crashes randomly. What a piece of junk." (When in reality, the crash is being caused by some other program entirely.)

    To avoid this problem, all the "legacy" messages from the controls built into the window manager were moved into the system message category. That way, when you sent message 0x0189, the window manager knew that it was LB_GETTEXT and could do the parameter marshalling for you. If it had been left in the WM_USER range, the window manager wouldn't know what to do when it gets message 0x040A since that might be LB_GETTEXT, or it might be TTM_HITTESTA or TBM_SETSEL or any of a number of other control-specific messages.

    Theoretically, this motion needed to be done only for legacy messages; i.e., window messages that existed in 16-bit Windows. (Noting that Windows 95 added some new 16-bit messages, so this remapping had to continue at least through Windows NT 4 with the shell update release.) Nevertheless, the window manager team added the *_GET*INFO messages in the system message range even though there was no need to put them there from a compatibility standpoint. My suspicion is that it was done to make things easier for accessibility tools.

    Note however that placing new messages in the system message range is more the exception than the rule for the edit box and other "core" controls. For example, the new message EM_SETCUEBANNER has the numeric value 0x1501, which is well into the WM_USER range. If you try to send this message across processes without taking the necessary precautions, you will crash the target process.

    (Note: Standard disclaimers apply. I won't bother repeating this disclaimer on future articles.)

  • The Old New Thing

    Another celebrity knitter: Tracey Ullman


    Tracey Ullman joins the roster of celebrity knitters with her book Knit 2 Together: Patterns and Stories for Serious Knitting Fun. (She also gets to add to the pile of books whose titles are of the form Catchy title: Long boring subtitle.)

  • The Old New Thing

    How do the names in the file security dialog map to access control masks?


    When you call up the file security dialog, you'll see options like "Full Control" and "Read and Execute". That's really nice as friendly names go, but when you're digging into the security descriptor, you may need to know what those permissions really map to when it comes down to bits.

    First, the summary attributes:

    Friendly name Access mask Inheritance

    If you go to the Advanced view, then you get much more precise control:

    Friendly name Access mask
    Traverse Folder / Execute File FILE_TRAVERSE == FILE_EXECUTE
    Read Attributes FILE_READ_ATTRIBUTES
    Read Extended Attriibutes FILE_READ_EA
    Create Files / Write Data FILE_ADD_FILE == FILE_WRITE_DATA
    Create Folders / Append Data FILE_ADD_SUBDIRECTORY == FILE_APPEND_DATA
    Write Attributes FILE_WRITE_ATTRIBUTES
    Write Extended Attributes FILE_WRITE_EA
    Delete Subfolders and Files FILE_DELETE_CHILD
    Delete FILE_DELETE
    Read Permissions READ_CONTROL
    Change Permissions WRITE_DAC
    Take Ownership WRITE_OWNER

    (In the Advanced view, you control inheritance from the "Apply to" drop-down combo box.)

    Note that the "Delete Subfolders and Files" and "Delete" attributes together determine whether you can delete a file or subdirectory: You can delete an item either if you have DELETE permission on the item or if you have DELETE_CHILD permission on its parent. This "combo" allows you to set up a directory where everybody can create files and can delete files that they have created, while still retaining the ability as the directory's owner to delete any file in it. You do this by granting yourself DELETE_CHILD permission on the directory and granting DELETE to CREATOR_OWNER as an inheritable attribute. Since you have DELETE_CHILD permission, you can delete anything in the directory. And since the creator/owner has DELETE permission, people can delete the files that they themselves created.

    [Update 2pm: INHERIT_ONLY_ACE should be OBJECT_INHERIT_ACE.]

  • The Old New Thing

    Stuart Stevens takes performance-enhancing drugs in order to see what they do


    It's an old story, but once again timely thanks to the drug scandal that rocked this year's Tour de France. Not to be confused with the drug scandal that rocked last year's Tour de France. (But that's okay, because it's all cleaned up now. Tipster.)

    Amateur cyclist Stuart Stevens takes performance-enhancing drugs for six months in order to see what they do. Read the first-hand account of the effects of human growth hormone, EPO, and steroids.

  • The Old New Thing

    András Schiff 2006 lectures on the Beethoven piano sonatas


    In 2006, pianist András Schiff gave a series of eight lecture-recitals covering the complete cycle of Beethoven piano sonatas. Here are all the lectures on one page. (Beware: The metadata on these mp3 files is all over the map.)

    As an incompetent student of the Beethoven sonatas, I find these lectures absolutely riveting.

    Note: Schiff assumes you are familiar with basic musical terminology, terms like exposition, subdominant, Neapolitan, enharmonic and quaver.

  • The Old New Thing

    News flash: Car salesmen are sneaky and underhanded


    Steve Tripoli looks at deception in the car sales industry.

  • The Old New Thing

    Dlaczego Microsoft zatopił Polskę?


    A colleague of mine stopped by my office to tell me that he got a telephone call from his father in Poland asking him why Microsoft sunk Poland. My colleague was somewhat baffled by this question, since his father isn't a computer nerd, but his father explained that he saw the story on the front page of the newspaper. Apparently, the story ran in the largest Polish newspaper, but it doesn't appear that they credited their source, demonstrating that quality journalism is hard to find in any country. My guess is that the jump into Poland came from this page, which does credit my article. I'm just guessing, though, since I can't read Polish.

    I just found it weird to see my stuff spreading all the way to general-audience newspapers in Poland.

  • The Old New Thing

    If the law says you can't file a petition, you might need to file it anyway, in case somebody later says that you should've even though the law says you couldn't


    It sounds like a scene from the movie Brazil, but in fact it's the law.

    Let's rewind a bit. The introduction is a bit technical, but I'll try to keep it short.

    There is a legal filing known as a habeas petition and another known as a petition for review. There are rules regarding what each one covers and the deadlines for filing them. Prior to 2005, there was no deadline for habeas petitions, but you had to file your petition for review within 30 days of whatever it was the government did that you wanted to object to. In 2005, Congress passed (and the President signed) a law which recategorizes what the two types of filings covered, and many claims that had fallen under the habeas petition have been reclassified as requiring a petition for review instead.

    This change in the rules creates a gap in coverage because Congress forgot to include a grandfather clause (or, for computer geeks, a "smooth migration plan"): What if, at the time the new law took effect, the thing you want to complain about was reclassified as requiring a petition for review, but it took place more than 30 days ago? You wake up one morning and somebody tells you, "Hey, there's a new law today. You just lost your right to respond."

    What you do, then, is file a lawsuit challenging the new rules. And then two years later, the Third Circuit Court hears your case and rules that, yes, you're right, the law that Congress passed is unconstitutional (a violation of Section 9, Clause 2, known commonly as the Suspension Clause) because it denied you the opportunity to file a claim.

    And now here's the weird part.

    Instead of saying, "And therefore we strike down this part of the law as unconstitutional," the court says "And therefore we will retroactively rewrite the law so it is constitutional again (saving Congress and the President the trouble of having to do it themselves), and oh lookie here, according to this new law we just made up, you did have a constitutionally guaranteed opportunity to file your petition, but it expired two years ago."

    In other words, what you should have done in 2005 was hire a psychic, who would then instruct you to spend thousands of dollars hiring an attorney to draft and file a petition which, according to the law, you were legally barred from filing, in anticipation of the courts (two years later) rewriting the law in order to make that filing legal again. And then when you file your petition, you have to convince the court to accept it, explaining that yes, I know that I cannot legally file this petition, but a psychic told me to do it.

    You can read the court's decision yourself. (Despite the connotations associated with the term legalese, court decisions are actually quite readable. You just have to skip over the complicated footnotes.)

Page 370 of 448 (4,472 items) «368369370371372»