Monday, June 22, 2009

Get command-as-meta in Cocoa Emacs 23

I've been running the Cocoa Nightlies of emacs lately. It's been mostly nice, although I switched back to 22 for a while because meta became super by default, and I couldn't figure out how to change it. The solution is to either go into
M-x Customize -> Environment -> Ns

or put

;; Command is meta in OS X.
(setq ns-command-modifier (quote meta))

in your emacs startup files. You'll also need to install an updated emacsclient since the one for emacs 22 won't work with 23.

Saturday, April 11, 2009

ZFS on OS X and Hanging Updaters

I was finishing off my taxes today, and while trying to apply the updater for TaxCut the updater would just hang. It'd completely max out one core of my MBP, and not ever do anything. Finally, in a moment of desperation, I fired up Instruments and started sampling it, and it was getting stuck in a Carbon routine about getting filesystem info. Unmounting my ZFS partition and trying the updater again caused it to go through instantly, with no issues.

Instruments is Made. Of. Awesome.

Monday, February 02, 2009

shepherd: Re-run tests automatically on save

For the past few months I've been using a tool I wrote called Shepherd to help run my tests for me when I'm doing a fast edit/re-test cycle. Shepherd is an OS X only shell tool (although I'd like to see equivalents for other platforms) that uses FSEvents to watch a directory for edits and re-run the tests only when the right kind of file has been edited. This is nice for a couple of reasons: Your editor doesn't need to know tests are being run, and it'll automatically re-run the tests if the code changes for some other reason, like an hg revert.

There are some bugs (^C in the middle of a test run doesn't actually stop the in-progress test run, for example), but it's been a valuable tool for me, and I'm quite late in blogging about it so others can try it out. The code is hosted on BitBucket, so if you have improvements to make, please publish them there in a fork or queue so I can pick them up!

Monday, June 30, 2008

Nokia 6085 with iSync

Well, I have an iPhone, but A doesn't, so we just got her a Nokia 6085, which is a huge step up from the Samsung she had. To get it working with iSync, I took this plugin for the 6300 and replaced 6300 with 6085 in all the plists, and it just worked neat as you please.

Syncing over bluetooth is kinda cool. Maybe Apple could work out some minimal ability to sync (say) calendars, contacts, and iTunes play counts over bluetooth, leaving the "big" files for when you've got a wire?

Saturday, May 17, 2008

This just makes me sad. I was booking a hotel room at a major hotel chain, and I got to this form and just started laughing. Am I weird in that I was tempted to try and screw up their system by using those characters?

Also, what kind of place is it that makes a form this not-robust in 2008? That's just asking for trouble.

Wednesday, April 23, 2008

Using ConfigParser on StringIO

ConfigParser is one of those bits of Python that is sadly under-documented. Recently I had need of using ConfigParser on a non-file, which meant using StringIO. Sadly, I couldn't find any examples of how to do this. After a little experimenting, I found that this works:

dummy_config = """[pinky]
narf: True
troz: True
config = ConfigParser.ConfigParser()
s = StringIO.StringIO(dummy_config)
print config.sections()

So there you have it: the secret is the readfp() method, which is mentioned in the output of PyDoc, but Google barely knew about.

Monday, March 31, 2008

setuptools and Subversion 1.5

Heads up: if you do not patch setuptools, installs from svn working copies *will* error out when you upgrade to Subversion 1.5. This isn't a big deal, really. If you're not using the new features, you can easily downgrade your working copy (left as an exercise for the reader, since I don't want to empower that kind of bad behavior). That said, if you are like me, you want to just fix setuptools. I figured out the patch. It's actually trivial, since they are already parsing the entries file in a sane way, all that needed to happen was to bump the accepted version of the entries file in the setuptools sources and move on with my day. Unfortunately, they have been totally silent on the patch. As such, I'm posting it here so that Google at least has a chance of finding this and making the world able to fix this problem. Here's the patch:

Index: setuptools/command/
--- setuptools/command/ (revision 61076)
+++ setuptools/command/ (working copy)
@@ -217,9 +217,9 @@
data =

- if data.startswith('8'):
+ if data.startswith('8') or data.startswith('9'):
data = map(str.splitlines,data.split('\n\x0c\n'))
- del data[0][0] # get rid of the '8'
+ del data[0][0] # get rid of the '8' or '9'
dirurl = data[0][3]
localrev = max([int(d[9]) for d in data if len(d)>9 and d[9]]+[0])
elif data.startswith('<?xml'):
Index: setuptools/command/
--- setuptools/command/ (revision 61076)
+++ setuptools/command/ (working copy)
@@ -86,7 +86,7 @@
f = open(filename,'rU')
data =
- if data.startswith('8'): # subversion 1.4
+ if data.startswith('8') or data.startswith('9'): # subversion 1.4 or 1.5
for record in map(str.splitlines, data.split('\n\x0c\n')[1:]):
if not record or len(record)>=6 and record[5]=="delete":
continue # skip deleted

If this works for you (and you are sure you are using svn 1.5 client binaries ("head -n 1 .svn/entries" prints "9"), please head over to the distutils SIG list and mention that it works for you. Of course, if you're reading this and you can be more of an authority than I can (I read the the libsvn_wc docs (search "The entries file")), please comment over there if the patch is right, or give me feedback so I can submit a more resilient patch.