This file contains hidden or 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
var q = require('q') | |
q.fcall(function(resolve, reject) { | |
resolve(undefined); | |
}).then(function() { | |
console.log("Yey"); | |
}, function() { | |
console.log("Boo"); | |
}); |
This file contains hidden or 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
var q = require('q') | |
q.fcall(function(resolve, reject) { | |
resolve(something); | |
}).then(function() { | |
console.log("Yey"); | |
}, function() { | |
console.log("Boo"); | |
}); |
This file contains hidden or 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
var request = require('request') | |
var cheerio = require('cheerio') | |
function collapse (text) { | |
return ( | |
text | |
.replace(/\\t/g, '') | |
.replace(/\\r/g, '') | |
.replace(/\\n/g, '') |
This file contains hidden or 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
function serveReddit (req, res) { | |
function recurse(i, res) { | |
if (i <= 0) | |
res.end('</ul></div>') | |
request({ | |
uri: 'http://www.reddit.com/r/random', | |
followRedirect: false | |
}, function (err, response, body) { | |
var location = response.headers.location |
This file contains hidden or 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
// arguments are `value`, `singular`, `plural` | |
// if `plural` is left out, it's just `singular` with an 's' appended | |
/* | |
pluralize(0, 'hour') // '0 hours' | |
pluralize(1, 'hour') // '1 hour' | |
pluralize(0, 'mouse', 'mice') // '0 mice' | |
pluralize(1, 'mouse', 'mice') // '1 mouse' | |
*/ | |
;(function () { |
This file contains hidden or 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
$(function () { | |
function tick (str) { | |
indexs[str] = (indexs[str] + 1) % arrays[str].length | |
return arrays[str][indexs[str]] | |
} | |
var arrays = {} | |
arrays.colors = [ | |
'yellow', |
This file contains hidden or 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
#!/usr/bin/env node | |
var concat = require('concat-stream') | |
var target = 0 | |
if (process.argv[2]) | |
target = parseInt(process.argv[2], 10) | |
process.stdin.pipe(concat(function (input) { | |
var lines = input.toString().split('\n') |
This file contains hidden or 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
#!/bin/bash | |
COUNT=$1 | |
cat /dev/urandom | head -c $COUNT |
This file contains hidden or 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
#!/bin/bash | |
COUNT=$1 | |
EXPLETIVE=$2 | |
yes $EXPLETIVE | tr -d '\n' | head -c $COUNT |