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
var request = require('request'), | |
async = require('async'); | |
async.series([ | |
function(c) { | |
request('someuri', function(err, response, body) { | |
console.log('Request Callback Executed'); | |
c(); | |
}); | |
}, |
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
designDoc = | |
_id: "_design/blog" | |
language: "javascript" | |
views: | |
posts_by_date: | |
map: '' + (doc) -> | |
emit doc.postedAt, doc if doc.type is "post".toString() |
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
var q1 = client.query("QUERY1"); | |
var counter = 1; | |
q1.on('row', function(r1) { | |
var q2 = client.query("QUERY2 WHERE `id`='"+r1.id+"'"); | |
counter++; | |
q2.on('row', function(r2)) { | |
HTTPres.write(r2.value); | |
} | |
q2.on('end', funciton() { |
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
exports.auth = function(update) { | |
return function(req, res, next) { | |
isLogged(req, function(logged, key){ | |
if (logged != update) return next() | |
if (!logged) return next(errors.fire(403)) | |
redis.setex(key, 1000, req.session.id, function() { | |
next() | |
}) | |
}) | |
} |
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
require deps, | |
([ | |
task | |
spine | |
{ | |
ItemController: itemC | |
CollectionController: collC | |
} | |
todoTemplate | |
]...) -> |
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
do ($ = jQuery) -> | |
methods = | |
split_at_colon: (points) -> | |
points.split(":") | |
split_at_comma: (points) -> | |
if typeof points == "object" | |
for mini_array in points | |
for num in mini_array.split(",") | |
parseInt(num) | |
else |
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
buttons = | |
dismissBtnClass: ".dismiss.btn" | |
selectBtnClass: ".select.btn" | |
normalBtnClass: ".normal.btn" | |
toggleBtnClass: ".toggle.btn" | |
buttons.bind = -> | |
bindDismissButtons() | |
bindSelectButtons() | |
bindNormalButtons() |
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
vinyls = [ | |
record: | |
name: "The best" | |
year: 2005 | |
, | |
record: | |
name: "OK, The Best For Real" | |
year: 2010 | |
] |
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
protect = (req, res, next) -> | |
console.log "I don't even get here" | |
req.user = if req.isAuthenticated() then "YES" else "NO" | |
if req.isAuthenticated() | |
next() | |
else | |
req.authenticate ["twitter"], (error, authenticated) -> | |
if error | |
next new Error "Problem authenticating" | |
else |
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
# See http://en.wikipedia.org/wiki/Fisher%E2%80%93Yates_shuffle#The_modern_algorithm | |
# written as one-liners because my REPL didn't like multiline functions this morning | |
# tested on CoffeeScript v1.0.1 | |
input = [0 .. 7] | |
swap = (input, x, y) -> [input[x], input[y]] = [input[y], input[x]] | |
rand = (x) -> Math.floor Math.random() * x | |
durst = (input) -> swap(input, i, rand i) for i in [input.length - 1 .. 1] | |
""" |
NewerOlder