In reply to this post:

Just figured it out, though to be perfectly honest I don't understand why the original code doesn't work. The latest version of the gist works, in case anybody out there runs into the same thing.