Holy cow, I wrote a book!
This weekend I saw Good-Bye, Lenin!, a German movie about a young man who must pretend that East Germany still exists, for the sake of his mother who was in a coma during the fall of the Berlin Wall and therefore remains unaware of the earth-shattering changes the took place while she was unconscious.
There is, of course, the comedy of a young man attempting to recreate a world that no longer exists. But there is also the look into the lives of the people of East Germany. Behind that wall were real people, living their lives day to day. They weren't evil people. And when the wall fell, that life ended.
Of course, this movie also taught me that my German needs a lot of work.
From a "learning German" point of view, I tried to keep track of when the formal "Sie" was used and when the informal "du"/"ihr". Since I didn't grow up in Germany, deciding which form to use is for me still a bit of a puzzlement. (When I spoke with some German college students, they said that my German was okay, except that I kept using the wrong word for "you". Then again, one of them also fell over laughing when I said, "Bilder knipsen". Apparently "knipsen" is the cutesy way of taking pictures. Thanks to my German textbook for not pointing this out.)
Windows lets you hibernate the entire machine, but why can't it hibernate just one process? Record the state of the process and then resume it later.
Because there is state in the system that is not part of the process.
For example, suppose your program has taken a mutex, and then it gets process-hibernated. Oops, now that mutex is abandoned and is now up for grabs. If that mutex was protecting some state, then when the process is resumed from hibernation, it thinks it still owns the mutex and the state should therefore be safe from tampering, only to find that it doesn't own the mutex any more and its state is corrupted.
Imagine all the code that does something like this:
// assume hmtx is a mutex handle that // protects some shared object G WaitForSingleObject(hmtx, INFINITE); // do stuff with G ... // do more stuff with G on the assumption that // G hasn't changed. ReleaseMutex(hmtx);
Nobody expects that the mutex could secretly get released during the "..." (which is what would happen if the process got hibernated). That goes against everything mutexes stand for!
Consider, as another example, the case where you have a file that was opened for exclusive access. The program will happily run on the assumption that nobody can modify the file except that program. But if you process-hibernate it, then some other process can now open the file (the exclusive owner is no longer around), tamper with it, then resume the original program. The original program on resumption will see a tampered-with file and may crash or (worse) be tricked into a security vulnerability.
One alternative would be to keep all objects that belong to a process-hibernated program still open. Then you would have the problem of a file that can't be deleted because it is being held open by a program that isn't even running! (And indeed, for the resumption to be successful across a reboot, the file would have to be re-opened upon reboot. So now you have a file that can't be deleted even after a reboot because it's being held open by a program that isn't running. Think of the amazing denial-of-service you could launch against somebody: Create and hold open a 20GB file, then hibernate the process and then delete the hibernation file. Ha-ha, you just created a permanently undeletable 20GB file.)
Now what if the hibernated program had created windows. Should the window handles still be valid while the program is hibernated? What happens if you send it a message? If the window handles should not remain valid, then what happens to broadcast messages? Are they "saved somewhere" to be replayed when the program is resumed? (And what if the broadcast message was something like "I am about to remove this USB hard drive, here is your last chance to flush your data"? The hibernated program wouldn't get a chance to flush its data. Result: Corrupted USB hard drive.)
And imagine the havoc if you could take the hibernated process and copy it to another machine, and then attempt to restore it there.
If you want some sort of "checkpoint / fast restore" functionality in your program, you'll have to write it yourself. Then you will have to deal explicitly with issues like the above. ("I want to open this file, but somebody deleted it in the meantime. What should I do?" Or "Okay, I'm about to create a checkpoint, I'd better purge all my buffers and mark all my cached data as invalid because the thing I'm caching might change while I'm in suspended animation.")
Who knew that Beethoven wrote ambient music?
The people at NOTAM took Beethoven's 9th Symphony and slowed it down so that the entire performance takes 24 hours. It's actually quite nice to listen to. (I like 2.1 myself.)
[Rats, scooped by MetaFilter. Honest, it was in my queue! Nobody will believe me; they'll think I swiped it from MeFi...]
A few months ago, NPR covered a similar experiment with the movie Psycho. I think it was a little less successful.
"I'll do my field validation when I get a WM_KILLFOCUS message."
This is wrong for multiple reasons.
First, you may not get your focus loss message until it's too late.
Consider a dialog box with an edit control and an OK button. The edit control validates its contents on receipt of the WM_KILLFOCUS message. Suppose the user fills in some invalid data.
Under favorable circumstances, the user clicks the OK button. Clicking the OK button causes focus to move away from the edit control, so the edit control's WM_KILLFOCUS runs and gets a chance to tell the user that the field is no good. Since button clicks do not fire until the mouse is released while still over the button, invalid data will pop up a message box, which steals focus, and now the mouse-button-release doesn't go to the button control. Result: Error message and IDOK action does not execute.
Now let's consider less favorable circumstances. Instead of clicking on the OK button, the user just presses Enter or types the keyboard accelerator for whatever button dismisses the dialog. The accelerator is converted by IsDialogMessage into a WM_COMMAND with the button control ID. Focus does not change.
So now the IDOK (or whatever) handler runs and calls EndDialog() or performs whatever action the button represents. If the dialog exits, then focus will leave the edit control as part of dialog box destruction, and only then will the validation occur, but it's too late now. The dialog is already exiting.
Alternatively, if the action in response to the button is not dialog termination but rather starting some other procedure, then it will do it based on the unvalidated data in the dialog box, which is likely not what you want. Only when that procedure moves focus (say, by displaying a progress dialog) will the edit control receive a WM_KILLFOCUS, at which time it is too late to do anything. The procedure (using the unvalidated data) is already under way.
There is also a usability problem with validating on focus loss. Suppose the user starts typing data into the edit control, and then the user gets distracted. Maybe they need to open a piece of email that has the information they need. Maybe they got a phone call and need to look up something in their Contacts database. Maybe they went to the bathroom and the screen saver just kicked in. The user does not want a "Sorry, that partial information you entered is invalid" error dialog, because they aren't yet finished entering the data.
I've told you all the places you shouldn't do validation but haven't said where you should.
Do the validation when the users indicate that they are done with data entry and want to go on to the next step. For a simple dialog, this would mean performing validation when the OK or other action verb button is clicked. For a wizard, it would be when the Next button is clicked. For a tabbed dialog, it would be when the user tabs to a new page.
(Warnings that do not change focus are permitted, like the balloon tip that apperas if you accidentally turn on Caps Lock while typing your password.)
The New York Times reported on two enormous construction projects of dubious merit:
[The first bridge] would connect [Ketchikan, population 7845] to an island that has about 50 residents and the area's airport, which offers six flights a day (a few more in summer). It could cost about $200 million. The other bridge would span an inlet for nearly two miles to tie Anchorage to a port that has a single regular tenant and almost no homes or businesses. It would cost up to $2 billion.
[The first bridge] would connect [Ketchikan, population 7845] to an island that has about 50 residents and the area's airport, which offers six flights a day (a few more in summer). It could cost about $200 million.
The other bridge would span an inlet for nearly two miles to tie Anchorage to a port that has a single regular tenant and almost no homes or businesses. It would cost up to $2 billion.
The first bridge replaces a five minute ferry ride with a drive that most likely will take even longer.
And the representative from Alaska behind these pointless construction projects is hardly ashamed of this. Quite the contrary: He's proud of his achievement.
"I stuffed it like a turkey."
United States politics is not about trying to make the world a better place. It's about doing whatever it takes to get re-elected.
If you really care just about "0" through "9", then you can test for them explicitly. For example, as a regular expression, use [0-9] instead of \d. Alternatively, for a regular expression, you can enable ECMA mode via RegexOptions.ECMAScript. Note that this controls much more than just the interpretation of the \d character class, so make sure to read carefully to ensure that you really want all the ECMA behavior.
It has been pointed out to me that there is a way to convert all those "strange" digits to the "0" through "9" range, namely by calling the FoldString function with the MAP_FOLDDIGITS flag.
(I put the word "strange" in quotation marks because of course they aren't strange at all. Just different.)
This converts digits but doesn't help with decimal points, so you still have to deal with correctly interpreting "1,500" as either "one thousand five hundred" (as it would be in the United States) or "one and a half" (as it would be in most of Europe). For that, you need to call GetLocaleInfo to get the LOCAL_SDECIMAL and LOCAL_STHOUSAND strings.
It seems that giving away ice cream has been illegal in Tennessee since 1957, when state legislators were trying to combat alleged unfair trade practices by the dairy industry.
Upon its being alerted to the existence of this law, the state Senate and House unanimously passed a bill to repeal the law, sending it to the governor for signature.
Aha, but it's not as simple as you think.
The bill as written would have eliminated an entire section of state law covering unfair trade practices and frozen desserts. The bill was withdrawn after some lawmakers got calls from dairy company officials who feared the bill was too broad.
The bill was withdrawn after some lawmakers got calls from dairy company officials who feared the bill was too broad.
It is unclear whether an amended bill will pass in time for Baskin-Robbins' free cone day, planned for April 28.
(Links courtesy of Fark. It's not news. It's Fark.)
A collection of limitations (both hardware and software) currently prevent Windows from booting and running off a USB drive. Some of them are described in this whitepaper from WinHEC 2003. Another reason not mentioned in this paper is that during any hot-plug operation, the USB bus is completely reinitialized. Windows really doesn't like it when it loses access to its boot device. Imagine, you plug in a USB camera, the USB bus reinitializes, Windows loses access to the boot drive, and *oops* the kernel needs to page in some data and it can't.
Rats.
But who knows, someday maybe it will work.
Spain's Crown Prince and his fiancée are outraged that they had to go through airport security in Miami.
"The prince and his bodyguard felt they should not be subjected to the screening, but if they do not have an escort from the State Department or the Secret Service, it is required," she added. "It is the law."
Apparently, the Prince did not give the standard 72 hours' notice to obtain pre-clearance. (Hm, I wonder if I can get pre-clearance by submitting my itinerary 72 hours in advance.)
What bugs me even more is that the officials in Miami are all apologetic!
Miami-Dade County Mayor Alex Penelas sent the royal family a letter of apology on the same day, calling the situation "lamentable".
Reminds me of an article in the New York Times Magazine a few years ago titled Life is a Contact Sport [fee required], describing a mandatory meeting for all NFL rookies to introduce them to the "real world". My favorite part was this:
Kendrell Bell, a Pittsburgh Steelers linebacker, tells of his great awakening to the verities of income tax: "I got a million-dollar signing bonus. But then I got the check, and it was only $624,000. I thought, Oh, well, I'll get the other half later. Then I found out that's all there was. I thought, They can't do this to me. Then I got on the Internet and I found out they can."
Shocking! Football players have to pay income tax! Where will the injustice end?
Happy Tax Day (US).
I'm sure everybody has seen the autogenerated short names for long file names. For the long name "Long name for file.txt", you might get "LONGNA~1.TXT" or possibly "LO18C9~1.TXT" if there are a lot of collisions.
What you may not know is that sometimes there is no tilde at all!
Each filesystem decides how it wants to implement short filenames. Windows 95 uses the "~n" method exclusively. Windows NT adds the hexadecimal hash overflow technique. But some filesystems (like Novell) just truncate the name. "Long name for file.txt" on a Novell server will come out to just "LONGNAME.TXT".
So don't assume that all short names contain tildes. They don't. This means no cheating on skipping a call to GetLongFileName if you don't see any tildes, since your optimization is invalid on Novell networks.