Skip to content

Instantly share code, notes, and snippets.

Joshua Mervine jmervine

View GitHub Profile
# build tmux w/ libevent source
set -uex
cd /tmp
# libevent

Mocking Middleware in Node.js is Easy

Mocking [Connect] or [Express] middleware in Node.js is easy. Simple create your request and response objects and use the next function as the harness to tests.

I'm going to assume [Tape] for this example, but this is easily ported to [Mocha], [nodeunit] or any other test harness of your choosing.

// file: simple_middleware.js
module.exports = function(request, response, next) { = 'foo';
View maketest.vim
" :MakeTestFile
" run make test/unit on file
" mapping:
" nnoremap <silent> <leader>tt :MakeTest %
command! -nargs=+ MakeTest call s:MakeTestFile(<q-args>)
function! s:MakeTestFile(current_file)
echo a:current_file
let test_file_path = substitute(expand(a:current_file), "yp", "test/unit", "")

Maxing out MaxCDN with Github Webhooks

Setup maxcdn-purge

[maxcdn-purge] is a wrapper for the [maxcdn] node module, allowing for simple purging of cdns.

Install maxcdn-purge

npm install -g maxcdn-purge
#!/usr/bin/env bash
if test "$(xrandr | grep "HDMI1 connected")"; then
xrandr --output LVDS1 --auto --right-of HDMI1
xrandr --output HDMI1 --auto --primary --left-of LVDS1
xrandr --output HDMI1 --off
xrandr --output LVDS1 --auto --primary
# exec_always ~/
View config
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
# Should you change your keyboard layout somewhen, delete
# this file and re-run i3-config-wizard(1).
# i3 config file (v4)
# Please see for a complete reference!
View Makefile
# Usage:
# Download this file and start by running 'make'. Then run
# each target listed, 'make lesson_one', 'make lesson_two',
# etc.
# Introduction:
View FormattedDate.js
Author: Joshua P. Mervine <> []
<script src="" />
<script src="" />
View extend.js
/* setup
* npm install underscore extend benchmark
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
var bento = require('./bento'); // 122K json file
View proxy.js
// npm install restify
var payload = JSON.parse(require('fs').readFileSync('./bento.json', 'utf8'));
var cluster = require('cluster');
if (cluster.isMaster) {
cluster.on('exit', function() {
You can’t perform that action at this time.