Handy commit hook

I try really hard to set myself up for success in the sense that I believe in setting up my environment to discourage mistakes (poka-yoke). I’ve been known to leave Office files open while I’m working in git, and occasionally things can get confused. To wit, I present a pre-commit hook that will prevent a […]

Detecting character encodings

This is a quick and dirty script inspired by this post, but it can definitely be a useful tool: #!/usr/bin/env python from chardet import detect from sys import argv for fn in argv[1:]: with open(fn, “rb”) as f: print(fn, detect(f.read())[‘encoding’])