Skip to content

Instantly share code, notes, and snippets.

View christabor's full-sized avatar
😅
I may be slow to respond.

Chris Tabor christabor

😅
I may be slow to respond.
View GitHub Profile
@christabor
christabor / pythondecorators
Created September 9, 2014 22:40
Some uses for python decorators?
class Db():
def __init__(self):
self.foo = 'FOO'
def save(self, msg, *args, **kwargs):
print 'Saving... {}'.format(msg)
class RemoteTransport():
def __init__(self):
@christabor
christabor / randomgibberish-py
Last active August 29, 2015 14:06
random gibberish text generator
from string import ascii_lowercase
from random import choice
def long_word(max):
return ''.join([choice(ascii_lowercase + ' ') for _ in xrange(max)])
1 1 36 1 0
2 69 36 33 1
3 4761 36 9 0
4 328509 36 9 1
5 22667121 36 9 1
6 1564031349 36 9 3
7 107918163081 36 9 1
8 7446353252589 36 9 5
9 513798374428641 36 9 0
10 35452087835576229 36 9 9
@christabor
christabor / ca-generator
Last active August 29, 2015 14:06
Random rules for Cellular Automata in python
from random import choice
from pprint import pprint as ppr
def rule(n, choices):
pattern = ''
for x in range(n):
pattern += choice(choices)
return pattern
@christabor
christabor / gist:761443715961c6afeb30
Created October 5, 2014 21:54
Raphael nodejs shim
// Shim for Raphael
Raphael = (typeof module !== 'undefined' && module.exports) ? require('node-raphael') : Raphael;
//...lib stuff
@christabor
christabor / dropwhile
Created October 8, 2014 07:43
dropwhile
import itertools
def is_odd_exp(n):
print n, 'exp mod 2 =', n ** n % 2
if n ** n % 2 == 0:
return False
return True
function PI() {
echo 'Fuck PHP';
echo 'Also, use radians for chrissake';
}
@christabor
christabor / gist:ed706b4330b180b4bc27
Created January 5, 2015 22:02
python magic methods
class Database(object):
def __init__(self):
self.data = {}
def insert(self, key, val):
print 'Making db insertion....'
self.data[key] = val
@christabor
christabor / regex-find-replace-sublime
Last active August 29, 2015 14:13
Sublime global find + replace regex
(notice space at the end of each!)
Find: ([a-zA-Z]+)='(.+)'
Replace with: \1="\2"
Fixes any single quote ids/classes/html attributes (eg. name='foo-bar' -> name="foo-bar", name='{{ foo._bar(bim) }}' -> name="{{ foo._bar(bim) }}")
@christabor
christabor / sublime git editor mac
Created February 3, 2015 17:42
Fix Sublime git editor association (mac)
# Fallback for this issue, when using
# http://www.sublimetext.com/docs/3/osx_command_line.html and https://help.github.com/articles/associating-text-editors-with-git/
# `subl -n -w: subl: command not found`
# `error: There was a problem with the editor 'subl -n -w'.`
# `Please supply the message using either -m or -F option.`
git config --global core.editor "subl -n -w" || git config --global core.editor "~/bin/subl -n -w"