Archive for the ‘geekery’ Category

silly hat trek: the next generation

Saturday, November 22nd, 2008

I can’t explain it, but some specimens of the Star Trek TNG photoshop meme are unbearably hilarious to me. Especially when they involve silly hats.

If you haven’t seen it, the new trailer for J. J. Abrams’ Trek has been out for about a week. Looks action-packed for sure, and I’m glad the franchise is getting a facelift and some fresh blood. But I can’t shake the sense that they’ve given the bridge of the Enterprise to a boy band. Kirk and Spock look like they’re in high school. Maybe I’m just getting old.

My reading of the Wikipedia entry (and with Karl Urban’s McCoy completely missing from this poster) suggests that the traditional tripod of character dynamic among Kirk, Spock, and Bones will be reduced to two: Kirk’s and Spock’s fragmented personalities. (This along with with the boyish casting will undoubtedly get the K/S culture all atwitter … er … FYI, that link is safe for work, but potentially unsafe for your world view.) So that’s something of a departure from the standard Trek framework …

Also I have wondered if Abrams’ Trek won’t be so bleak as to violate the spirit of hope that was so important to creator Roddenberry. Based on Cloverfield and Lost, Abrams’ work—to me—reads dark and fatalist. But, according to Wikipedia, “[Abrams] does like Star Trek’s optimism though, being an optimist himself, and [he] felt the film would be a refreshing antidote to films like The Dark Knight.” So that’s good, I guess.

Anyway. Here’s my contribution to the meme. Not so funny, but oh well.

line numbers in php exceptions

Monday, October 20th, 2008

Quick geeky public service announcement. PHP 5’s Exception objects have line number and file name fields which are automatically populated for you. Refer to this page for details.

Ok, cool, but the question is: do those fields correspond to the construction site or the throw site? Based on this little experiment:

try {
	$exception = new Exception('exception constructed on '.__LINE__);
	throw $exception;
}
catch (Exception $e) {
	echo $e->getMessage().', (internal line:'.$e->getLine().')';
}

… they appear to refer to the construction site. In this case, the line number in the message (which is produced by the __LINE__ magic constant at the point of construction) and the return value of getLine() (made however it is the exception facility determines the line number) is the same number.

At first blush, this behavior seems less useful to me than if line numbers and file names were attached to the throw site. That’s where the exception actually occurs. It may be constructed entirely elsewhere. Hmmm.

Anyway, I couldn’t find an answer out there right away, at least with the terms I used to ask The Great Oracle. So here ’tis.

those dictation exercises in music theory would’ve been cake

Friday, April 18th, 2008

Meanwhile, in other music-and-math news, this is pretty impressive: software that will extract individual notes from multitimbral performances. Hrmmm. I’m skeptical about how reliably it will work in practice, but I will believe it when I see it.

Also, who pronounces MIDI like “meaty?”

“Now, we can control the chords with our MEATY keyboard … nom nom nom …”

selectable NSToolbarItems and itemIdentifiers in Leopard

Saturday, February 23rd, 2008

Maybe it’s just me, but I couldn’t figure out how to specify an itemIdentifier for a toolbar item in Interface Builder 3.0 (OS X 10.5 Leopard). So I didn’t know what to return from the toolbar’s delegate method toolbarSelectableItemIdentifiers to flag items as selectable. Nor could I just flag an item as selectable directly in IB. The default identifiers given to the items are GUIDs and completely meaningless. I’m guessing these are just oversights in the newly-minted IB. (Prior to Leopard you couldn’t define toolbars in IB at all.)

I also didn’t google any obvious hits on this topic, so here’s my community contribution for today. Specify view tags on your toolbar items in IB instead of identifiers. Then implement toolbarSelectableItemIdentifiers in your delegate to check for the tags you want.

- (NSArray*) toolbarSelectableItemIdentifiers: (NSToolbar *)toolbar
{
	// yarr. leopard be toyin' with me, yarr!
	static NSMutableArray* identifiers = nil;
	if (identifiers == nil) {
		NSArray* items = [toolbar items];
		identifiers = [[NSMutableArray alloc] init];
		for(NSToolbarItem* item in items) {
			if ([item tag] == 1 || [item tag] == 2) {
				[identifiers addObject:[item itemIdentifier]];
			}
		}
	}
	return identifiers;
}

I happened to have two toolbar items I wanted to be selectable, with tags 1 and 2. Modify to suit your needs …

The pirate-speak comment is of course critical to this method’s success.