Skip to content

Instantly share code, notes, and snippets.

~ > cat /usr/local/bin/git-publish
#!/usr/bin/env ruby
cmds = []
cmds << "git co gh-pages"
cmds << "git merge master"
cmds << "git push github gh-pages"
cmds << "git co master"
system cmds.join("&&")
@carljm
carljm / install-gems.sh
Created May 18, 2011 19:29
ghetto gem-installer that reads something similar to a pip requirements file
#!/bin/bash
vfile=$1
for line in `cat ${vfile}`; do
gem=${line%%=*}
version=${line##*=}
if gem list | grep ${gem} | grep "(${version})"; then
echo "${gem} (${version}) is already installed"
else
gem install ${gem} -v ${version} --no-rdoc --no-ri
fi
#!/bin/sh
# Close stdin
exec <&-
devices=$(ls /dev/sd? | grep -v '/dev/sda')
devcount=$(echo "$devices" | wc -w)
FSTYPE=ext4
from time import time
import math
class AccrualFailureDetector(object):
""" Python implementation of 'The Phi Accrual Failure Detector'
by Hayashibara et al """
max_sample_size = 1000
threshold = 3 # 1 = 10% error rate, 2 = 1%, 3 = 0.1%, etc
class ReverseProxied(object):
def __init__(self, app):
self.app = app
def __call__(self, environ, start_response):
script_name = environ.get('HTTP_X_SCRIPT_NAME', None)
if script_name is not None:
environ['SCRIPT_NAME'] = script_name
path_info = environ['PATH_INFO']
if path_info.startswith(script_name):
@brettbuddin
brettbuddin / install.sh
Created May 10, 2011 18:53
New machine setup. SET IT! AND FORGET IT!
#!/bin/sh
# Usage: bash < <(curl -s https://gist.github.com/raw/965142/install.sh)
if [ ! -d "/Developer/Applications/Xcode.app" ]; then
echo "Please install Xcode first. Exiting."
exit 1
fi
# Have sudo ask us for our password before we kick everything off so we can walk away.
sudo echo "Here we go..."
@mattpodwysocki
mattpodwysocki / jsconf2011-talks.txt
Created May 5, 2011 18:30
JSConf talks and resources
Track A
Bytes and Blobs – David Flanagan @__DavidFlanagan
Slides: http://davidflanagan.com/Talks/jsconf11/BytesAndBlobs.html
Conference Wifi Redux - Malte Ubi @cramforce
Sashimi: https://github.com/cramforce/Sashimi
Slides: http://social-traffic.streamie.org/preso/static/#slide1
Run Your JS everywhere with Jellyfish – Adam Christian @admc
@jeresig
jeresig / .vimrc
Created May 4, 2011 16:46
VIM Config
au BufRead,BufNewFile jquery.*.js set ft=javascript syntax=jquery
set nocompatible
set autoindent
set tabstop=2
set showmatch
set vb t_vb=
set ruler
set nohls
set incsearch
syntax on
"""
Patches the database wrapper and template engine to throw an exception if a query is executed inside of a template.
In your urls.py, enable it like so:
>>> import monkey
>>> monkey.patch_templates()
"""
import logging
@lak
lak / puppet-solo
Created March 7, 2011 23:00
Providing chef-solo-like behavior in Puppet
#!/usr/bin/env
# Because Puppet has supported "solo" mode since 2005
exec puppet $@