Skip to content

Instantly share code, notes, and snippets.

View jeremyBanks's full-sized avatar

Jeremy Banks jeremyBanks

  • Canada
  • 07:12 (UTC -04:00)
View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / README.md
Created September 6, 2009 07:54
[2010-01] simple python script template

This is a template intended for use as the starting point of simple command-line Python scripts. It wraps the main function, passing on the arguments the script was called with and using the function's return value as the exit code. If an invalid number of arguments are provided, it generates and displays a usage string from the function's argument list and docstring.

Here are some examples that should demonstrate exactly how this works.

def main():

@jeremyBanks
jeremyBanks / gist:186509
Created September 14, 2009 04:57
[2010-01] this might have been speciation in very primitive tic-tac-toe bots
GENERATION 0 TOP 4 OF 8 RESULTS
13 fitness, hash 3486bf78
0 1 DUPLICATE -1 2 REVERSE SUB GET 0 EQ NOT 7 IFN 1 ADD -15 RELJUMP
-6 fitness, hash 3486bf60
0 1 DUPLICATE -1 2 REVERSE SUB GET 0 EQ NOT 7 IFN 1 ADD 19 RELJUMP