This file contains hidden or 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 FooManager(object): | |
| def __init__(self, data, trys_left=3): | |
| self.data = data | |
| self.trys_left = trys_left | |
| def __enter__(self): | |
| return self | |
| def badfunc(self): |
This file contains hidden or 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
| function selectvcs() { | |
| case `stat -qn -f "%N" $1/.{git,hg}` in | |
| *.git) echo "git" ;; | |
| *.hg) echo "hg" ;; | |
| //./) exit -1 ;; | |
| *) $(selectvcs "`dirname ${1}`") ;; | |
| esac | |
| } | |
| $(selectvcs $PWD) $@ |
This file contains hidden or 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 ast import Name, NodeTransformer, parse, Return | |
| from itertools import chain | |
| import sys | |
| from warnings import warn | |
| class StaticTransformer(NodeTransformer): | |
| def _check_none(self, x): | |
| if isinstance(x, Name) and x.id == 'None': |
This file contains hidden or 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 urlparse import urljoin | |
| from google.appengine.ext import webapp | |
| from google.appengine.ext.webapp import util, WSGIApplication | |
| class Bouncer(webapp.RequestHandler): | |
| def __init__(self, mapping=()): | |
| super(Bouncer, self).__init__(self) |
This file contains hidden or 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
| SWIG=../../swig/preinst-swig | |
| INCLUDE=-I. -I./../generic $(shell xapian-config --cxxflags) | |
| LINK=$(shell xapian-config --libs) | |
| all: static | |
| static: libs | |
| ocamlc -pp "camlp4o ./swigp4.cmo" -c smoketest.ml | |
| ocamlfind ocamlc -g -ccopt -g -cclib \ | |
| -g -custom -o smoketest \ |
This file contains hidden or 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 xmlrpclib | |
| client = xmlrpclib.ServerProxy('http://pypi.python.org/pypi') | |
| packages = client.search({'summary': 'simple printer of nested lists'}) | |
| header = ''.join(['-'] * 80) | |
| for package in packages: | |
| print """{header} | |
| {name} - {version}: {summary}""".format(header=header, **package) | |
| print header |
This file contains hidden or 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
| #!/bin/bash | |
| RUN_SQL?="$(which psql) i3" | |
| function _info(){ | |
| echo "At migration version: $(cat .migration-version)" | |
| } | |
| function _init() { | |
| echo 0 > .migration-version |
This file contains hidden or 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 collections import namedtuple | |
| from os import unlink | |
| from os.path import join as pjoin | |
| from subprocess import PIPE, Popen | |
| class Path(object): | |
| def __init__(self, pathname): | |
| self.pathname = pathname |
This file contains hidden or 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 Foo(object): | |
| def __repr__(self): | |
| return "<Silly Human, I'm not real>" | |
| def __eq__(self, b): | |
| return True | |
| def __getattr__(self, meh): | |
| return Foo() |
This file contains hidden or 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 imp | |
| import sys | |
| class ErrorlessImport(object): | |
| def find_module(self, name, path): | |
| try: | |
| return imp.find_module(name, path) | |
| except ImportError: |