Skip to content

Instantly share code, notes, and snippets.

View raycmorgan's full-sized avatar

Ray Morgan raycmorgan

  • Stripe
  • San Francisco, CA
View GitHub Profile
var http = require('http'),
sys = require('sys');
http.createServer(function (request, response) {
response.writeHead(200, {'content-type': 'text/plain'});
response.write("Hello");
response.write(" ");
setTimeout(function () {
/*
* hookio/protocols/mustache
* Implements a mustache protocol for parsing mustache tags out of text
*/
var hookIO = require('../../hookio').hookIO,
mu = require('../lib/mu/lib/mu');
exports.start = function() {
// little test case
function doHash(str, seed) {
var m = 0x5bd1e995;
var r = 24;
var h = Math.pow(seed, str.len);
var length = str.length;
var currentIndex = 0;
while (length >= 4) {
var k = UInt32(str, currentIndex);
function doHash(str, seed) {
var m = 0x5bd1e995;
var r = 24;
var h = seed ^ str.length;
var length = str.length;
var currentIndex = 0;
while (length >= 4) {
var k = UInt32(str, currentIndex);
contents = fs.readFile("/path/to/file.txt");
// do stuff with contents
var foo = db.get('foo', function (err, res) {
callback(err, res);
});
@raycmorgan
raycmorgan / gist:1636039
Created January 18, 2012 21:54 — forked from jimmyjacobson/gist:1631704
Redis Queries
=== database object file
var errors = require('./errors');
var db;
exports.setDatabase = function(database) {
db = database;
}
function foo(key, callback) {
db.get(key, function (err, result) {
callback(err, result);
})
}
// is the same as:
function foo(key, callback) {
db.get(key, callback);
var objOne = {};
var objTwo = {};
objOne.foo = {};
objOne.foo.bar = 100;
objTwo = objOne;
objTwo.foo.bar = 200;
@raycmorgan
raycmorgan / async_ext.js
Created January 17, 2014 20:47
async.applyDeps
// ----------------------------------------------------------------------------
// Requirements
// ----------------------------------------------------------------------------
var _ = require('underscore')
, async = require('async');
// ----------------------------------------------------------------------------
// Public functions
// ----------------------------------------------------------------------------