Vincent Gable’s Blog

June 24, 2010

Retina Ready

Filed under: Announcement,Design,iPhone,Programming,Tips | , , , , , ,
― Vincent Gable on June 24, 2010

The iPhone 4’s ultra-sharp “Retina Display” really is a game changer. Until now, popular computer screens have been so low resolution, they could only display crude, low density, designs. It will take a few years for such high resolution screens to filter up into the personal computer space. But if you start writing an application that takes advantage of the iPhone 4’s display now, there will be millions of people who can use it by the time you’re done.

The best source I can recommend for understanding the kinds of designs that take full advantage of high PPI displays are Edward Tufte‘s classic design books:

If you just get one, make it The Visual Display of Quantitative Information.

PS: Tufte’s books are themselves examples of beautiful, complex, high density design, and as such really only make sense printed. At least for the next few years. Even if you can find an electronic version, I wouldn’t recommend reading it, because it won’t convey the power of a 1600 PPI display (printer).

May 19, 2010


Filed under: Cocoa,iPhone,MacOSX,Objective-C,Programming,Tips | , , ,
― Vincent Gable on May 19, 2010

How to remember Cocoa memory management:

Think NARC: “New Alloc Retain Copy”. If you are not doing any of those things, you don’t need to release.

–Andiih on Stack Overflow

Personally, I like to immediately autorelease anything I NARC-ed, on the same line. For example:

Foo* pityTheFoo = [[[Foo alloc] init] autorelease];

Admittedly, this makes for some ugly, bracey, lines. But I think it’s worth it, because you never having to worry about calling release if you also…

Use a @property (or Setter) Instead of retain

In other words I would write an init method that looked like:

- (id) init
	self = [super init];
	if (self) {
		_ivar = [[Foo alloc] init];
	return self;


- (id) init
	self = [super init];
	if (self) {
		self._ivar = [[[Foo alloc] init] autorelease];
	return self;

(Or [self setIvar:[[[Foo alloc] init] autorelease]]; if you are one of those folks who hate the dot-syntax.)

It’s debatable if using acessors in init and dealloc is a good idea. I even left a comment on that post arguing against it. But since then I’ve done a lot of reflection, and in my experience using a @property instead of an explicit release/= nil solves more problems then it causes. So I think it’s the best practice.

Even if you disagree with me on that point, if the only places you explicitly NARC objects are init, dealloc, and setX: methods then I think you’re doing the right thing.


The last piece of the memory-management puzzle are retain cycles. By far the best advice I’ve seen on them is Mike Ash’s article. Read it.

April 29, 2010

What Am I About To Call?

Filed under: Cocoa,iPhone,MacOSX,Objective-C,Programming,Reverse Engineering,Tips | , ,
― Vincent Gable on April 29, 2010

Say you’re in gdb, and about to execute a call instruction for dyld_stub_objc_msgSend, how do you know what’s about to happen?

On i386

(gdb) x/s *(SEL*)($esp+4)

tells you the message that’s about to be sent.

(gdb) po *(id*)$esp

tells you the target object that’s about to get the message.

November 17, 2009

Cut To The Chase

Filed under: Announcement,Tips | , ,
― Vincent Gable on November 17, 2009 makes it easy to link to a specific time in a YouTube video.

Do It Yourself Example

To link to 2 minutes & 14 seconds into this video of dancing in a Microsoft store,, add #t=2m14s to the end of the url:

Did you catch the shoplifting? (via @codinghorror)

November 14, 2009

You Can’t Please Everyone

Filed under: Design,Programming,Quotes,Tips,Usability | , , ,
― Vincent Gable on November 14, 2009

I did a project years ago called the “Dollar Dudes”, where we got on the subway with a bucket of dollar bills and announced that we were in the lucky “Dollar Train” and that everyone gets a dollar. Most everyone was delighted (at both the dollar and the ridiculousness of it all) but one guy refused to take the money and snapped at me. I was bummed out to get that reaction, but at the end of the day I didn’t feel that one guy getting irritated made the whole project a failure. The other 40 people had fun. I imagine the type of person who gets mad when offered a dollar by a stranger probably gets mad quite a bit throughout his day. I’m not trying or pretending to please every single person we encounter.

Charlie Todd (of Improv Everywhere fame)

Yes, handing out a bucket of money really does upset someone. You have no chance of pleasing everyone. Make tradeoffs accordingly.

October 19, 2009

sizeof() Style

Filed under: Bug Bite,C++,Objective-C,Programming,Tips | , ,
― Vincent Gable on October 19, 2009

Never say sizeof(sometype) when you can say sizeof(a_variable). The latter works even if the type of a_variable changes, and it is much more obvious what the size is supposed to represent.

October 12, 2009

Don’t Check malloc()

Filed under: C++,Cocoa,iPhone,MacOSX,Objective-C,Programming,Quotes,Tips | , , ,
― Vincent Gable on October 12, 2009

There’s no point in trying to recover from a malloc failure on OS X, because by the time you detect the failure and try to recover, your process is likely to already be doomed. There’s no need to do your own logging, because malloc itself does a good job of that. And finally there’s no real need to even explicitly abort, because any malloc failure is virtually guaranteed to result in an instantaneous crash with a good stack trace.

Mike Ash

This is excellent advice. Peppering your code with if statements harms readability and simplicity.

It’s still a good idea to check large (many MB) mallocs, but I can’t imagine recovering gracefully from a situation where 32 byte memory allocations are failing on a modern desktop.

September 21, 2009

Best Mosquito Bite Remedy

Filed under: Announcement,Tips | , ,
― Vincent Gable on September 21, 2009

The past few rainy days here in Austin have been a welcome respite from the drought, but it means mosquitoes. The best remedy I know for a mosquito bite is Thayer’s Superhazel,

Most importantly, it numbs mosquito bites quickly, and seems to help reduce swelling. It’s most effective for me when I use a little spray bottle to apply it; then blow on the bite or put it under a fan. Airflow + menthol = instant relief.

What do you think works best for treating mosquito bites?

August 28, 2009

Fair Coin Tosses

Filed under: Security,Tips | , , ,
― Vincent Gable on August 28, 2009

Flipping a coin is, ever so slightly, unfair. As this article (via) points out, there is a bias for a coin to land on the same side it started on.

Fortunately, all the biases coins have are systemic biases — they effect all similar coins the same way.

So, with a fair thrower, it’s possible to flip twice, and have the bias of the two throws cancel each other out.


  1. Put a coin heads-up, and flip it, as you normally would.
  2. Note the result, if certified this will be the decision.
  3. Flip the coin again, exactly as you did in step 1.
  4. If the coin lands on the opposite side as it did in step 2, the result from step 2 is certified. Otherwise, restart from step 1.

For maximum fairness and reproducibility, it’s best to let the coin land on the floor.

Why This Works

To simplify discussion, let’s call the sides of the coin unlikely (U) and likely (L) instead of heads & tails.

There are only 4 possible results to a pair of coin tosses: UU, UL, LU, LL. Obviously LL is most likely, and UU is least likely, so we rethrow if we get either (steps 3-4). That means the only “certified” results are UL or LU, and the odds of getting UL are the same as getting LU.

Dexterous Cheating

Unfortunately, this is not a self-enforcing protocol, so if the thrower is skillful enough, they can make the second throw go however they like, and keep re-throwing until they get the result they want.

Fortunately, most people aren’t able to manipulate a coin-toss. If you are worried that someone else is, then only let them flip once, and call the result in the air — that way they won’t know which side to pick.

If you can throw the result, and can’t find someone else to call the result — it serves you right for driving away all your friends by cheating at coin tosses, you tosser. But I’m still impressed.

August 16, 2009

Best First Straight Razor

Filed under: Announcement,Tips | , , ,
― Vincent Gable on August 16, 2009

As I’ve said before, I sometimes shave with a straight razor. Honestly, straight razors are worse than safety razors by just about any metric you pick1 — except the most important one: fun.

They turn a 40 second routine into a 40 minute ritual. It takes more work, to get a slightly coarser cut, but when I’m done I feel pampered yet accomplished. Kind of like if I went to an invigorating spa, but actually made something instead of relaxing.

If you are thinking about trying straight razor shaving, here’s my advice on what razor to try first.

The Good

The Hess EZY Shave Razor is the best all-around razor to see if straight-razor shaving is for you.

It’s easy to maintain, because it takes disposable blades. No sharpening or stropping required.

It has exactly the same size and ergonomics as a real straight razor.

Of course, the blade is different. But the long and stiff hair shaper blades it takes aren’t too far off.

It’s affordable, and not just the sticker price. Because, it takes easy-to-find “injector” blades as well as hair shaper blades, it’s affordable to keep using. (Tip: to find cheap injector blades, look for “mini shaper blades“, they are the same thing, but without the “key” for loading into an injector razor).

I’ve been throughly satisfied with my EZY Shave, and I still use it today. It’s handy for trimming places like the upper lip, that are difficult to reach with a safety razor.

The Bad

Actually, this is the cheap.

FROMM Hair Shapers can be had for $3 to $7. Check your local beauty supply store first, so you don’t pay more in shipping than the razor itself costs!

LIke the EZY Shave, it uses disposable hair shaper blades, so it’s easy to maintain.

This little fellow isn’t made for shaving, and it feels cheap, but when you take the guard off, it works … well enough. I’ve gotten descent shaves from one. The ergonomics aren’t exactly like a real straight razor, but they are close enough to give you a feel for what using one is like.

The bottom line is that it’s such a small investment that there’s very little risk in trying the FROMM. If all else fails, it’s still a perfectly good hair shaper. I still use mine to trim my sideburns.

The Ugly

Another good option is to ask around on forums like Straight Razor Place, and see if an old-timer will sell you a no-frills shave-ready razor on the cheap ($10-$30).

The disadvantage of starting with the real thing, is that it adds more variables, and you’ll need to get a strop to prepare the razor for each shave. (Sorry, I don’t know any good deals on strops, try a local knife shop.)

In other words, you’ll have to learn how to shave and maintain a straight razor. Bad stropping technique will dull a blade, or make it uncomfortable to use. That means more to go wrong. It also means one more thing to rule out as the cause of a bad shave, making it harder to evaluate the experience.

This is how I learned to use a straight razor. In retrospect, I don’t think it was the wisest way to go. But for many people, you haven’t tried something, unless you’ve really tried it.

1Some folks really believe a straight razor gives the closest (and yes, most nick free) shaves of their lives. I’m not one of them. I don’t think most people who’ve tried a straight razor are. That’s not to say true believers are wrong — preparing and using a bare blade give you ultimate control of every aspect of the shave. But machines still make sharper blades, while people inevitably make mistakes. And in my experience, some nooks and curves (eg. bottom of chin) can be reached better with a safety razor.

Older Posts »

Powered by WordPress