Raw Syntax

The stuff programs are made of

Comparing Plist Files on OSX


I recently had a problem with some of my keyboard shortcuts not working on OS X. I ended up moving the original plist (Property List) file, rebooting, and configuring the settings manually. This fixed the problem but left me wondering why the keyboard shortcut broke in the first place. Computers don't just break. There has to be a reason.

I tried to diff the two plist files and I got an unhelpful message similar to binary files differ. Having been on OS X a while, I know that plists can be saved as text or binary. In this case I simply used the open command to load the files into XCode, exported them as Property List XML, and then was able to diff them as normal text files.

Why Binary?

As an Emacs user, I was still confused as to why plists would ever be saved as binary. This just means I can't edit them with Emacs (out of the box anyway). Referring to the man page for plist it turns out the reason is performance:

The property list programming interface allows you to convert hierarchically structured combinations of these basic types to and from two formats: standard XML and an optimized, opaque binary format.

You can also use plutil to convert between binary and text. For example:

plutil -convert xml1 com.apple.symbolichotkeys.plist

Which converts the file to another format in place.

RSpec Suite Runs Twice?


I worked on a rails project recently that had a peculiar problem. When running the specs via rake spec or rspec the whole suite would appear to run twice. I began digging around in spec/spec_helper.rb to try to figure out how RSpec could be configured to run twice instead of once. I also went to google and stack overflow and didn't find much.

Eventually I saw that there was both a .rspec file with configuration options and a few of the same configuration options repeated in the spec_helper. Once I removed the duplication (in particular the format documentation option was specified in both places), the RSpec suite output only appeared once. I did a little more digging and found that the test suite was not running twice, but rather the output was getting printed twice.

The easiest way to avoid this kind of problem is to decide on a project level to keep RSpec options in spec/spec_helper.rb or .rspec, but not both.

On API Security


I was asked recently about designing a secure API. There are 2 basic steps:

  1. Encrypt the connection (HTTPS)
  2. Encrypt the paylod (HMAC-SHA1 for example)

You could think up ways to go further but these are the basics that need to be covered.

K750: A Solid Wireless Keyboard


I don't normally talk about computer equipment here, but I recently purchased the K750 wireless keyboard by Logitech. It's amazing because it is solar powered and therefore requires no batteries. Their manual says it can remain powered for 3 months in total darkness. I believe they tested this in my office. Also of note, I bought the mac version of the keyboard. However, it also works with my PC, though I had to fool with their software a bit for the function keys to work.

The K750 is also a good deal cheaper than the official Apple wireless keyboard.

Previously I had an older version of the Razer Deathstalker. It was nice, but there were wires everywhere. The K750 is nice and clean, and I haven't noticed any perceptible input lag / delay.