Skip to content

Instantly share code, notes, and snippets.

View orangle's full-sized avatar
🎯
Focusing

orangleliu orangle

🎯
Focusing
View GitHub Profile
@koenbollen
koenbollen / punch.py
Created July 5, 2010 19:10
Proof of Concept: UDP Hole Punching
#!/usr/bin/env python
#
# Proof of Concept: UDP Hole Punching
# Two client connect to a server and get redirected to each other.
#
# This is the client.
#
# Koen Bollen <meneer koenbollen nl>
# 2010 GPL
#
@TimFletcher
TimFletcher / run_gunicorn.sh
Created September 21, 2010 01:43
Gunicorn Management
#!/bin/sh
# You must have your virtualenv activated to run this script
NAME=gunicorn_timothyfletcher
PID=/home/fire/www/timothyfletcher.com/conf/gunicorn.pid
SETTINGS=/home/fire/www/timothyfletcher.com/timothyfletcher/settings.py
LOGFILE=/home/fire/www/timothyfletcher.com/logs/gunicorn.log
WORKERS=8
BIND_ADDRESS=127.0.0.1:8000
@tmc
tmc / gist:777085
Created January 12, 2011 23:08
multiprocessing gevent chat example
import sys
import gevent
from gevent.monkey import patch_all; patch_all()
from gevent import server, event, socket
from multiprocessing import Process, current_process, cpu_count
"""
Simple multiprocess StreamServer that proxies messages between clients.
Avoids using a multiprocessing.Event since it blocks on a semaphore.
@parente
parente / runinenv.sh
Created February 15, 2011 01:54
run a command in virtualenv, useful for supervisord
#!/bin/bash
VENV=$1
if [ -z $VENV ]; then
echo "usage: runinenv [virtualenv_path] CMDS"
exit 1
fi
. ${VENV}/bin/activate
shift 1
echo "Executing $@ in ${VENV}"
exec "$@"
@jehiah
jehiah / simple_args_parsing.sh
Created March 4, 2011 16:56
a simple way to parse shell script arguments
#!/bin/sh
#
# a simple way to parse shell script arguments
#
# please edit and use to your hearts content
#
ENVIRONMENT="dev"
@rotaris
rotaris / views.py
Created April 22, 2011 01:04
Django-soaplib Hello World Web Service View
# soaplib v2.0.0beta2 (from memory)
# Django v1.3 (stable)
# NOTE: CSRF middleware has been turned off!
# For urls.py, see: https://gist.github.com/935812
import soaplib
from soaplib.core.service import rpc, DefinitionBase
from soaplib.core.model.primitive import String, Integer
from soaplib.core.model.clazz import Array
@randrews
randrews / lua_map.c
Created April 23, 2011 22:16
Example of embedding Lua in C
#include <lua.h>
#include <lauxlib.h>
#include <lualib.h>
#include <stdlib.h>
int map_create(lua_State *lua);
int map_slice(lua_State *lua);
int main(int argc, char **argv){
lua_State *lua = lua_open();
@simonw
simonw / log.lua
Created June 22, 2011 09:28
Query logging for mysql-proxy
--[[
Copyright (C) 2007 MySQL AB
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 of the License.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@ncode
ncode / gsdproxy.py
Created July 10, 2011 16:01
gevent simple dynamic reverse proxy
#!/usr/bin/env python
from gevent import monkey
monkey.patch_all()
import sys
import redis
import urllib2
import traceback
from cgi import escape
# -- gsdproxy
@gwik
gwik / zerologger.py
Created July 10, 2011 18:43
Python logger ZeroMQ, Gevent, CouchDB
# encoding: utf-8
"""
A python logging Handler that use ZeroMQ (ØMQ).
+------+ +------+ +-------+
| app1 | | app2 | | app X |
+------+ +------+ +-------+
| PUSH | PUSH | PUSH
| | |