Skip to content

Instantly share code, notes, and snippets.

@tj
tj / Makefile
Created October 20, 2011 00:36
tiny bash test runner
TESTS = $(shell find test/test.*.js)
test:
@./test/run.sh $(TESTS)
.PHONY: test
@3rd-Eden
3rd-Eden / remote.js
Created February 4, 2012 22:32
Uniform remote address interface for Node.js
var http = require('http')
, request = http.IncomingMessage.prototype;
/**
* Add a uniform interface for remote address in Node.js
*
* @api private
*/
request.__defineGetter__('remote', function remote () {
@jfhbrook
jfhbrook / hat.js
Created February 10, 2012 20:20
Howdy, stranger. Meet broadway.
// hat.js
exports.name = 'hat';
exports.attach = function attachHat (opts) {
// This plugin *depends* on the "head" plugin being loaded.
if (!this.head) {
throw new Error('You can\'t wear a `hat` without a `head`!');
}
@jedp
jedp / gist:1894029
Created February 23, 2012 17:54
example node.js event emitter
var util = require('util');
var events = require('events');
var redis = require('redis');
var RedisQueueConsumer = function (port, host) {
events.EventEmitter.call(this);
this.port = port || 6379;
this.host = host || '127.0.0.1';
};
@luk-
luk- / index.html
Created November 8, 2012 06:20 — forked from mbostock/.block
SVG Linear Gradient (D3)
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript" src="http://mbostock.github.com/d3/d3.js?1.27.1"></script>
</head>
<body>
<script type="text/javascript">
var w = 960,
h = 500;
@jhs
jhs / example.js
Created December 10, 2012 03:16
My Node.js modules these days
// Short module explanation // Something to gather my thoughts
// // I think this looks cool.
//
module.exports = the_exported_function // Modules are a function. Always.
//
module.exports.extra = extra // Additional API entry points if
module.exports.other = other // desired.
//
var util = require('util') // Other packages from npm or core
var assert = require('assert') // No comma-first due to lots of
@wolfeidau
wolfeidau / node-profiler.md
Last active December 17, 2015 00:59
Using node profiler util programs

#Introduction

So you have a program that is doing bad things and have isolated that to a test case, this guides you though using one of the tools bundled with node-profiler to read the v8 logs.

  • Install node-profiler into your project directory.
npm install profiler --from-git git://github.com/wolfeidau/node-profiler.git#updated_v8_to_3.14.5.8
@mikeal
mikeal / gist:2504336
Created April 27, 2012 00:11
Date parsing JSON
JSON._dateReviver = function (k,v) {
if (v.length !== 24 || typeof v !== 'string') return v
try {return new Date(v)}
catch(e) {return v}
}
JSON.parseWithDates = function (obj) {
return JSON.parse(obj, JSON._dateReviver);
}
@paulirish
paulirish / gist:3098860
Created July 12, 2012 15:26
Open Conference Expectations

Open Conference Expectations

This document lays out some baseline expectations between conference speakers and conference presenters. The general goal is to maximize the value the conference provides to its attendees and community and to let speakers know what they might reasonably expect from a conference.

We believe that all speakers should reasonably expect these things, not just speakers who are known to draw large crowds, because no one is a rockstar but more people should have the chance to be one. We believe that conferences are better -- and, dare we say, more diverse -- when the people speaking are not just the people who can afford to get themselves there, either because their company paid or they foot the bill themselves. Basically, this isn't a rock show rider, it's some ideas that should help get the voices of lesser known folks heard.

These expectations should serve as a starting point for discussion between speaker and organizer. They are not a list of demands; they are a list of rea

@timoxley
timoxley / gist:4697136
Last active December 30, 2019 07:56
Things I learned about Voxel.JS today

Terminology

  • block/voxel/cube -> mostly interchangeable. The minecrafty blocks you see on the screen.
  • chunk: is a piece of the world that contains voxels
  • AABB: bounding volume
  • voxeljs: not 100% consistent yet, 'voxel.js' also acceptable, but definitely not 'VoxelJS'.
  • dims: short for 'dimensions'. Perhaps obvious to some.

Positions