Skip to content

Instantly share code, notes, and snippets.

View jeremyBanks's full-sized avatar

Jeremy Banks jeremyBanks

  • Canada
  • 17:20 (UTC -04:00)
View GitHub Profile
@jeremyBanks
jeremyBanks / setup.sh
Created July 22, 2009 22:44
[2010-01] script I ran on some servers to aptitude install gcc, python and git
# "curl http://gist.github.com/this | bash" to kick it.
clear
echo AUTOMATED AWESOME BEGINS
echo
aptitude -y install gcc-4.3
aptitude -y install python2.5
aptitude -y install git-core
echo
echo AUTOMATED AWESOME COMPLETE
@jeremyBanks
jeremyBanks / intense_debugging.h
Created May 22, 2009 17:53
[2010-01] some defines to print line numbers for debugging in c
// Won't work if you don't use {]s everywhere.
#define PRINT_ABBREVIATED_FILE_AND_LINE() fprintf(stderr,"[%.3s:%i]", __FILE__ + 2, __LINE__) && fflush(stderr)
#define if PRINT_ABBREVIATED_FILE_AND_LINE(); if
#define for PRINT_ABBREVIATED_FILE_AND_LINE(); for
#define while PRINT_ABBREVIATED_FILE_AND_LINE(); while
#define return PRINT_ABBREVIATED_FILE_AND_LINE(); return
#define free PRINT_ABBREVIATED_FILE_AND_LINE(); free
@jeremyBanks
jeremyBanks / sin_approx.py
Created May 22, 2009 17:28
[2010-01] approximating sine using an identity and knowledge that sin(x) ~= x for small values of x
#!/usr/bin/env python3.0
import sys
from fractions import Fraction
from math import sin, pi
def xsin(x, threshold=.05):
"""Sine approximation."""
if abs(x) < threshold:
return(x)
@jeremyBanks
jeremyBanks / macros.md
Created April 29, 2009 14:39
[2010-01] ramblings on wow druid macros

Notes

  • [mod:shift]
  • [flying] doesn't mean I can fly.
  • This article is a good reference for Druidic stuff.
    • [stance:1] is bear
    • [stance:2] is aquatic
    • [stance:3] is cat
  • [stance:4] is travel
@jeremyBanks
jeremyBanks / mptesting.py
Created February 10, 2009 23:41
[2010-01] i was testing out the multiprocessing module
#!/usr/bin/env python3.0
import sys
import multiprocessing
def process(function, name=None):
"""Decorates a into spawning a new process. Yay clarity."""
def decorated(*args, *kwargs):
p = multiprocessing.Process(target=function, name=name, args=args, kwargs=kwargs)
p.start()
@jeremyBanks
jeremyBanks / linked.c
Created February 5, 2009 17:27
[2009-02] Some stuff I made in April '09 [2010-01] i was a bit of a noob
/*
* linked.c
*
* Generic linked list library.
*
* Please see linked.h for documentation.
*/
#ifndef JB_LINKED_C
#define JB_LINKED_C
@jeremyBanks
jeremyBanks / somesort.py
Created February 5, 2009 16:07
[2010-01] some shitty sort? don't remember what this was for.
#!/usr/bin/env python
# encoding: utf-8
from __future__ import division, with_statement
import sys
import random
def somesort(data):
"""A dumb n**2 sort."""
data = list(data)
result = list()
@jeremyBanks
jeremyBanks / strsub.c
Created February 1, 2009 23:14
[2010-01] goofing around with string substitution
//&>/dev/null;x="${0%.*}";[ ! "$x" -ot "$0" ]||(rm -f "$x";cc -o "$x" "$0")&&"$x" $*;exit
#import <stdio.h>
#import <stdlib.h>
#import <string.h>
typedef struct strpart {
char* start;
int len;
struct strpart* next;
@jeremyBanks
jeremyBanks / logon.bat
Created December 9, 2008 16:57
[2010-01] trying windows "shebang" for python
C:\Python26\python.exe -x logon.bat & exit
# There, this can act as the windows equivilent of a shebang, I guess.
print("Hello world")
@jeremyBanks
jeremyBanks / numberwords.py
Created November 23, 2008 06:52
[2010-01] i meant to code golf numbers to words but failed
#!/usr/bin/env python
# encoding: utf-8
from __future__ import division, with_statement
import sys
# http://stackoverflow.com/questions/309884/code-golf-number-to-words
# http://en.wikipedia.org/wiki/Long_and_short_scales
"""Converts numbers to words using the English short scale."""