Let’s start with the premise of these two famous rich people out discount shoe shopping. Ha, ha! They don’t really have to shop at Payless like the half a million people who lost their jobs this year.
Gates and Seinfeld may both be schlumpy dressers, but their regular-guy qualities stop there. Neither is the Warren Buffett kind of rich, the frugal sort who knows the value of a dollar and doesn’t put himself above the working man (or so we believe about Buffett). Instead the ad seems to be somehow making light of bargain-shopping, as if it’s just a lark for these guys, or some kind of joke that we’re not quite in on.
September 5, 2008
Condescending Rich Guys
ASCII is Dangerous
Never use NSASCIIStringEncoding
“Foreign” characters, like the ï in “naïve”, will break your code, if you use NSASCIIStringEncoding
. Such characters are more common then you might expect, even if you do not have an internationalized application. “Smart quotes”, and most well-rendered punctuation marks, are not 7-bit ASCII. For example, that last sentence can’t be encoded into ASCII, because my blog uses smart-quotes. (Seriously, [thatSentence cStringUsingEncoding:NSASCIIStringEncoding]
will return nil
!)
Here are some simple alternatives:
C-String Paths
Use - (const char *)fileSystemRepresentation;
to get a C-string that you can pass to POSIX functions. The C-string will be freed when the NSString
it came from is freed.
An Alternate Encoding
NSUTF8StringEncoding
is the closest safe alternative to NSASCIIStringEncoding
. ASCII characters have the same representation in UTF-8 as in ASCII. UTF-8 strings will printf
correctly, but will look wrong (‘fancy’ characters will be garbage) if you use NSLog(%s)
.
Native Foundation (NSLog
) Encoding
Generally, Foundation uses UTF-16. It is my understanding that this is what NSStrings are by default under the hood. UTF-16 strings will look right if you print them with NSLog(%s)
, but will not print correctly using printf
. In my experience printf
truncates UTF-16 strings in an unpredictable way. Do not mix UTF-16 and printf
.
Convenience C-Ctrings
[someNSString UTF8String]
will give you a const char *
to a NULL
-terminated UTF8-string. ASCII characters have the same representation in UTF-8 as in ASCII.
Take a minute to search all your projects for NSASCIIStringEncoding
, and replace it with a more robust option.
It never hurts to brush up on unicode.
September 2, 2008
You Can Fool Some of the People
Preconceptions are a powerful thing.
In one recent test, psychologists asked 32 volunteers to sample strawberry yogurt. To make sure the testers made their judgments purely on the basis of taste, the researchers said, they needed to turn out the lights. Then they gave their subjects chocolate yogurt. Nineteen of the 32 praised the strawberry flavor. One said that strawberry was her favorite flavor and she planned to switch to this new brand.
Waiting for Safety “Kills”
Assume that all the new airport security measures increase the waiting time at airports by — and I’m making this up — 30 minutes per passenger. There were 760 million passenger boardings in the United States in 2007. This means that the extra waiting time at airports has cost us a collective 43,000 years of extra waiting time. Assume a 70-year life expectancy, and the increased waiting time has “killed” 620 people per year — 930 if you calculate the numbers based on 16 hours of awake time per day. So the question is: If we did away with increased airport security, would the result be more people dead from terrorism or fewer?
Relatedly, Tog claims that designing roads for speed first, and safety second, could save lives.