Skip to content

Instantly share code, notes, and snippets.

View JT5D's full-sized avatar
💭
Multiversing...

JT5D JT5D

💭
Multiversing...
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 / 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 / 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:
@jeremyBanks
jeremyBanks / gist:10970
Created September 16, 2008 01:18
[2010-01] simple example using scp from python
#!/usr/bin/env python
# encoding: utf-8
from __future__ import with_statement
import sys
import subprocess
def scp(source, server, path = ""):
return not subprocess.Popen(["scp", source, "%s:%s" % (server, path)]).wait()
def main(*args):
@jeremyBanks
jeremyBanks / installPytho.bash
Created September 19, 2008 04:55
[2010-01] a script downloading python from svn, they're moving off that
#!/bin/bash
version="${1:-"3.0"}"
release="${2:-"rc1"}"
repository="http://svn.python.org/projects/python/r${version//./}"
directory="python$version$release"
NUL="/dev/null"
if python$version --version &> "$NUL"; then
@kueda
kueda / tmbundle.sh
Created October 14, 2008 16:49
Simple bash script for installing TextMate bundles
#!/bin/bash
tmsupportpath="/Library/Application Support/TextMate"
bundlepath="$tmsupportpath/Bundles"
if [ ! -d "$bundlepath" ]
then
echo "First time, eh? Making $bundlepath..."
mkdir -p "$bundlepath"
fi
if [ ! -d "$tmsupportpath/Support" ]