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
define -> | |
class EventEmitter | |
constructor: -> | |
@listeners = {} | |
@middleware = [] | |
on: (event, action) -> | |
throw new Error "'#{event}' arg is not a function" if typeof action isnt 'function' |
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
sugar = require 'sugar' | |
memwatch = require 'memwatch' | |
logger = require './logger' | |
presetFormats = | |
raw: (stats) -> stats | |
default: (stats) -> stats.change.size | |
details: (stats) -> | |
top3 = stats.change.details.sortBy('size_bytes', true).slice(0, 3) | |
summary = {} |
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
# printout helper | |
counter = 1 | |
println = (args...) -> console.log "#{counter++}:", args... | |
# example collection | |
names = ['Jim', 'Nancy', 'Sam', 'Cindy'] | |
# example function |
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
{ operation: 'set', | |
id: '51a0249adae44c01b0000003', | |
path: 'messages', | |
data: | |
[ { message: 'hey', | |
username: 'Bob', | |
timestamp: Fri May 24 2013 19:40:28 GMT-0700 (MST), | |
_id: 51a0249cdae44c01b0000005 }, | |
{ message: 'hey', | |
username: 'Bob', |
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
{ operation: 'pushAll', | |
id: '51a0249adae44c01b0000003', | |
path: 'messages', | |
data: | |
[ { message: 'asdf', | |
username: 'Bob', | |
timestamp: 'Mon May 27 2013 14:26:39 GMT-0700 (MST)', | |
_id: '51a3cf8f5f9a745a07000003' } ] } |
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
curry: (fn, args...) -> fn.bind fn.prototype, args... | |
tandoor: (fn) -> | |
naan = (args...) -> | |
[_..., last] = args | |
unless (fn.length > 0 and args.length >= fn.length) or (fn.length == 0 and util.getType(last) is 'Function') | |
return util.curry naan, args... | |
fn args... | |
return naan |
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
{EventEmitter} = require 'events' | |
eventChannel = new EventEmitter() | |
eventChannel.on 'error', (args...) -> console.log "Event Channel received error:", args... | |
module.exports = eventChannel |
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
module.exports = (assets) -> | |
replaceUrls = (content) -> | |
result = content.toString() | |
for asset in assets.assets when asset.url and asset.specificUrl | |
#console.log "replacing: #{asset.url} with: #{asset.specificUrl}" | |
result = result.replace asset.url, asset.specificUrl | |
return result | |
for asset in assets.assets when asset.contents |
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
#!/usr/bin/ruby | |
puts "Need a process name to search for." && Process.exit() unless ARGV.count > 0 | |
name = ARGV[0] | |
process = `ps aux | grep '#{name}' | grep -v grep | grep -v #{$$}` | |
if process.chomp.match "\n" | |
puts "Multiple processes found:\n #{process}" | |
Process.exit() | |
end |
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
# coffeescript version 1.3.3 | |
should = require 'should' | |
nums = | |
current: 5 | |
next: -> @current + 1 | |
last: -> @current - 1 | |
# passes |