Mezzo Cammin

Tho’ much is taken, much abides; and tho’
We are not now that strength which in old days
Moved earth and heaven; that which we are, we are;
One equal temper of heroic hearts,
Made weak by time and fate, but strong in will
To strive, to seek, to find, and not to yield.

(Yes, this is from Ulysses; Mezzo Cammin is something else entirely.)

Posted in Jack Handy | Comments Off

P.G. vs. AAPL

Paul Graham discusses Apple’s iPhone App Store approval process in his latest essay. I think it’s fair to summarize the core of his piece as:

  • The App Store approval process is opaque and frustrating
  • Its bad design is driven by AAPL’s perception that they own the channel between developers and users – AAPL is essentially trying to act as a “software publisher”
  • 80’s companies like VisiCorp showed that software publishing makes no sense
  • AAPL’s review process is also incompatible with launch-fast-and-iterate development, which is the way of the future
  • By annoying its developers, AAPL is (to some extent) undermining its future

I think this essay overlooks some important things.

Continue reading

Posted in iPhone, Jack Handy | Comments Off

0x5f375a86

Okay, so, yeah: XKCD. The mouseover text for that one reads:

Some engineer out there has solved P=NP and it’s locked up in an electric eggbeater calibration routine. For every 0x5f375a86 we learn about, there are thousands we never see.

This is a reference to a neat floating point hack, to which I provide some references below.

Continue reading

Posted in Jack Handy | Comments Off

Probability

Something a little lighter today: a probability puzzle. Consider this snippet of code:

def roll(a,b):
	# Assume that a and b are both integers greater than 0
	return random.randint(0,a-1) > random.randint(0,b-1)

What is the probability that roll() returns True for any given a and b? The answer to this turns out to be a piecewise function, which we derive below.

Continue reading

Posted in Python | Comments Off

Pre-Existing

In the current U.S. health-care debate, you hear the phrase “pre-existing conditions” a lot – usually in the context of someone claiming that health insurers shouldn’t be “allowed” to consider pre-existing conditions when deciding whether or not to offer (or under what terms to offer) to sell a health insurance policy to a potential customer.

It seems to me that this is analogous to saying that a fire insurance company shouldn’t be “allowed” to consider the black smoke pouring out of the warehouse you’re asking them to ensure. Whatever the merits of other proposals, this one is just silly; if you know that someone is going to make higher-than-average claims, of course you’re going to charge them higher-than-average premiums. (This is why, if you have a DUI, your auto insurance rates go up.)

Posted in Jack Handy | Comments Off

@synthesize

When declaring properties that will be created with the @synthesize directive, it’s natural to use the same name for both the property and the backing member. Something like this:

@interface MyClass : NSObject
{
    NSString* value;
}

@property(nonatomic, retain) NSString* value;

@end
 
@implementation MyClass

@synthesize value;

- (void)dealloc
{
	[value release];
	[super dealloc];
}

@end

Although natural, I feel that this is a mistake.

Continue reading

Posted in iPhone | Comments Off

Table Cell Indentation

Just a quick iPhone note: The “Table View Cell” group of the “Table View Cell Attributes” pane in Interface Builder contains a checkbox labelled “Indent While Editing”. It seems to me that this should control whether or not the cell being configured will, uhm, indent when the table in which it appears enters editing mode. Unfortunately, experimentally, this flag seems to do nothing at all. (More generally, the shouldIndentWhileEditing property of UITableViewCell doesn’t seem to do anything, either.)

The tableview:shouldIndentWhileEditingRowAtIndexPath: UITableViewDelegate method works ok, though.

Posted in iPhone | Comments Off

The Facts

There are a lot of facts. When arguing a point, some are going to be for you, and some against you. Many times, you’re not arguing over what is true, but over what is important.

Posted in Jack Handy | Comments Off

Cross-Fade Back Buttons

Maybe it’s just me, but there’s a quirk in the iPhone’s navigation controller infrastructure that just drives me batty: If you set the leftBarButtonItem of a view controller’s navigationItem while the navigation bar is displaying a “back” button, the back button will disappear without animation, producing a nasty “pop” effect. Today, I present a workaround.

Continue reading

Posted in iPhone | Comments Off

Core Graphics Problems

I saw a disturbing thing today. I was running a new app in the debugger, and I suddenly began to see messages like this in the console:

crasher(8502,0xa07a6500) malloc: *** error for object 0x2017000: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug

I eventually traced these down to my Shiny Red Button code, and through that to what I believe to be a Core Graphics bug. It seems that the underlying problem is not too serious, but I wanted to document what I’d found.

Continue reading

Posted in iPhone | Comments Off