Skip to content

Instantly share code, notes, and snippets.

@michaelficarra
Created July 19, 2011 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaelficarra/1091248 to your computer and use it in GitHub Desktop.
Save michaelficarra/1091248 to your computer and use it in GitHub Desktop.
possible coffeescript implementation of a TameJS example from http://tamejs.org/
huntMen = (buffy) ->
soulmates = []
while soulmates.length < 10
# get 10 candidates for Buffy
(userids) <- getMatches buffy, 10, *
for u, i in userids
# get their pic from our pic server
(thumb) <- getThumbnail u, *
# ask our pic analyzer to review
(is_vamp) <- isPicAVampire thumb, *
unless is_vamp
defer
# get 2 more pieces of info
(personality) <- getPersonality u, *
(last_talked) <- getLastTalked u, match, *
soulmates.push {
userid: match
thumb
last_talked
personality
}
soulmates
huntMen = function(buffy) {
var soulmates = [];
while (soulmates.length < 10) {
// Get 10 candidates for Buffy
twait {
getMatches(buffy, 10, mkevent(var userids));
}
for (var i = 0; i < userids.length; i++) {
var u = userids[i];
twait {
// get their pic from our pic server
getThumbnail(u, mkevent(var thumb));
}
twait {
// ask our pic analyzer to review
isPicAVampire(thumb, mkevent(var is_vamp));
}
if (!is_vamp) {
twait {
// get 2 more pieces of info
getPersonality(u, mkevent(var personality));
getLastTalked(u, match, mkevent(var last_talked));
}
soulmates.push({
"userid" : match,
"thumb" : thumb,
"last_talked" : last_talked,
"personality" : personality
});
}
}
}
return soulmates;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment