Code from blog posts on pierceboggan.com.