Skip to content

Instantly share code, notes, and snippets.

import csv
import StringIO
from twisted.enterprise import adbapi
from twisted.web.server import Site, NOT_DONE_YET
from twisted.web.resource import Resource
from twisted.internet import reactor
from txroutes import Dispatcher
dbpool = adbapi.ConnectionPool('pyodbc', 'connection string')
" General config
set nocompatible
set nowrap
set listchars=tab:>-,trail:-
set list
set showmatch
set autowrite
filetype plugin indent on
syntax on
@steiza
steiza / gist:661539
Created November 3, 2010 19:12
Function decorator factory that takes an argument (for Thrift exception handling)
def create_thrift_exception_wrapper_for_logger(logger_name):
def thrift_exception_wrapper(f):
def wrapped_f(*args, **kwargs):
try:
return f(*args, **kwargs)
except BaseException, e:
if hasattr(e, "thrift_spec"):
import simplejson
try:
from twisted.internet import epollreactor
epollreactor.install()
except ImportError:
pass
from twisted.internet import reactor
from twisted.web.resource import Resource
function reset() {
var dim = 8;
// Set up the playing field
var sheet = SpreadsheetApp.getActiveSheet();
var i = 0;
var columns = ['A', 'B', 'C', 'E', 'F', 'G', 'H', 'I'];
for (i = 0; i < dim; i++) {
import urllib
import simplejson
url = 'http://ec2-184-73-30-219.compute-1.amazonaws.com/create_collage_confetti_json'
params = simplejson.dumps({'width': 146, 'height': 146, 'images': [{'url': 'http://a3.twimg.com/profile_images/112917031/twitterpic2_bigger.png', 'x': 0, 'y': 0, 'width': 73, 'height': 73}, {'
url': 'http://a1.twimg.com/profile_images/67054692/tiny_me_bigger.jpg', 'x': 0, 'y': 73, 'width': 73, 'height': 73}, {'url': 'http://a3.twimg.com/profile_images/576253659/13835_508461253871_146000102_30345328_5589768_n_bigger.jpg', 'x': 73, 'y': 0, 'width': 73, 'height': 73}, {'url': 'http://a3.twimg.com/profile_images/601583591/n2259627_1608_bigger.jpg', 'x': 73, 'y': 73, 'width': 73, 'height': 73}]})
data = urllib.urlopen(url, params).read()
print repr(data)
a = open('a.jpg', 'wb')