A Tribute to XKCD on NodeJS
I LOVE the high-brow comic xkcd written by Randall Munroe. Additionally, I like to print out these comics, which I think has a tinge of irony to it. None-the-less, the xkcd page is a disaster to print and the images on their own lack the title and alternative text, which add context that is sorely missed in some cases. For example, the brilliance of 1639: To Taste below, where the real burn is in the alternative text, but maybe that’s the point. Whatever, I still like printing them.
Caption: Look, recipe, if I knew how much was gonna taste good, I wouldn’t need you.
I present xkcd-print, a little NodeJS app I built for exactly this purpose. You can find the source code on Github.
How I built it
Man, I love the ecosystem of NodeJS; everything is so simple when you have access to NPM. I probably didn’t need to use ExpressJS, but it just makes everything so simple and I wanted the built in express.static
function to serve my static files. I’m using cheerio to parse the returned HTML from xkcd. Cheerio is a fantastic jQuery inspired nodejs package that makes page scraping easy (probably too much so). Then I’m just rendering it using template strings, which are seriously amazing in their capabilities. If anything is going to overtake React in it’s popularity, it’s going to be ES6 template strings. Find out more about their potential from Dr. Axel Rauschmayer.
I haven’t even started about how easy the people at Heroku have made deploying a NodeJS application. It is so painless it should almost just be a part of your workflow for testing.