Skip to content

Instantly share code, notes, and snippets.

@Plou
Created March 3, 2014 09:03
Show Gist options
  • Select an option

  • Save Plou/9321114 to your computer and use it in GitHub Desktop.

Select an option

Save Plou/9321114 to your computer and use it in GitHub Desktop.
Display an identicons from the last commit hash
var colors = require('colors');
var exec = require('child_process').exec;
exec('git rev-parse HEAD', function(error, stdout, stderr){
hash = process.argv[2] ? process.argv[2] : stdout
hash = hash.toString();
hash = hash.split('');
var identicons = '',
on = " ".zebra.inverse,
off = " ".green.inverse,
sqrt = 7,
pointer = 1;
for (var i = 0; pointer < 50; i++) {
var subhash = parseInt(hash[i],16)
subhash = subhash.toString();
subhash = subhash.split('');
for (var j = 0; j < subhash.length; j++) {
carret = ''
if (pointer%sqrt === 0) {
carret = "\n"
}
if (pointer < 50) {
if (parseInt(subhash[j]) & 1) identicons += on+carret
else identicons += off+carret
pointer++
};
}
}
console.log(identicons);
done()
})
function done() {process.exit();}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment