Created
March 3, 2014 09:03
-
-
Save Plou/9321114 to your computer and use it in GitHub Desktop.
Display an identicons from the last commit hash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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