I wanted to make some edits to the code, so I have moved it to a Gist as that’s probably a better home.
You can find the Gist here: