Code to go with the blog post  at m2ag.wordpress.com