Skip to content

Instantly share code, notes, and snippets.

@brianmhunt
brianmhunt / gist:4413209
Last active December 10, 2015 09:18
An extension called 'recipe' that goes in place of the `task` function of Cakefiles. The `recipe` function emits events "taskname.start" and "taskname.complete". It also facilitates other events, on demand.
events = require('events')
recipe = (id, description, action) ->
# `recipe` wraps the Cake `task` command but fires a events through 'recipe'.
#
# One can listen for an event with `recipe.on('event_name', callback)`, and
# call that event with `recipe.emit('event_name', args)`.
#
# If `action` takes two arguments, the second argument is presumed to be a
# `done` callback. The presence of this callback makes the recipe
@brianmhunt
brianmhunt / gist:4365815
Last active December 10, 2015 02:09
A CasperJS wrapper for remote jQuery calls (untested)
class jQueryCasperWrapper
constructor: (@selector) ->
wrappedMethods = ['data', 'visible'] # ... plus all the other jQuery functions being wrapped
_.each(wrappedMethods, (method) => # lodash/underscore foreach -- just from my own preferences
wrapper = (args...) => @RemotejQuery(method, args)
@[method] = wrapper
)
RemotejQuery: (methodName, args) ->