The Old New Thing

Don't try to allocate memory until there is only x% free

I have an ongoing conflict with my in-laws. Their concept of the correct amount of food to have in the refrigerator is "more than will comfortably fit." Whenever they come to visit (which is quite often), they make sure to bring enough food so that my refrigerator bursts at the seams, with vegetables and eggs and other foodstuffs crammed into ...

Microspeak: Walls and ladders

Reader laonianren wanted to know more about this game Walls and Ladders. "Walls and Ladders" is not a game. It's just a metaphor for a conflict in which one side wants to perform some action and the other side wants to prevent it. The defending side builds a wall, and the attacking side builds a taller ladder. In response, the defending ...

Cultural arbitrage: The food-related sucker bet

While I was at a group dinner at a Chinese restaurant, a whole fish was brought to our table. One of the other people at the table told a story of another time a whole fish was brought to the table. He attended the wedding rehearsal dinner of a family member. The bride is Chinese, but the groom is not. (Or maybe it was the other way around. ...

Why was there a font just for drawing symbols on buttons?

Henke37 wonders why the Marlett font was introduced. Why use a font for drawing symbols on window buttons? Using a font was a convenient way to have scalable graphics. It's not like Windows could've used VML or SVG since they hadn't been invented yet. EMFs would have been overkill as well. Fonts were very convenient because the technology ...

Keys duplicated from photo: Delayed reaction

There was a report some time ago that researchers have developed a way to duplicate keys given only a photograph. When I read this story, I was reminded of an incident that occurred to a colleague of mine. He accidentally locked his keys in his car and called a locksmith. Frustratingly, the keys were sitting right there on the driver's seat...

How do I print non-error messages during compilation?

Commenter Worf remarked, "My one wish is that would be supported." I always find it interesting when people say "I wish that Microsoft would stop following standards," since the directive is nonstandard. The Microsoft C/C++ compiler implements the feature in a method compatible with the standard, namely via a directive. If you ...

Puzzling out the upsell-o-meter

As I noted before, many grocery stores in the United States have a printer next to the cash register which prints out coupons customized to your purchases. Here's a purchase and the accompanying coupon. What is the story behind this pairing? Purchased: Diapers for newborn baby. Coupon: Save 75 cents on ice cream. Bonus chatter: While ...

What a steal: A house for only ten dollars!

When I was signing the papers for a house purchase many years ago, I noticed that the deed papers read The Grantor «names of people selling the house» for and in consideration of TEN DOLLARS AND OTHER GOOD AND VALUABLE CONSIDERATION in hand paid, conveys and warrants to «me» the following described real estate...

How can I detect the language a run of text is written in?

A customer asked, "I have a Unicode string. I want to know what language that string is in. Is there a function that can give me this information? I am most interested in knowing whether it is written in an East Asian language." The problem of determining the language in which a run of text is written is rather difficult. Many languages share...