Skip to content

Instantly share code, notes, and snippets.

View jeremyBanks's full-sized avatar

Jeremy Banks jeremyBanks

  • Canada
  • 23:09 (UTC -04:00)
View GitHub Profile
@jeremyBanks
jeremyBanks / defenders.py
Created September 8, 2008 17:27
[2010-01] i script i made to buy defenders in mysqlgame, I guess
#!/usr/bin/env python
# encoding: utf-8
from __future__ import division, with_statement
import sys, os
import httplib2
request = httplib2.Http().request
def main():
queryURL = "http://mysqlgame2.appspot.com/update/queries"
@jeremyBanks
jeremyBanks / class.py
Created September 10, 2008 20:52
[2010-01] me noobing out with python
#!/usr/bin/env python
# encoding: utf-8
# Experimenting with creating a class without using the class statement.
# The classes MyA and MyB should be equivalent.
class MyA(object):
x = 5
def xAndHam(self):
@jeremyBanks
jeremyBanks / logo.py
Created September 11, 2008 02:34
[2010-01] oh ha, this is the script I used to generate the old avatar/logo, the one of my contact card
#!/usr/bin/env python
# encoding: utf-8
import Image
generations = [
0x18,
0x24,
0x7E,
0x81,
0x42,
@jeremyBanks
jeremyBanks / joinStrings.c
Created September 12, 2008 09:17
[2010-01] I guess I was trying string contactenation in C
//&>/dev/null;x="${0%.*}";[ ! "$x" -ot "$0" ]||(rm -f "$x";cc -o "$x" "$0")&&"$x" $*;exit
#import <stdio.h>
#import <stdlib.h>
char* joinStrings(char** strings, int numStrings, char* seperator) {
// Handle empty case which would cause problems.
if (numStrings == 0)
return "";
@jeremyBanks
jeremyBanks / variables.py
Created September 12, 2008 16:24
[2010-01] getting names of variable at run-time in python
#!/usr/bin/env python
# encoding: utf-8
from __future__ import division, with_statement
import sys
# Demonstrating a crude method of determining a variable's names/labels.
def main():
def getVariableNames(variable, globals, locals):
variables = {}
@jeremyBanks
jeremyBanks / python
Created September 13, 2008 20:12
[2010-01] my minor tweaks to textmate's python syntax
{ scopeName = 'source.python';
comment = '
todo:
list comprehension / generator comprehension scope.
';
firstLineMatch = '^#!/.*\bpython\b';
fileTypes = ( 'py', 'rpy', 'cpy', 'SConstruct', 'Sconstruct', 'sconstruct', 'SConscript' );
foldingStartMarker = '^\s*(def|class)\s+([.a-zA-Z0-9_ <]+)\s*(\((.*)\))?\s*:|\{\s*$|\(\s*$|\[\s*$|^\s*"""(?=.)(?!.*""")';
foldingStopMarker = '^\s*$|^\s*\}|^\s*\]|^\s*\)|^\s*"""\s*$';
@jeremyBanks
jeremyBanks / .gitignore
Created September 13, 2008 21:01
Drawing the Koch snowflake!
*.pyc
.DS_Store
@jeremyBanks
jeremyBanks / app.c
Created September 14, 2008 18:55
[2010-01] my basic textmate templates for c and python
//&>/dev/null;x="\${0%.*}";[ ! "\$x" -ot "\$0" ]||(rm -f "\$x";cc -o "\$x" "\$0")&&"\$x" \$*;exit
#import <stdio.h>
int main(int argc, char* argv[]) {
${1:printf("${2:Hello, world!}\n"$3);}
return 0;
}
@jeremyBanks
jeremyBanks / gist:10763
Created September 14, 2008 20:50
[2010-01] finding the point to make an equilaterial trangle with a line segment, i was figuring out for fractical triangle khoh curve or whatever
"""
The equation of the line segment near A is
y = a.y + (x - a.x) * slopeA
The equation of the line segment near B is
y = b.y + (x - b.x) * slopeB
Isolate x in the system;
@jeremyBanks
jeremyBanks / reCache.py
Created September 15, 2008 18:30
A simple class to cache previously-compiled regular expressions.
#!/usr/bin/env python
# encoding: utf-8
import re
class reCache(object):
def __init__(self):
self.cache = {}
def getPattern(self, pattern, flags=0):
try: