Skip to content

Instantly share code, notes, and snippets.

@chadgh
chadgh / commandline.py
Created June 20, 2012 17:50
simple python module that provides a few useful setups for other command line python scripts. Requires plumbum
#!/usr/bin/python
import sys
import argparse
from plumbum import local, FG, BG
local = local
FG = FG
BG = BG
def getArgParser(program=__file__, desc=''):
@chadgh
chadgh / gist:1027833
Created June 15, 2011 19:05
defines a function to move up X number of directories in bash
updir(){
if [ $# -gt 0 ];then
path=""
for (( i=1; i<=$1; i++ )); do
path=$path"../"
done
cd $path
else
cd ../
fi
@chadgh
chadgh / timer.js
Created April 19, 2011 15:39
A timer utility class for javascript.
function Timer(el, callbackFunction) {
// init the timer
// el - element for time to be updated
// callbackFunction - string of function name to
// be called when the countdown is finished.
this.init = function(el, callbackFunction) {
this.seconds = 0;
this.minutes = 0;
this.counterCaller = null;
this.timer = el;
@chadgh
chadgh / runner.js
Created February 15, 2011 00:41
Bot for Botswana
var Runner = function() {};
Runner.prototype = new Bot("Runner");
Runner.prototype.setup = function() {
this.clicks = 0; // keep track of how many clicks
this.opponent = -1;
this.speed = 2;
this.safety = 7;
};
Runner.prototype.getAngle = function(point) {
dx = 0;
@chadgh
chadgh / Curling.class.php
Created August 24, 2010 17:46
A solution to simplify the use of curl in php
<?php
/**
* @name Curling.class.php
*
* Purpose: encapsulates and simplifies curl functionality
*
* @author Chad G. Hansen
*/
class Curling
{