Created
July 19, 2011 03:28
-
-
Save michaelficarra/1091248 to your computer and use it in GitHub Desktop.
possible coffeescript implementation of a TameJS example from http://tamejs.org/
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
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 |
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
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