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 / node-require.js-diff_match_patch.js
Created May 25, 2011 17:22 — forked from tmpvar/node-require.js-diff_match_patch.js
use diff match patch in node and in the browser via require.js
/**
* Diff Match and Patch
*
* Copyright 2006 Google Inc.
* http://code.google.com/p/google-diff-match-patch/
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
@dshaw
dshaw / node-and-npm-in-30-seconds.sh
Created May 26, 2011 03:50 — forked from isaacs/node-and-npm-in-30-seconds.sh
Use one of these techniques to install node and npm without having to sudo. Discussed in more detail at http://joyeur.com/2010/12/10/installing-node-and-npm/ Note: npm >=0.3 is *safer* when using sudo.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl http://npmjs.org/install.sh | sh
@dshaw
dshaw / application.js
Created June 8, 2011 17:43 — forked from fabware/application.js
socket.io application and haproxy configuration
var express = require('express');
var redis = require('redis');
const serverType = process.argv[2];
const serverHost = process.argv[3];
const serverPort = parseInt(process.argv[4]);
const redisPort = 6379;
const redisHost = '127.0.0.1';
@dshaw
dshaw / gist:1038645
Created June 21, 2011 19:22 — forked from bluewhalelabs/gist:1033554
Turntable Growler
// ==UserScript==
// @name Turntable Growler
// @namespace http://fluidapp.com
// @description Creates growl notifications for chat in turntable
// @include *
// @author Gregarious Narain
// ==/UserScript==
(function () {
if (window.fluid) {
@dshaw
dshaw / module.js
Created June 22, 2011 05:01 — forked from creationix/module.js
A super simple module system for browsers. Assumes all source files are concatenated and in browser.
function define(name, fn) {
if (!defs) { defs = {}; }
defs[name] = fn;
}
function require(name) {
console.log("Loading " + name);
if (modules && modules.hasOwnProperty(name)) return modules[name];
if (defs && defs.hasOwnProperty(name)) {
if (!modules) { modules = {}; }
var fn = defs[name];
@dshaw
dshaw / gist:1072946
Created July 8, 2011 22:08 — forked from technoweenie/gist:1072829
.netrc file so you can push/pull to https git repos without entering your creds all the time
machine github.com
login technoweenie
password SECRET
machine api.github.com
login technoweenie
password SECRET
@dshaw
dshaw / console.log.js
Created July 12, 2011 07:29 — forked from tmpvar/.gitignore
A console.log implementation that plays "nice" with large amounts of data. Keeps node alive until the output has flushed to screen.
/*
A console.log that won't leave you hanging when node exits
*/
console.log = function(d) {
var res = process.stdout.write(d + '\n');
// this is the first time stdout got backed up
if (!res && !process.stdout.pendingWrite) {
process.stdout.pendingWrite = true;
@dshaw
dshaw / array.goodies.js
Created July 21, 2011 21:09 — forked from rwaldron/array.extensions.md
Array goodies from twitter rap with David Herman, see wrap up here: http://twitter.com/#!/littlecalculist/status/89855977838485504
// http://twitter.com/#!/littlecalculist/status/89848378682392576
// http://twitter.com/#!/littlecalculist/status/89855977838485504
// Unary Array.from()
Array.from = function( arrayish ) {
return [].slice.call( arrayish );
};
###
# An implementation of the msgpack serialization format - http://msgpack.org/
# By Devon Govett
# MIT LICENCE
###
class MsgPack
idx = 0
@pack: (data, byteArray = false) ->
@dshaw
dshaw / gist:1145696
Created August 15, 2011 04:01 — forked from devongovett/gist:1037265
jsondb + msgpack
var arr = [],
obj = {'abcdef' : 1, 'qqq' : 13, '19' : [1, 2, 3, 4]};
for(var i = 0; i < 5000; i++)
arr.push(obj);
// jsondb(arr) looks something like this:
// ["abcdef", "qqq", "19", [1, 13, [1, 2, 3, 4]], [1, 13, [1, 2, 3, 4]]...]
> JSON.stringify(arr).length //original