Archive for July 29th, 2004

KeySpan Remote: very useful with iTunes

Thursday, July 29th, 2004

I picked up a Keyspan Digital Media Remote today. As long as you install the beta driver (scroll down), it works flawlessly (the volume control doesn’t work in the production drivers on recent versions of OS X).

With this, I can now remotely control the iMac that acts as both the main music library and occasional DVD player. Out of the box, it is quite useful; track forward/back, volume, mute, play, pause, stop and a handful of other keys I can’t remember.

The “key editor” will let me assign AppleScript scripts to the buttons, as well. So, I’m going to make the directional buttons set the rating on the song and the select button effectively do a Do not ever play the currently playing song again. Not ever. It sucks. Make it go away! Play the Next Song!!!

Cool gadget for less than $40.

Posted in Mac OS X | No Comments »

Cool PyObjC Trick

Thursday, July 29th, 2004

With PyObjC, you can edit classes at runtime on an ad hoc basis. In particular, you can change what methods a class responds to, both adding and replacing methods in a class with new implementations at will. You can also cache the original implementation and easily invoke it from your replacement implementations.

% python
>>> from Foundation import *
>>> from objc import classAddMethods, classAddMethod
>>> oldDescription = NSObject.instanceMethodForSelector_("description")
>>> def newDescription_(self):
...   print "New %s description" % oldDescription(self)
...
>>> x = NSObject.alloc().init()
>>> x.description()

>>> classAddMethod(NSObject, "description", newDescription_)
>>> x.description()
New <NSObject: 0x379a70> description
>>>

The same can be done in pure ObjC (mostly C, really), but it is a lot harder.

Posted in PyObjC | No Comments »