Skip to content

Instantly share code, notes, and snippets.

require 'faye'
require 'logger'
Faye::WebSocket.load_adapter('thin')
faye = Faye::RackAdapter.new(:mount => '/faye', :timeout => 25)
#Define hash to store metrics each time a monitoring event occurs in the server
event_metrics = {
:connections => {count: 0, latest_timestamp: nil},
:active_subscriptions => {count: 0, latest_timestamp: nil},
export PATH := node_modules/.bin:$(PATH)
source_files := $(wildcard lib/*.coffee)
build_files := $(source_files:%.coffee=build/%.js)
template_source := templates/*.handlebars
template_js := build/templates.js
app_bundle := build/app.js
spec_coffee := $(wildcard spec/*.coffee)
spec_js := $(spec_coffee:%.coffee=build/%.js)
@jcoglan
jcoglan / async.js
Last active August 29, 2015 13:56
var foo
async.waterfall([
function(cb) {
getThingFromDB("foo", cb)
}, function(_foo, cb) {
foo = _foo
getOtherThingFromDB(foo, "bar", cb)
}, function(bar, cb) {
qux(foo, bar)
var crypto = require("crypto")
var User = function(attributes) {
this._attributes = attributes || {}
}
User.KEY_LENGTH = 32
User.WORK_FACTOR = 20000
User.prototype.setPassword = function(password, callback) {
\ /
\ so /
\ /
much X very
/ \
/ wow \
/ \
var cheerio = require("cheerio"),
path = require("path"),
request = require("request"),
url = require("url"),
_ = require("underscore")
var Browser = function(userAgent, origin) {
this.location = url.parse(origin)
this._cookies = request.jar()
this._headers = {"Accept": "text/html", "User-Agent": userAgent}
var express = require("express"),
fs = require("fs"),
http = require("http"),
path = require("path")
var app = express()
app.use(express.static(path.resolve(__dirname, "public")))
app.get("/", function(request, response) {
var JS = require("jstest"),
async = require("async"),
WebSocket = require("faye-websocket").Client,
Browser = require("../../chatroom/spec/browser"),
store = require("../../orm/store"),
User = require("../../orm/persisted_user"),
app = require("../app")
JS.Test.describe("WebSockets", function() { with(this) {
before(function(resume) { with(this) {
// fs_stat :: String -> (Error -> Stat -> ()) -> ()
var fs_stat = _.curry(fs.stat, 2);
// paths :: [String]
var paths = ['file1.txt', 'file2.txt', 'file3.txt'];
// tmp :: [(Error -> Stat -> ()) -> ()]
var tmp = paths.map(oneparam(fs_stat));
// async.parallel :: [(Error -> a -> ()) -> ()] -> (Error -> [a] -> ()) -> ()
# Migrate from this:
class ListItem < ActiveRecord::Base
belongs_to :group
acts_as_list scope: :group
# has id and type columns
end
class Audio < ListItem
end