Code from blog posts at www.leshylabs.com