Skip to content

Instantly share code, notes, and snippets.

@derek
Created November 16, 2010 04:26
Show Gist options
  • Save derek/701418 to your computer and use it in GitHub Desktop.
Save derek/701418 to your computer and use it in GitHub Desktop.
Node.js/YQL winner generator
/*
The winner generator for SoCal.js November meetup
Be sure to `npm install yql` first!
Written by Derek Gathright (@derek)
*/
var sys = require("sys"),
YQL = require('yql');
// Example #1
new YQL.exec("select from_user from twitter.search where q='@ydn and @coloft'", function(response) {
if (response.error) {
sys.puts("Example #1... Error: " + response.error.description);
}
else {
var max = response.query.results.results.length,
random = Math.floor(Math.random()*max),
winner = response.query.results.results[random].from_user;
winner = winner.substring(0, 8);
while(winner.length < 9) {
winner = winner += " ";
}
var unicorn = "\n\n" +
" \\\\ \n" +
" \\\\ \n" +
" \\\\\\\\ \n" +
" \\\\\\\\ \n" +
" __________ >\\\\/7 \n" +
"/ \\ _.-(6' \\\\ \n" +
"| " + winner + "|-(=___._/` \\\\ \n" +
"\\__________/ ) \\\\ | \n" +
" / / | \n" +
" / > / \n" +
" j < _\\\\ \n" +
" _.-' : ``. \n" +
" \\\\ r=._\\\\ `. \n" +
" <`\\\\\\\\_ \\\\ .`-. \n" +
" \\\\ r-7 `-. ._ ' . `\\ \n" +
" \\\\`, `-.`7 7) ) \n" +
" \\\\/ \\| \\' / `-._\n" +
" || .'\n" +
" \\\\ (\n" +
" >\\ >\n" +
" ,.-' >.'\n" +
" <.'_.''\n" +
" <'\n" +
"";
sys.puts(unicorn);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment