Skip to content

Instantly share code, notes, and snippets.

commit f21a996ff88a09d30e818fc9815f19c055efb215
Author: Erik Kastner <[email protected]>
Date: Wed Oct 6 22:39:46 2010 -0400
work in progress
diff --git a/src/rrd_tool.c b/src/rrd_tool.c
index 4ad80f7..76a3c35 100644
--- a/src/rrd_tool.c
+++ b/src/rrd_tool.c
@dcolish
dcolish / vcs.sh
Created January 6, 2011 00:05
If you use HG or GIT, now you dont need to remember type of repo you're in
function selectvcs() {
case `stat -qn -f "%N" $1/.{git,hg}` in
*.git) echo "git" ;;
*.hg) echo "hg" ;;
//./) exit -1 ;;
*) $(selectvcs "`dirname ${1}`") ;;
esac
}
$(selectvcs $PWD) $@
@hunner
hunner / .gitconfig
Last active September 26, 2016 09:25
Pretty format `git lg`
[alias]
# See http://cat.pdx.edu/~hunner/git-lg.png for an example
lg = "log --decorate --pretty=format:'%C(yellow)%h%C(reset) %C(green)%G?%C(reset) %C(blue)%an%C(reset) %C(cyan)%cr%C(reset) %s %C(auto)%d%C(reset)' --graph --date-order"
C FILE: FIB1.F
PROGRAM FIB1
INTEGER X
X = 12
WRITE(*,*), FIB(X)
END PROGRAM FIB1
FUNCTION FIB(N)
C
C CALCULATE THE NTH FIBONACCI NUMBER
import os
import socket
import sys
import threading
import traceback
class SocketDumper(threading.Thread):
daemon = True
@schmichael
schmichael / runningavg.py
Created October 20, 2011 00:41
Handy script for calculating averages streamed via stdin
#!/usr/bin/env python
import sys
CHUNK = 100
if len(sys.argv) > 1:
CHUNK = int(sys.argv[1])
vals = []
i = 1
# Boto simpy works. Fuck Yeah!
from boto.emr.connection import EmrConnection
from boto.emr.step import JarStep
conn = EmrConnection('<Your Key ID>', '<Your Key>')
froms3 = JarStep(name='cpfroms3', jar='s3://us-east-1.elasticmapreduce/libs/s3distcp/1.0/s3distcp.jar', step_args=['--src', 's3n://cascastro/','--dest', 'hdfs:///tmp/users/'])
@dcolish
dcolish / provision.sh
Created March 4, 2012 06:58
Bootstrap a development minion
#!/bin/bash
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Use this with something like
# Vagrant::Config.run do |config|
# config.vm.box = "lucid32"
# config.vm.forward_port 22, 2223
# config.vm.forward_port 80, 8080
import random
empty = None
color, left, root, right, red, black = range(6)
rbnode = lambda c, l, t, r: {color: c, left: l, root: t, right: r}
def member(x, tree):
if tree == empty:
# Inplace quicksort in python
from functools import partial
import operator
import random
import time
def partition(list_, l, r, p):
pVal = list_[p]
list_[p], list_[r] = list_[r], list_[p]