Credit: Alexander "Jarvis" Buck and Sean Lavelle.
Source code on GitHub.