Skip to content

Instantly share code, notes, and snippets.

@todoubled
todoubled / hack.sh
Created April 2, 2012 14:11 — forked from erikh/hack.sh
OSX For Hackers
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://raw.github.com/gist/2108403/hack.sh | sh
#
# index.html
<script src="/javascripts/lib/require.js" data-main="/javascripts/app/config.js">
# public/coffeescripts/app/config.coffee
require.config
deps: ["initialize"]
paths:
"jquery":"lib/jquery"
"initialize": "app/initialize"
@todoubled
todoubled / process-manager.coffee
Created November 24, 2012 00:36
Manage multiple long-running node.js processes.
cp = require 'child_process'
processes = ['make dev-server PORT=8081', 'casperjs test --includes=test/casper-helpers.coffee --cookies-file=/dev/null? test/integration']
processes.forEach (proc) ->
p = cp.spawn 'sh', ['-c', proc]
p.stdout.setEncoding 'utf8'
p.stderr.pipe process.stderr
p.stdout.pipe process.stdout
p.on 'exit', ->
process.kill 'SIGINT'
@todoubled
todoubled / dynamic-dependencies.coffee
Created December 9, 2012 20:16
Helper to detect and write dependency versions in query string params.
# Get version strings from URL
jQueryVersion = /jquery=([\w\.]+)/.exec location.search
backboneVersion = /backbone=([\w\.]+)/.exec location.search
underscoreVersion = /underscore=([\w\.]+)/.exec location.search
mustacheVersion = /mustache=([\w\.]+)/.exec location.search
supportedVersions =
jquery: ['1.6.4', '1.8.1']
backbone: ['0.5.3', '0.9.2']
@todoubled
todoubled / start.coffee
Created December 10, 2012 04:40
Manage multiple long-running node.js processes.
cp = require 'child_process'
processes = ['make dev-server PORT=8081', 'casperjs test --includes=test/casper-helpers.coffee --cookies-file=/dev/null? test/integration']
processes.forEach (proc) ->
p = cp.spawn 'sh', ['-c', proc]
p.stdout.setEncoding 'utf8'
p.stderr.pipe process.stderr
p.stdout.pipe process.stdout
p.on 'exit', ->
process.kill 'SIGINT'
@todoubled
todoubled / kue-example.coffee
Last active October 13, 2015 20:07
Controlling Meatspace With Arduino and Twitter
kue = require 'kue'
jobs = kue.createQueue()
kue.app.enable 'jsonp callback'
assembleJob = (data) ->
type = 'tweet'
jobData =
title:data.text
handle:data.user.screen_name
avatar:data.user.profile_image_url
@todoubled
todoubled / routes.coffee
Created December 17, 2012 01:58
Mock server for local development
#
# Use a fixture stub of JSON to mock a headline API to respond to GET /headline
#
fs = require 'fs'
express = require 'express'
root = require('path').normalize "#{__dirname}/.."
pub = "#{root}/app/public"
headline = JSON.parse fs.readFileSync "#{root}/app/fixtures/headline-api.json", 'utf8'
module.exports = routes = express()
@todoubled
todoubled / casper-test.coffee
Created December 17, 2012 02:27
Example casper.js test
query = 'portland'
types = 'foo,bar,baz'
params = /// chicago/all/#{types} ///
casper.start 'http://localhost:8081', ->
@setupCookie 'chicago'
@reload()
.then ->
@todoubled
todoubled / callbacks.coffee
Last active December 11, 2015 03:19
Module examples
{SearchError} = require '../views/search-error.coffee'
@onEnterError = (event, from, to, model) ->
new SearchError({model}).render()
@todoubled
todoubled / cors.sh
Created January 16, 2013 17:39
Enable CORS in Chrome.
open -a Google\ Chrome --args --disable-web-security