Skip to content

Instantly share code, notes, and snippets.

# Zope2 functional testing using Twill
import sys
from StringIO import StringIO
import twill
from ZPublisher.Response import Response
from ZPublisher.Test import publish_module
from Testing import ZopeTestCase
<!--
Scroogle (http://scroogle.org/) is an anonymous proxy to Google search.
Their front page is ugly; this minimal html file is an alternative interface.
-->
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>scroogle</title>
<style>
body { text-align: center; }
#!/usr/bin/env python
""" Serve WSGI requests via inetd / launchd """
import sys
import socket
from StringIO import StringIO
from wsgiref.simple_server import WSGIServer, make_server
class InetdWSGIServer(WSGIServer):
"""
#!/usr/bin/env python
# recursively back up a folder using hard links
# Alex Morega, Eau de Web
import os
from optparse import OptionParser
parser = OptionParser()
parser.add_option("-n", "--dry-run", action="store_true", dest="dry_run", default=False,
#!/bin/bash
echo -ne "\033]0;"`hostname`"\007"
#!/usr/bin/env python
#
# $Id: czoink.py 11 2008-06-18 23:44:45Z respawned $
#
# Copyright (c) 2008 Respwaned Fluff <[email protected]>
#
# Permission is hereby granted, free of charge, to any person
# obtaining a copy of this software and associated documentation
# files (the "Software"), to deal in the Software without
# restriction, including without limitation the rights to use,
# TinyCache
# simple object cache based on Durus (http://www.mems-exchange.org/software/durus/)
# provides multiple named cache pools; no expiration of entries
import logging
from cStringIO import StringIO
durus_log_file = StringIO()
durus_logger = logging.getLogger('durus')
durus_logger.addHandler(logging.StreamHandler(durus_log_file))
# wsgiapp.py - tiny web service wrapper. URL dispatch; req/resp objects; logging; static
# files, genshi templates, json and repr data; plays nice with mod_wsgi. 99 lines of code.
# http://grep.ro/blog/2009/06/python_web_service
from os import path
app_root_fspath = path.dirname(__file__)
# mod_wsgi: we need the virtualenv site-packages, and our current folder, on sys.path
import site
site.addsitedir(path.join(app_root_fspath,
#!/usr/bin/env python
# invoke repozo to back up a ZODB filestorage database
import os
from os import path
from datetime import datetime, date
from ConfigParser import SafeConfigParser
from subprocess import Popen, PIPE, STDOUT
def parse_config(cfg_path):
#!/usr/bin/env python
""" Read a tab-separated CSV file and print its contents, padding values so
they align into pretty columns. """
import csv
from collections import defaultdict
from optparse import OptionParser
option_parser = OptionParser()
option_parser.add_option("-e", default="utf-8", dest="encoding")