Skip to content

Instantly share code, notes, and snippets.

View hayes's full-sized avatar

Michael Hayes hayes

View GitHub Profile
var document = require('dom-lite').document
, htmlparser = require('htmlparser2')
var el_proto = Object.getPrototypeOf(document.createElement('p'))
, node_proto = Object.getPrototypeOf(el_proto)
Object.defineProperty(el_proto, 'innerHTML', {
get: get_html
, set: set_html
})
module.exports = debounce
function debounce(fn, delay, at_start) {
var timeout
if(typeof delay === 'undefined') {
delay = 0
}
return function() {
var tape = require('tape')
module.exports = setup
function setup(up, down, run) {
return function add_test(name, fn) {
var test_state = {}
var test = tape(name, function(t) {
test_state = up ? up(test_state) : test_state
var format = require('util').format
, ldap = require('ldapjs')
, fs = require('fs')
module.exports = setup
function setup(unpm) {
var base_options = {
url: unpm.config.ldap.uri
, tlsOptions: {
function add_commas(args, change) {
return function(val) {
var regex = /(\d+)(\d{3})/
val = val.toString()
while(regex.test(val)) {
val = val.replace(/(\d+)(\d{3})/, '$1,$2')
}
module.exports = Batch
function Batch(sync) {
if(!(this instanceof Batch)) {
return new Batch(sync)
}
this.jobs = []
this.sync = sync
this.frame = null
function upload_file(file) {
var fd = new FormData
, self = this
fd.append('file', file)
var xhr = request.post(url, {}, fd, function(err, response, headers) {
if(err) {
// non 200 resonse will be an error
// handle error
@hayes
hayes / faster-csv-parser.js
Last active August 29, 2015 14:06
a faster csv parser
var TransfromStream = require('stream').Transform
module.exports = Parser
function Parser(row, col) {
TransfromStream.call(this)
this._writableState.objectMode = false
this._readableState.objectMode = true
this.row_delim = row || '\r\n'
var express = require('express')
var app = express();
var sub = express.Router()
var sub2 = express.Router()
sub2.get('/c', function(req, res, next, base) {
res.send('sub test!!')
})
From 357ac14276b19fd760a9c3441a81ba2469e4e42a Mon Sep 17 00:00:00 2001
From: Michael Hayes <[email protected]>
Date: Fri, 10 Oct 2014 13:49:15 -0700
Subject: [PATCH] wip
---
lib/instrumentation/express.js | 71 ++++++++++++++++++++++++++++++++++--------
1 file changed, 58 insertions(+), 13 deletions(-)
diff --git a/lib/instrumentation/express.js b/lib/instrumentation/express.js