Skip to content

Instantly share code, notes, and snippets.

View mikewaters's full-sized avatar

Mike Waters mikewaters

  • Dealertrack
View GitHub Profile
@mpasternacki
mpasternacki / pingfcgi.sh
Created October 13, 2009 18:40
Ping FCGI server, using cgi-fcgi program from libfcgi library.
#!/bin/sh
set -e
# Ping FCGI server. Uses cgi-fcgi program from libfcgi library.
# Retrieves the root path (/) from host:port specified on command line.
if [ -z "$1" ] ; then
echo "Usage: $0 host:port|path/to/socket" >&2
exit 1
fi
#!/bin/sh
# Start/stop the named twistd application
#
APP=/opt/myapp/myapp.py
TWISTD=/usr/bin/twistd
PID=/var/run/myapp.pid
LOGFILE=/var/log/myapp/myapp.log
DESCRIPTION="Super duper Twisted apptacularness!"
NAME=myapp
from flask import Flask, request
from gevent.event import AsyncResult
from gevent.wsgi import WSGIServer
app = Flask(__name__)
waiters = []
@app.route("/")
def main():
@miku
miku / 4956984-1.py
Created February 10, 2011 13:16
How do you split a csv file into evenly sized chunks in Python?
#!/usr/bin/env python
# import csv
# reader = csv.reader(open('4956984.csv', 'rb'))
def gen_chunks(reader, chunksize=100):
"""
Chunk generator. Take a CSV `reader` and yield
`chunksize` sized slices.
"""
@mahmoudimus
mahmoudimus / nose-timetests.py
Last active April 6, 2016 16:36
Nose plugin to time tests
"""This plugin provides test timings to identify which tests might be
taking the most. From this information, it might be useful to couple
individual tests nose's `--with-profile` option to profile problematic
tests.
This plugin is heavily influenced by nose's `xunit` plugin.
Add this command to the way you execute nose::
--with-test-timer
@stefanfoulis
stefanfoulis / osx_developer_installation.rst
Last active December 10, 2024 19:25
Instructions on how to setup an OSX developer machine for (python/django) development

OSX Developer System installation

This guide assumes a fresh install of Mac OSX 10.7 Lion.

Brew User

@coopernurse
coopernurse / limit.py
Created April 8, 2011 22:32
gevent concurrency test script
#!/usr/bin/env python
import sys
import gevent
from gevent import Greenlet
from gevent.pool import Pool
from gevent.server import StreamServer
from gevent.socket import create_connection
bind_addr = '127.0.0.1'
@kastner
kastner / graph.html
Created May 3, 2011 23:00
Draw an rrdtool style graph with canvas
<!doctype html>
<html>
<head>
</head>
<body>
<!doctype html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
@denik
denik / ServerRack.py
Created June 5, 2011 09:31
class for managing multiple servers in gevent
# Class for managing multiple servers or anything with start() and stop() methods
class ServerRack(object):
def __init__(self, servers):
self.servers = servers
def start(self):
started = []
try:
@rincewind
rincewind / version.py
Created June 14, 2011 23:22 — forked from dcreager/version.py
Extract a setuptools version from the git repository
# -*- coding: utf-8 -*-
# Author: Douglas Creager <[email protected]>
# This file is placed into the public domain.
# Calculates the current version number. If possible, this is the
# output of “git describe”, modified to conform to the versioning
# scheme that setuptools uses. If “git describe” returns an error
# (most likely because we're in an unpacked copy of a release tarball,
# rather than in a git working copy), then we fall back on reading the
# contents of the RELEASE-VERSION file.