Skip to content

Instantly share code, notes, and snippets.

View witsch's full-sized avatar
💭
204 No Content

Andreas Zeidler witsch

💭
204 No Content
View GitHub Profile
First you want a version of `git` that comes with the bash completion script
installed. Of course, you could also download the `current version
<https://github.com/git/git/blob/master/contrib/completion/git-completion.bash>`_
and store it somewhere (e.g. in `~/.bash/`), but using the `git-core` port
from `MacPorts <http://www.macports.org/>`_ or a the binaries available at the
`Git home page <http://git-scm.com/>`_ has the advantage of (very likely)
giving you a more recent version. In the case of MacPorts_ you would run::
$ sudo port install git-core +bash_completion
@witsch
witsch / .pdbrc
Created September 23, 2011 18:21
Previewing `browser.contents` in Pdb
# 'preview' support for browser tests
alias preview import os, tempfile; out = tempfile.NamedTemporaryFile(mode='w', suffix='.html'); print >> out, browser.contents; out.flush(); _ = os.system("open '%s'" % out.name)
@witsch
witsch / pythontidy.xml
Created September 25, 2011 13:07
Configuration file for PythonTidy
<config>
<parm name="COL_LIMIT" value="int(79)" />
<parm name="SHEBANG" value="" />
<parm name="PARENTHESIZE_TUPLE_DISPLAY" value="bool(False)" />
<parm name="ADD_BLANK_LINES_AROUND_COMMENTS" value="bool(False)" />
<parm name="ADD_BLANK_LINE_AFTER_DOC_STRING" value="bool(False)" />
<parm name="MAX_SEPS_FUNC_DEF" value="int(99)" />
<parm name="MAX_SEPS_FUNC_REF" value="int(99)" />
<parm name="WRAP_DOC_STRINGS" value="bool(True)" />
<parm name="NORMALIZE_DOC_STRINGS" value="bool(True)" />
@witsch
witsch / Makefile
Last active September 27, 2015 12:28
convenience Makefile for the "collective" Python buildout
# set up python buildout & development tools
version = 2.7
python = bin/python$(version)
defaults = bin/python bin/virtualenv
tools = buildout pep8 pyflakes mkrelease checkversions igor pytest tox devpi
namespace =
all: $(defaults) $(tools)
@witsch
witsch / formtest.py
Created February 27, 2012 22:14
dynamic forms on deform
from colander import MappingSchema, SchemaNode, String
from deform import Form
def magnet(schema):
def decorator(node):
for child in node().children:
schema.add(child)
return node
return decorator
@witsch
witsch / waitfor.py
Created May 9, 2012 10:41
helper script to wait until some process is listening to a given TCP port
#!/usr/bin/python
from socket import socket, gethostbyname, AF_INET, SOCK_STREAM
from sys import argv, exit
from time import sleep
def waitfor(*ports, **kw):
timeout = kw.get('timeout', 30)
host = kw.get('host', 'localhost')
@witsch
witsch / render.py
Created May 25, 2012 08:19
lookup and render a given path from inside a view etc
from tribaspace.router import Router
path = '/foo/bar'
newreq = Request.blank(path=path, base_url=request.application_url)
newreq.registry = registry
markup = Router(registry).handle_request(newreq)
print markup.body
@witsch
witsch / metafoo.py
Last active December 18, 2015 01:49
metaclass prototype for collecting https://github.com/tomster/ezjail steps & stages
from operator import attrgetter
def counter():
count = 0
while True:
yield count
count += 1
@witsch
witsch / conftest.py
Created August 16, 2013 12:56
example pytest session fixture reordering the tests
from pytest import fixture, Class
@fixture(scope="session", autouse=True)
def sort_tests_by_class_name(request):
session = request.node
key = lambda item: item.getparent(Class).obj.__name__
session.items[:] = sorted(session.items, key=key)
@witsch
witsch / net.devpi.devpi-server.plist
Created August 17, 2013 13:28
run `devpi-server` (http://devpi.net/) using `launchd` on OSX
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>KeepAlive</key>
<true/>
<key>Label</key>
<string>com.devpi.devpi-server</string>
<key>ProgramArguments</key>
<array>