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
class Lion extends Animal | |
eat: (food, cb)-> | |
cb() |
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
# How do I add the second params to a method args after the first one being a function? | |
timeout = setTimeout(function() { | |
sys.puts('Timeout') | |
tweetEmitter.removeListener(listener) | |
}, 10000) | |
timeout = setTimeout -> | |
sys.puts 'Timeout' | |
tweetEmitter.removeListener listener |
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 find = function(obj, id) { | |
if(id !== undefined) { | |
var results; | |
if(obj.id === id) { | |
results.push(obj); | |
} | |
return results; | |
} | |
return obj; | |
} |
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
find = (obj, id) -> | |
if id isnt undefined | |
thing for thing in obj when thing.id is id | |
else | |
obj |
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
# 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] | |
""" |
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
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 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
vinyls = [ | |
record: | |
name: "The best" | |
year: 2005 | |
, | |
record: | |
name: "OK, The Best For Real" | |
year: 2010 | |
] |
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
buttons = | |
dismissBtnClass: ".dismiss.btn" | |
selectBtnClass: ".select.btn" | |
normalBtnClass: ".normal.btn" | |
toggleBtnClass: ".toggle.btn" | |
buttons.bind = -> | |
bindDismissButtons() | |
bindSelectButtons() | |
bindNormalButtons() |
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
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 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
require deps, | |
([ | |
task | |
spine | |
{ | |
ItemController: itemC | |
CollectionController: collC | |
} | |
todoTemplate | |
]...) -> |
OlderNewer