Skip to content

Instantly share code, notes, and snippets.

View mattnull's full-sized avatar

Matt Null mattnull

View GitHub Profile
@mattnull
mattnull / handlebars-precompiler-cakefile.coffee
Last active December 19, 2015 21:59
Part of my main Cakefile that pre-compiles Handlebars templates. This script watches the specified directory for changes and writes to templates.js
fs = require 'fs'
{print} = require 'sys'
{log, error} = console; print = log
{spawn, exec} = require 'child_process'
run = (name, args...) ->
proc = spawn(name, args)
proc.stdout.on('data', (buffer) -> print buffer if buffer = buffer.toString().trim())
proc.stderr.on('data', (buffer) -> error buffer if buffer = buffer.toString().trim())
proc.on 'exit', (status) ->
@mattnull
mattnull / socketio-quick-reference.js
Last active December 26, 2015 09:39
Quick reference for commonly used Socket.io methods
// http://stackoverflow.com/questions/10058226/send-response-to-all-clients-except-sender-socket-io
// send to current request socket client
socket.emit('message', "this is a test");
// sending to all clients, include sender
io.sockets.emit('message', "this is a test");
// sending to all clients except sender
socket.broadcast.emit('message', "this is a test");
@mattnull
mattnull / consolelog-override-heroku.coffee
Created November 13, 2013 23:58
Override console.log on Heroku
# Override console.log on Heroku
# We are doing this console.log kills performance
console.log = if global.process.env.NODE_ENV? then () -> else console.log