This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from decorator import decorator | |
import types | |
@decorator | |
def hello_printer(f, *args, **kwargs): | |
print "Hello World" | |
return f(*args, **kwargs) | |
def testing(name, bases, dict): | |
for key, value in dict.iteritems(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<VirtualHost 65.19.178.50> | |
ServerName www.toomuchthe.com | |
ServerAlias toomuchthe.com | |
DocumentRoot /domains/toomuchthe | |
<Directory /domains/toomuchthe> | |
Options ExecCGI Indexes SymLinksIfOwnerMatch | |
AllowOverride All | |
</Directory> | |
ProxyRequests Off | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this works | |
/usr/bin/gcc-4.0 -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.4.0 -I. -DHAVE_SYS_UN_H -DHAVE_SOCKET -DHAVE_GETHOSTNAME -DHAVE_PQSETCLIENTENCODING -DHAVE_PG_ENCODING_TO_CHAR -DHAVE_PQESCAPESTRING -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/opt/local/include -fno-common -I/opt/local/include/postgresql83 -c postgres.c | |
# this is what gem is trying to do. it doesn't work. | |
/usr/bin/gcc-4.0 -I. -I. -I/opt/local/lib/ruby/1.8/i686-darwin9.4.0 -I. -DHAVE_LIBPQ_FE_H -DHAVE_LIBPQ_LIBPQ_FS_H -DHAVE_PQSETCLIENTENCODING -DHAVE_PG_ENCODING_TO_CHAR -DHAVE_PQFREEMEM -DHAVE_PQESCAPESTRING -DHAVE_PQEXECPARAMS -I/opt/local/include/postgresql83 -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -I/opt/local/include -fno-common -O2 -fno-common -pipe -fno-common -Wall -c postgres.c | |
# gem command line: gem install ruby-postgres -- --with-pgsql-include-dir=/opt/local/include/postgresql83 --with-pgsql-lib-dir=/opt/local/lib/postgresql83 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jon@euterpe:~$ pyinstall.py | |
Traceback (most recent call last): | |
File "/Library/Frameworks/Python.framework/Versions/Current/bin/pyinstall.py", line 5, in <module> | |
pkg_resources.run_script('pyinstall==0.1', 'pyinstall.py') | |
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg/pkg_resources.py", line 448, in run_script | |
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/setuptools-0.6c8-py2.5.egg/pkg_resources.py", line 1166, in run_script | |
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/pyinstall-0.1-py2.5.egg/EGG-INFO/scripts/pyinstall.py", line 102, in <module> | |
help='Check out --editable packages into DIR (default %s)' % base_src_prefix) | |
NameError: name 'base_src_prefix' is not defined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import types | |
def build_tree(start_point=None): | |
if start_point is not None and type(start_point) is not types.ModuleType: | |
print "start_point is not None (meaning use globals) and is not a module" | |
check = [start_point] | |
checked = set() | |
tree = {} | |
while len(check) > 0: | |
current = check.pop(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ImportPrinter(object): | |
def __init__(self): | |
record = set() | |
self.install() | |
def install(self): | |
import sys | |
sys.meta_path.insert(0, self) | |
def find_module(self, fullname, path=None): | |
record.append(fullname) | |
return None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SwitchingMethod(object): | |
"""This decorator turns a method into a classmethod, | |
but only when it's being called from the class; | |
it still works perfectly from the instance.""" | |
def __init__(self, f): | |
self.f = f | |
def __get__(self, obj, klass=None): | |
if obj is None: | |
return classmethod(self.f).__get__(obj, klass) | |
return self.f.__get__(obj, klass) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
channel event | |
messages | |
newsboy | |
speech | |
to | |
quotation | |
emote | |
to | |
thoughtbubble | |
emits (in practice, emits are usually mimicking speech, quotations, emotes, and so on. but I think it's best to just treat it as unstructured text for now) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from mako.template import Template | |
from mako.lookup import TemplateLookup | |
import os | |
import os.path | |
cwd = os.getcwd() | |
template_path = os.path.join(cwd, 'templates') | |
mylookup = TemplateLookup(directories=[template_path]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this uses the raw SQL expression language and Table objects. remember to adjust your imports as necessary. | |
q2 = sa.select([model.users_table.c.user_id]).where(model.users_table.c.name == 'Tom') | |
q1 = model.users_table.select().where(sa.not_(model.users_table.c.user_id.in_(q2))) | |
# this builds a query like so: | |
# >>> print q1 | |
# SELECT users.user_id, users.name, users.address, users.is_staff | |
# FROM users | |
# WHERE users.user_id NOT IN (SELECT users.user_id | |
# FROM users |
OlderNewer