Skip to content

Instantly share code, notes, and snippets.

View isaacs's full-sized avatar
🔮
only way out is through

isaacs isaacs

🔮
only way out is through
View GitHub Profile
var sys = require('sys'),
crypto = require('crypto'),
algos = ["sha1", "md5", "sha256", "sha512", "ripemd160"],
encoding = "hex";
algos.forEach( function( algo) {
exports[ algo ] = function(data, salt) {
return (typeof salt === 'undefined')
? crypto.createHash(algo).update(data).digest(encoding)
: crypto.createHmac(algo, salt).update(data).digest(encoding)
var crypto = require('crypto');
["sha1", "md5", "sha256", "sha512", "ripemd160"].forEach(function(algo) {
exports[algo] = function(data, salt) {
return crypto["createH"+(typeof salt != 'undefined' ? "mac":"ash"](algo,salt)
.update(data).digest("hex");
};
});
@isaacs
isaacs / router.js
Created July 22, 2010 17:11 — forked from pgriess/router.js
var HTTPParser = process.binding('http_parser').HTTPParser;
var net = require('net');
var path = require('path');
var sys = require('sys');
var Worker = require('webworker').Worker;
var VHOSTS = ['foo.bar.com', 'baz.bizzle.com'];
var WORKERS = {};
VHOSTS.forEach(function(vh) {
fromAll("foo","bar","baz","widget", function(foo, bar, baz, widget){
var myThing
// Actual library code
return myThing
})
@isaacs
isaacs / module.patch
Created August 4, 2010 20:48 — forked from nickstenning/dirs.patch
module.patch
diff --git a/lib/module.js b/lib/module.js
index 72814a7..0827d13 100644
--- a/lib/module.js
+++ b/lib/module.js
@@ -83,17 +83,6 @@ var pathFn = process.compile("(function (exports) {" + natives.path + "\n})",
var pathModule = createInternalModule('path', pathFn);
var path = pathModule.exports;
-function existsSync (path) {
- try {
diff --git a/lib/module.js b/lib/module.js
index 72814a7..1db1cb4 100644
--- a/lib/module.js
+++ b/lib/module.js
@@ -83,17 +83,6 @@ var pathFn = process.compile("(function (exports) {" + natives.path + "\n})",
var pathModule = createInternalModule('path', pathFn);
var path = pathModule.exports;
-function existsSync (path) {
- try {
@isaacs
isaacs / gist:620979
Created October 11, 2010 18:24 — forked from mikeal/gist:620021
diff --git a/lib/stream.js b/lib/stream.js
index 189708a..37687b0 100644
--- a/lib/stream.js
+++ b/lib/stream.js
@@ -53,3 +53,22 @@ Stream.prototype.pipe = function (dest, options) {
if (source.readable) source.resume();
});
};
+
+exports.createFilter = function (listener) {
@isaacs
isaacs / foo.js
Created February 7, 2011 21:50 — forked from niklasfi/foo.js
module.exports = Foo;
//now i would like to have a constructor function for the foo "class" (i know in JS that does not exist)
//with normal js this would be
function Foo(arg1,arg2){
this.something = arg1;
this.somethingOther = arg2;
}
@isaacs
isaacs / testing
Created April 18, 2011 02:40 — forked from anonymous/testing
isaacs@cometrocket:~
$ pbpaste > file.js
isaacs@cometrocket:~
$ chmod 0755 file.js
isaacs@cometrocket:~
$ ./file.js
testing
@isaacs
isaacs / LICENSE.txt
Created May 18, 2011 13:54 — forked from 140bytes/LICENSE.txt
140byt.es -- Click ↑↑ fork ↑↑ to play!
Copyright (c) 2011 YOUR_NAME_HERE, YOUR_URL_HERE
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions: