public
Created

Node.js/YQL winner generator

  • Download Gist
gistfile1.txt
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
/*
 
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);
}
 
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.