Skip to content

Instantly share code, notes, and snippets.

@hughsk
hughsk / index.js
Created September 1, 2013 22:50
requirebin sketch
var observer = require('continuous-observer')
var cave = require('cave-automata-2d')
var fill = require('ndarray-fill')
var zero = require('zeros')
var raf = require('raf')
var canvas = document.createElement('canvas')
var ctx = canvas.getContext('2d')
// Set up the controls, so that we can control
@hughsk
hughsk / index.js
Created September 1, 2013 22:44
requirebin sketch
var observer = require('continuous-observer')
var cave = require('cave-automata-2d')
var fill = require('ndarray-fill')
var zero = require('zeros')
var raf = require('raf')
var canvas = document.createElement('canvas')
var ctx = canvas.getContext('2d')
// Set up the controls, so that we can control
@hughsk
hughsk / index.js
Created September 1, 2013 14:13
requirebin sketch
// Load up the `raf` module.
var raf = require('raf')
var controls = require('kb-controls-iframed')({
'W': 'up',
'A': 'left',
'S': 'down',
'D': 'right',
'<up>': 'up',
'<left>': 'left',
'<down>': 'down',
@hughsk
hughsk / index.js
Created September 1, 2013 11:21
requirebin sketch
// Load up the `raf` module.
var raf = require('raf')
// Create the canvas, and add it
// to the page.
var canvas = document.createElement('canvas')
var ctx = canvas.getContext('2d')
var width = 500
var height = 300
var perlin = require('perlin').noise.perlin3
var fill = require('ndarray-fill')
var zeros = require('zeros')
var scale = 0.075
var threshold = 0.125
// Untested in 3D, but "theoretically" this should
// work. Using the equivalent 2d getter with the
// continuous-box2d demo works well.
<style type='text/css'> html, body { margin: 0; padding: 0; border: 0; } </style>
@hughsk
hughsk / .gitignore
Created September 18, 2012 01:19
Trickle
node_modules
@hughsk
hughsk / post-receive.sh
Created April 3, 2012 09:45
Node + Git push-to-deploy hook
# GITBAREDIR e.g. "/home/web/present-company.git"
GITBAREDIR=`pwd`;
# GITPROJECTDIR e.g. "present-company"
GITPROJECTDIR=`basename $PWD | sed 's/.git//g'`;
# Stop the application, move up on directory
npm stop;
cd ..;
@hughsk
hughsk / rmdirSyncForce.js
Created February 1, 2012 07:47
Synchronous `rmdir --recursive` for NodeJS.
// Thanks to [liangzan's gist](https://gist.github.com/807712)
rmdirSyncForce = function(path) {
var files, file, fileStats, i, filesLength;
if (path[path.length - 1] !== '/') {
path = path + '/';
}
files = fs.readdirSync(path);
filesLength = files.length;
@hughsk
hughsk / Boide.pde
Created December 27, 2011 08:40
Simple Boids example in Processing
class Boid {
PVector pos;
PVector spd;
PVector acc;
Boid() { this(random(0, width), random(0, height)); }
Boid(float x, float y) { this(x, y, random(0,1), random(0,1)); }
Boid(float x, float y, float xspd, float yspd) {
pos = new PVector(x, y);