Skip to content

Instantly share code, notes, and snippets.

View hayes's full-sized avatar

Michael Hayes hayes

View GitHub Profile
'use strict';
var test = require('tap').test;
var tracer = require('tracing')
test("async listener lifecycle", function (t) {
t.plan(1);
var count = 0
From 357ac14276b19fd760a9c3441a81ba2469e4e42a Mon Sep 17 00:00:00 2001
From: Michael Hayes <mhayes@newrelic.com>
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
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!!')
})
@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'
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
module.exports = Batch
function Batch(sync) {
if(!(this instanceof Batch)) {
return new Batch(sync)
}
this.jobs = []
this.sync = sync
this.frame = null
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')
}
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: {
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
module.exports = debounce
function debounce(fn, delay, at_start) {
var timeout
if(typeof delay === 'undefined') {
delay = 0
}
return function() {