Skip to content

Instantly share code, notes, and snippets.

@ecto
Created January 24, 2011 22:05
Show Gist options
  • Save ecto/794063 to your computer and use it in GitHub Desktop.
Save ecto/794063 to your computer and use it in GitHub Desktop.
The home page for our FaceMash clone
app.get('/', function(req, res){
db.keys('image:*:location', function(err,keys){
if (err) { throw err; }
var offense = keys[Math.floor(Math.random()*keys.length)];
var defense = keys[Math.floor(Math.random()*keys.length)];
if (defense == offense) {
defense = keys[Math.floor(Math.random()*keys.length)];
}
db.mget('image:' + offense + ':location', 'image:' + offense + ':rating',
'image:' + defense + ':location', 'image:' + defense + ':rating',
function(err, reply){
res.render('battle.ejs', {
locals: {
offense: offense,
defense: defense,
battle: reply
}
});
});
});
});
@cannikin-strike
Copy link

Has anyone run across a decent facemash clone with a large number of images? www.facemasher.com just has a static image, but they didn't finish it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment