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 / nsolid-install.sh
Last active October 19, 2015 05:20 — forked from pmuellr/nsolid-install.sh
install N|Solid components into ~/nsolid
#!/bin/sh
#-------------------------------------------------------------------------------
# download/unpack componentry for N|Solid into ~/nsolid
#-------------------------------------------------------------------------------
# directories
DIR_DOWN=~/Downloads
DIR_INST=~/nsolid
@dshaw
dshaw / server.js
Last active January 3, 2016 14:59
var jade = require('jade')
, data = require('./data.json')
;
var header = new Buffer('HTTP/1.1 200 OK\r\n\r\n');
var server = require('net').createServer(function(conn) {
conn.write(header);
conn.close();
}).listen(8000);
@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 / 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 / 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 / gist:1408474
Created November 30, 2011 09:05 — forked from shripadk/gist:1406702
#!/usr/bin/env node
var os = require('os');
var WebSocketClient = require('websocket').client;
var count = 0;
function recursion() {
var client = new WebSocketClient();
client.on('connectFailed', function(error) {
@dshaw
dshaw / starttls.js
Created November 17, 2011 16:29 — forked from TooTallNate/starttls.js
Upgrade a regular `net.Stream` connection to a secure `tls` connection.
// Target API:
//
// var s = require('net').createStream(25, 'smtp.example.com');
// s.on('connect', function() {
// require('starttls')(s, options, function() {
// if (!s.authorized) {
// s.destroy();
// return;
// }
//
@dshaw
dshaw / HelloDartTest.dart
Created October 12, 2011 00:27
Dart Compilation
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
// Simple test program invoked with an option to eagerly
// compile all code that is loaded in the isolate.
// VMOptions=--compile_all
class HelloDartTest {
static testMain() {
print("Hello, Darter!");