Create a gist now

Instantly share code, notes, and snippets.

gravatar link generator
#!/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