August 11, 2011

Unicode in Python 2: Decode in, encode out

Posted in Software at 00:24 by graham

In Python 2 you need to convert between encoded strings and unicode. It’s easy if you follow these three simple rules:

Decode all input strings

name = input_name.decode('utf8', 'ignore')

You need to decode all input text: filenames, file contents, console input, database contents, socket data, etc. If you are using Django, it already does this for you, as much as it can.

Read the rest of this entry »

August 3, 2011

git: Resolving 'git gc' error: cannot lock ref

Posted in Software at 17:37 by graham

If you get an error like this from git::

Auto packing the repository for optimum performance. You may also
run "git gc" manually. See "git help gc" for more information.
error: cannot lock ref 'HEAD (xyz's conflicted copy 2011-06-02)'
error: cannot lock ref 'refs/heads/master (xyz's conflicted copy 2011-06-02)'
error: failed to run reflog

You just need to delete the offending files from .git/logs/ and run your operation again.