Skip to content

Instantly share code, notes, and snippets.

View theacodes's full-sized avatar
🪼
I'm workin on it!

Stargirl Flowers theacodes

🪼
I'm workin on it!
View GitHub Profile
@theacodes
theacodes / logserver.py
Created September 6, 2014 18:29
Gevent based log server
#!/usr/bin/env python
from gevent import monkey
monkey.patch_all()
monkey.patch_sys(stdin=True, stdout=False, stderr=False)
import gevent
from gevent.queue import Queue
import signal
import sys
from socketio.namespace import BaseNamespace
@theacodes
theacodes / echo.py
Created September 6, 2014 17:58
Non-blocking gevent stdin read
#!/usr/bin/env python
from gevent import monkey
monkey.patch_all()
monkey.patch_sys(stdin=True, stdout=False, stderr=False)
import gevent
from gevent.queue import Queue
import sys
import signal
@theacodes
theacodes / appengine_config.py
Created September 2, 2014 22:28
appengine_config.py demonstrating how to properly add vendor packages to sys.path
"""
`appengine_config.py` gets loaded every time a new instance is started.
Use this file to configure app engine modules as defined here:
https://developers.google.com/appengine/docs/python/tools/appengineconfig
"""
def add_vendor_packages(vendor_folder):
"""
@theacodes
theacodes / gist:6753923
Created September 29, 2013 16:17
Memory profiling WSGI middleware
from collections import defaultdict
import gc
class MemoryProfilingMiddleware(object):
def __init__(self, app):
self.app = app
#gc.set_debug(gc.DEBUG_LEAK)
self.last_count = 0