Code that accompanies the article: