Skip to content

Instantly share code, notes, and snippets.

View jmervine's full-sized avatar

Joshua Mervine jmervine

View GitHub Profile
# build tmux w/ libevent source
TMUX_VERSION=1.9a
LIBEVENT_VERSION=2.0.21
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) {
 response.foo = 'foo';
" :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
else
xrandr --output HDMI1 --off
xrandr --output LVDS1 --auto --primary
fi
# exec_always ~/display.sh
# 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 http://i3wm.org/docs/userguide.html for a complete reference!
/*
Author: Joshua P. Mervine <joshua@mervine.net> [github.com/jmervine]
See: http://jsfiddle.net/jmervine/dqA9r/5/
Use:
<script src="http://cdn.mervine.net/FormattedDate.js" />
<script src="http://cdn.mervine.net/FormattedDate.min.js" />
###
# Usage:
#
# Download this file and start by running 'make'. Then run
# each target listed, 'make lesson_one', 'make lesson_two',
# etc.
#
introduction:
# Introduction:
/* setup
*
* npm install underscore extend benchmark
*
*/
var Benchmark = require('benchmark');
var suite = new Benchmark.Suite;
var bento = require('./bento'); // 122K json file
// npm install restify
var payload = JSON.parse(require('fs').readFileSync('./bento.json', 'utf8'));
var cluster = require('cluster');
if (cluster.isMaster) {
cluster.fork();
cluster.fork();
cluster.on('exit', function() {