Recent Snippets

Posting to Medium using Node.js and fetch()

You can use the Medium REST API to post new articles on Medium. They previously had a Node.js SDK to make using the API a bit simpler, but that SDK is no longer supported. Rather than relying on an unsupported SDK, you can call the REST API endpoints directly using the node-fetch package. The following... […]

Special formatting for SVG images with CSS

I frequently run into a problem displaying SVG images in my blog posts. SVG images tend to have no background color (so the post background bleeds through) and don’t have any space between the artwork and what would be the border. This left the SVG images looking a bit squished and washed out even though... […]

Flattening a JavaScript array with a generator

ECMAScript 2019 will introduce the Array.prototype.flat() method to aid in flattening out multidimensional arrays in JavaScript. However, flattening arrays has been easy in JavaScript every since ECMAScript 6 (2015) introduced generators. Because generators can yield values in any order, not just linearly, it’s possible to use a recursive generator to easily flatten an array. Here’s... […]