Skip to content

Instantly share code, notes, and snippets.

@omnizach
Last active December 4, 2016 08:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save omnizach/9add0443a37e2613f5ea to your computer and use it in GitHub Desktop.
Save omnizach/9add0443a37e2613f5ea to your computer and use it in GitHub Desktop.
List Gists

List Gists

I clone all my gists, and keep the folder name as the unique key for the gist. So, to find a particular gist, I use this script to list all the folders with the title found in the README.md file.

Usage:

node gists.js

Example Output:

0f93ca731883d601a114 Gradient Along Stroke
9f86cfa7443eb079b4f3 Dragon Curve
209cf70cd9a377f5c224 Rainbow Circle
886d9843b0fb176da2a7 Bezier Screensaver
c44cd2a810d94734b053 Fireflies
cbddbec7a8ca22aca587 Animate Along Path III
c5c304c82d02b83f77ee Animate Along Path IV
e786dde6a6358008d1fb Animate Along Path II
d8220c3ca6d82fef083b Animate Along Path I
#!/usr/local/bin/node
// Having a clone of all my gists, and wanting to keep the folder names consistent,
// this script looks up the titles of all the gists.
var fs = require('fs'),
gs = fs.readdirSync('raw');
gs.forEach(function(g) {
var readme = 'raw/' + g + '/README.md';
if (!fs.existsSync(readme)) {
return;
}
fs.readFile(readme, 'utf-8', function(err, data) {
var lines = data.split('\n', 1),
title = lines[0].replace(/^[\#\s]*/, '');
console.log(g, title);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment