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
reverse = (fn, args...) -> | |
fn.apply(this, args.slice(0).reverse()) | |
times = (step, times, fn, args...) -> | |
checks = 0 | |
interval = reverse setInterval, 1500, -> | |
if fn.apply(this, args) or checks++ >= times | |
clearInterval(interval) | |
detect_facebook_like = -> |
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
jQuery.fn.__defineGetter__ 'tap', -> | |
console.log "Element:", this | |
return this |
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
# Mixins | |
# ------------------------------- | |
# Adapted from The Little Coffee Book | |
# http://arcturo.github.com/library/coffeescript/03_classes.html | |
# and this gist: | |
# https://gist.github.com/993415 | |
moduleKeywords = ['extended', 'included', 'setup'] | |
class Module |
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
# A very ugly hack to access object literals | |
# with the fat arrow: | |
# | |
# _this = obj = {} | |
# | |
# $.extend obj, | |
# hello: => @stuff() | |
# | |
# compiles to: | |
# |
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
# A wrapper around the morpheus animation library, | |
# for a jQuery like syntax. Passing the duration | |
# and callback can work as separate arguments or as | |
# part of the options object. | |
# | |
# Easings can be specified by just writing their name. | |
# | |
# - o - the options bag, exactly like morpheus. | |
# Remember to add easings, as it defaults | |
# to easeOut. |
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
# Parses a URL string, using the DOM | |
# | |
# - href - full URL | |
# - host - sub.domain.tld:port | |
# - path - /stuff | |
# - protocol - https: | |
# - port - 80 | |
# - search - unparsed query string | |
# - query - parsed query string | |
# - fullpath - path + query string |
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
create_job = (klass, args) -> | |
job = JSON.stringify | |
class: klass | |
args : args | |
redis.multi() | |
.sadd('resque:mysite:tasks:queues', 'facebook') | |
.rpush('resque:mysite:tasks:queue:facebook', job) | |
.exec() | |
create_job "MySite::GetFacebookFriends", [fb_id] |
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
@get '/health', -> | |
pre @req, => | |
@req.assert('param', 'Invalid Param').notEmpty() | |
@next | |
, => | |
# Validation Passed | |
@response.json | |
pid: process.pid | |
memory: process.memoryUsage() | |
uptime: process.uptime() |
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
pre = (req, fn, next) -> | |
error_handler = fn() | |
errors = req.validationErrors() | |
if errors then error_handler(errors) | |
else 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
up: (o) -> | |
tasks = _cpt.topics.concat o | |
if @initialized # Everything is loaded and we are good to go | |
while tasks.length | |
task = tasks.shift() | |
if @is_function(task) then task() | |
else @[k](v) for k,v of task | |
else | |
# search for the initialization object (the one with the api key) |