Some python code that I have found useful