public
Created

gravatar link generator

  • Download Gist
gistfile1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
#!/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);
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.