Happy New Year

I just wanted to wish you a happy new year. Thank you for taking the time to stop by and read what I write. This site is tiny by the standards of the Internet, but that just means each reader is that much more special. Best wishes for a prosperous 2010.

If all goes well, I should be launching a new iPhone app in January. If you’re interested in joining a (free) Beta for an app that will Change Your Life, please send me your e-mail address.

Posted in Jack Handy | Comments Off

Welterweights

Since the Floyd Mayweather/Manny Pacquiao fight seems to have run up on the rocks at the moment, let me seize this opportunity to issue a modest proposal: Paul Williams (who says he can still make 147) vs. the winner of Mosley/Berto for the generally recognized position of #1 welterweight.

Mayweather and Pacquiao are good fighters, but, I would argue, not really welterweights; they’ve only fought one consensus top welter between them, and that at a catch weight. They’re just roaming around 147 in order to make as much money as possible and, hey, good luck with that. But when it comes to determining the best guy in that weight class, I’d like to see it fought out between guys who’ve put the rounds in to establish a meaningful record in that division.

Posted in Boxing | Comments Off

Deep Copying (Built-In)

I’d previously presented some code that made deep copies of plists. I recently discovered that this code is superfluous, due to the CFPropertyListCreateDeepCopy method. You can invoke this function with a call such as this:

testData = CFPropertyListCreateDeepCopy(kCFAllocatorDefault, [NSDictionary dictionaryWithContentsOfFile:path], kCFPropertyListMutableContainersAndLeaves);

(This assumes that path has previously been set to something meaningful, and that testData will later be used for some good purpose.)

Better late than never, I suppose.

Posted in iPhone | Comments Off

Merry Christmas

s = 's = %s; print s %% repr(s)'; print s % repr(s)

(Put it in a file, e.g. ps.py, then run python ps.py | python | python | python | python | python | python | python | python | python | python | python | python | python | python | python | python | python | python | python | python | python | python and see what happens.)

Posted in Python | Comments Off

C99 Arrays

Today, I learned that a cool “new” C feature had snuck up on me. This was added in C99, and it has apparently been integrated into Objective-C (where I stumbled across it) as well. Briefly, this sort of thing is now legal:

void quux(int x)
{
    char someArray[x];    // Illegal in K&R or ANSI C, ok in C99

    ...other, less interesting code...
}

(Previously, “x” would have had to be a constant that could be determined at compile-time.)

I guess I should pay more attention to this sort of thing.

Posted in iPhone | Comments Off

Cat Racing

Seth Godin today:

Someone asked me where I get all my good ideas, explaining that it takes him a month or two to come up with one and I seem to have more than that. I asked him how many bad ideas he has every month. He paused and said, “none.”

And there, you see, is the problem.

So, just throwing it out there, here’s one of my bad ideas.

Continue reading

Posted in Jack Handy | Comments Off

Churchillian

Never give in–never, never, never, never, in nothing great or small, large or petty, never give in except to convictions of honour and good sense. Never yield to force; never yield to the apparently overwhelming might of the enemy.

— Sir Winston Churchill

Posted in Jack Handy | Comments Off

Taking Pictures

Today it’s just a quick note on using the iPhone’s camera to take pictures from within your app. They’ve made this really easy. Begin by reading the section in the iPhone Application Programming Guide that covers the UIImagePickerController class.

That documentation provides the following code snippet, which works pretty well (with two caveats):

-(BOOL)startCameraPickerFromViewController:(UIViewController*)controller usingDelegate:(id<UIImagePickerControllerDelegate>)delegateObject
{
    if ( (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
            || (delegateObject == nil) || (controller == nil))
        return NO;
 
    UIImagePickerController* picker = [[UIImagePickerController alloc] init];
    picker.sourceType = UIImagePickerControllerSourceTypeCamera;
    picker.delegate = delegateObject;
    picker.allowsImageEditing = YES;
 
    // Picker is displayed asynchronously.
    [controller presentModalViewController:picker animated:YES];
    return YES;
}

Two things to note:

  1. This code allocs a UIImagePickerController, but never releases it. The release is assumed to happen in the same delegate code that dismisses the modal view. This seems an odd arrangement to me, and I think you could (auto)release the controller in this code just as well.
  2. The delegate of a UIImagePickerController must actually adopt the UINavigationControllerDelegate protocol as well as the UIImagePickerControllerDelegate protocol. I don’t know much about the UINavigationControllerDelegate protocol, but its methods seem to be optional; at any rate, sticking it into the list of protocols adopted by the delegate, with no other changes to the code, seemed to work ok.
Posted in iPhone | Comments Off

Vetting

Scott Adams has a post up with an interesting bit at the end:

We’re only a few years away from a point where no mating will ever occur because no one will pass the background check. If you knew everything about another person’s history, there would always be at least one show stopper.

This strikes me as a point that could be generalized: Once it becomes sufficiently easy to investigate someone’s background, will anyone look like a good candidate for employment/public office/promotion?

I imagine norms will change over time, but there might be a window 20-40 years in the future in which the incredibly bland will prosper as never before.

Posted in Jack Handy | Comments Off

Core Graphics Problems (Update)

A while back I wrote about some Core Graphics code that gave rise to memory management errors when (a.) compiled for iPhone OS 3.0 and (b.) run on the iPhone Simulator; the core of the problematic code looked like this:

UIGraphicsBeginImageContext(CGSizeMake(300,44));
UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

This code did not throw any errors on my device, but since I had already upgraded that device to the 3.1.2 OS, I wasn’t sure whether or not it would happen on a device running the 3.0 OS. Fortunately, Jeffrey Scofield was nice enough to test the code on his iPhone 2G, running OS 3.0.1, and report that no problems appeared.

So it looks like this is a Simulator-only problem, which means it can be largely ignored.

Posted in iPhone | Comments Off