Skip to content

Instantly share code, notes, and snippets.

View dshaw's full-sized avatar
🦄
Always bet on Node.js ✨

Dan Shaw dshaw

🦄
Always bet on Node.js ✨
View GitHub Profile
@dshaw
dshaw / RedisConf2012.md
Created October 29, 2012 16:59
Redis Conf 2012 Talks
@dshaw
dshaw / 0-readme.md
Created October 29, 2012 16:53 — forked from burke/0-readme.md

A Bloom Filter in Redis

This is a really simple implementation of a bloom filter using Redis 2.6's lua scripting facility.

Though it "works", it's just a proof of concept. The choice and implementation of hashing functions leave something to be desired (I'm sure it's a fine implementation of CRC32 that I borrowed, but it's in pure lua, and, well, CRC32 is not the best function to use for a bloom filter).

Caveat Emptor, no refunds, etc. MIT License.

@dshaw
dshaw / npm-avail.js
Created September 9, 2012 00:27
npm avail
npm view `basename $PWD`
@dshaw
dshaw / package.json_private_module
Created July 26, 2012 03:20 — forked from mbrevoort/package.json_private_module
private npm repo namespace idea so that private registries don't have to replicate the entire public NPM registry or you don't have to do some sort of conditional proxying.
// A module published to a private registry would optionally have a "registry"
// property that is a reference to the registry where this module is published.
//
// A `npm publish` would publish to the registry in the registry property.
//
// Otherwise, `npm --registry http://private.me:5984/registry/_design/app/_rewrite publish`
//
{
"name": "foo",
@dshaw
dshaw / replify.js
Created July 12, 2012 00:57
Add a repl to Node v0.6 or v0.8
var fs = require("fs")
, net = require("net")
, repl = require("repl")
module.exports = function replify (name, ctx) {
var repl_path = "/tmp/" + name + ".sock"
ctx || (ctx = {})
fs.unlink(repl_path, function () {
// intentionally not listening for the error. either way, we're good.
@dshaw
dshaw / app.js
Created March 29, 2012 08:36
Socket.io / Express App REPL
var express = require('express')
, repl = require('./repl');
var app = express.createServer();
app.get('/', function(req, res){
res.send('Hello World');
});
app = repl(app);
@dshaw
dshaw / respawn.js
Created March 22, 2012 04:45
Continuously keep respawning a child process
var exec = require('child_process').exec;
function respawn () {
var child = exec('date', function (error, stdout, stderr) {
console.log('stdout: ' + stdout);
console.log('stderr: ' + stderr);
if (error !== null) console.log('exec error: ' + error);
});
child.on('exit', function (code, signal) {
@dshaw
dshaw / emitLines.js
Created February 10, 2012 01:24 — forked from TooTallNate/emitLines.js
Make any ReadableStream emit "line" events
/**
* A quick little thingy that takes a Stream instance and makes
* it emit 'line' events when a newline is encountered.
*
* Usage:
* ‾‾‾‾‾
* emitLines(process.stdin)
* process.stdin.resume()
* process.stdin.setEncoding('utf8')
* process.stdin.on('line', function (line) {
@dshaw
dshaw / client.js
Created November 30, 2011 21:56
socket.io-client node fail
/**
* Module dependencies
*/
var io = require('socket.io-client');
/**
* Configuration.
*/