Created
February 9, 2012 15:11
-
-
Save JakubOboza/1780601 to your computer and use it in GitHub Desktop.
gravatar link generator
This file contains 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
#!/usr/bin/env node | |
var email = process.argv[2]; | |
var crypto = require('crypto'); | |
function trim (str) { | |
var str = str.replace(/^\s\s*/, ''), | |
ws = /\s/, | |
i = str.length; | |
while (ws.test(str.charAt(--i))); | |
return str.slice(0, i + 1); | |
} | |
if(process.argv.length !== 3){ | |
console.log("usage: gravatar <email>"); | |
}else{ | |
var md5sum = crypto.createHash('md5'); | |
md5sum.update(trim(email).toLowerCase()); | |
var hash = md5sum.digest('hex'); | |
console.log("http://www.gravatar.com/avatar/" + hash); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment