Skip to content

Instantly share code, notes, and snippets.

@sheldonh
sheldonh / restreamer.coffee
Created May 23, 2013 08:23
connect-restreamer that's sensitive to content-type
restreamer = (req, res, next) ->
req.removeAllListeners 'data'
req.removeAllListeners 'end'
next()
process.nextTick ->
if req.body?
if req.headers['content-type'] == 'application/x-www-form-urlencoded'
stringify = querystring.stringify
else
stringify = JSON.stringify
#!/bin/sh
# Assumes the launcher is in ~/.minecraft/minecraft.jar
version=2.8.5
source=http://sourceforge.net/projects/java-game-lib/files/Official%20Releases/LWJGL%20$version/lwjgl-$version.zip/download
cd ~/.minecraft || exit 1
checksum=$(md5sum bin/lwjgl.jar | awk '{print $1}')
@sheldonh
sheldonh / interaction_repo.rb
Created November 2, 2012 13:57
repo exploration
# E.g.
#
# InteractionRepo.with_interaction_for_message(m) do |i|
# i.add_response(m)
# i.call_back
# end
class InteractionRepo
def with_interaction_for_message(message)
require 'spec_helper'
describe InterfaceEnforcement::Constraint::Type do
context "for a class" do
subject { InterfaceEnforcement::Constraint::Type.new(Set) }
it 'allows the class' do
subject.allows?(Set.new).should be_true
# mongo 10.1.3.1
MongoDB shell version: 1.8.5
connecting to: 10.1.3.1/test
> config = { _id: 'rejproc',
... members: [
... {_id: 0, host: '10.1.3.1'},
... {_id: 1, host: '10.1.3.2'},
... {_id: 2, host: '10.1.3.3'}
... ]
... }
#
# lxc: linux Container library
#
# (C) Copyright IBM Corp. 2007, 2008
#
# Authors:
# Daniel Lezcano <dlezcano at fr.ibm.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
#!/usr/bin/env ruby
#
# output
#
# 17.340000 0.000000 17.340000 ( 17.346691)
# 18.380000 0.000000 18.380000 ( 18.388277)
#
require 'benchmark'
def bitmask
#!/usr/bin/env ruby
require 'benchmark'
def bitmask
2 ** 32 - 1
end
def bitmask_with_assignment
overshoot = 2 ** 32
@sheldonh
sheldonh / gist:1264292
Created October 5, 2011 12:05
Interactive PHP
[sheldonh] $ php -a
Interactive mode enabled
[sheldonh] $
I should have known. *sigh*
#!/bin/sh
#
if [ x"$OVERRIDE_WINDOW_TITLE" != x"" ]; then
title=$OVERRIDE_WINDOW_TITLE
else
title=${USER}@${HOSTNAME%%.*}:${PWD/$HOME/~}
fi
case $TERM in