All code in any of my original answers is dual licensed under CC-BY-SA and the MIT license unless otherwise noted. Feel free to use whichever suits your project better.