Skip to content

Instantly share code, notes, and snippets.

@xythian
xythian / keybase.md
Created October 4, 2017 23:59
keybase.md

Keybase proof

I hereby claim:

  • I am xythian on github.
  • I am xythian (https://keybase.io/xythian) on keybase.
  • I have a public key ASBlMexDfwwmok-EX3ErTcktq9CYxSna6bHJTbx1UlgDCgo

To claim this, I am signing this object:

@xythian
xythian / gist:1906356
Created February 25, 2012 04:01
a snippet of contextmanager + WSGI middleware for an approach for db txns
@contextmanager
def connect():
db = psycopg2.connect(**DATABASE_CONFIG)
cur = db.cursor()
cur.execute("SET search_path TO wordshot,public")
del cur
try:
yield db
except:
db.rollback()
@xythian
xythian / gist:1066569
Created July 6, 2011 04:32
fabric snippet to build zmq and mongrel2 and install them
def install_web_server(profile=REMOTE):
profile.sudo("apt-get install checkinstall libsqlite3-dev uuid-dev sqlite3")
with profile.cd(SERVER_STAGE):
profile.run("wget http://mongrel2.org/static/downloads/mongrel2-1.7.5.tar.bz2")
profile.run("tar xjf mongrel2-1.7.5.tar.bz2")
profile.run("wget http://download.zeromq.org/zeromq-2.1.7.tar.gz")
profile.run("tar xzf zeromq-2.1.7.tar.gz")
with profile.cd(os.path.join(SERVER_STAGE, 'zeromq-2.1.7')):
profile.run("./configure")
profile.run("make")