Code examples from Tom Stuart's book of the same name.