Skip to content

Instantly share code, notes, and snippets.

https://www.dropbox.com/s/a5gupd4wb343w57/blast-logo-copy_watermark-block.png?dl=0
@nrw
nrw / struct.js
Last active August 29, 2015 14:02
struct({
note: varhash({}, function (val, key) {
var output = {}
Object.keys(val).forEach(function (k) {
output[k] = Observ(val[k])
})
return output
})
})
var people = varhash({}, function setPerson (obj, key), {
return struct({
id: key,
name: value(obj.name)
})
})
var teams = varhash({}, function setTeam (obj, key) {
return struct({
id: key,
@nrw
nrw / index.js
Created May 29, 2014 20:24
requirebin sketch
var raf = require("raf")
var throttle = require("lodash.throttle")
var canvas = document.createElement("canvas")
var ctx = canvas.getContext('2d')
// setup canvas
document.body.style.margin = document.body.style.padding = 0
document.body.appendChild(canvas)
// only redraw every 200 milliseconds
@nrw
nrw / index.js
Created May 29, 2014 20:23
requirebin sketch
require('fs') // at the time of writing, requirebin needs a require.
var canvas = document.createElement("canvas")
var ctx = canvas.getContext('2d')
// setup canvas
document.body.style.margin = document.body.style.padding = 0
document.body.appendChild(canvas)
requestAnimationFrame(tick)
@nrw
nrw / client.js
Created January 30, 2014 22:40
Example of failing reconnect
// client
var domready, reconnect, through;
through = require('through');
domready = require('domready');
reconnect = require('reconnect/shoe');
domready(function() {
var r, result;
result = document.getElementById('result');