Downloading all your gist from github using Node.js

Gists are a awesome tool for me. I use it a lot now a days. So is kind of a micro-blogging thing. For m is a great tool to find small commands for Linux, Gradle, AWS, Git, stuff i need do day by day as a engineer. Sometimes i have gist with just 1 line of code or just a command. I do that because is easy to recover this information because github search works very well and for me this is cheaper and faster than evernote.

So lets say, like me you have lots of gists, you might want use gist as a blog as well or maybe you just want share some code with friends which is pretty cool as well :-) Would be handy if you could download them? You actually can, there is an JSON REST API for gist that allow you do a bunch of things.  I`m using Node.JS do download each gist and save it into a directory.  Node is very productive for this kinda of tasks thanks to the libraries like request, path and fs you can do this task with a couple of lines. You will need to have Node.Js and NPM installed and also install: request, path and fs.

Show me the code

The URL is pointing to my gist account, you will need to change for yours. The code is pretty straightforward. I`m overriding the Default String class in order to add a replaceAll method to make sure we can save the file properly.

You will need to change the savepath for your computers path but besides it should be all set. In order to run you just do $ node download_all_gists.js

Cheers,
Diego Pacheco




Popular posts from this blog

Telemetry and Microservices part2

Installing and Running ntop 2 on Amazon Linux OS

Fun with Apache Kafka