Skip to content

Instantly share code, notes, and snippets.

Version = 5
Booleans = {'caretLineVisible': True, 'preferFixed': True, 'useSelFore': True}
CommonStyles = {'attribute name': {'fore': 13236445},
'attribute value': {'fore': 3100463},
'bracebad': {'back': 6710886, 'bold': 1, 'fore': 13421823},
'bracehighlight': {'bold': 1, 'fore': 16777215},
'classes': {'fore': 8578762},
'comments': {'fore': 10066329, 'italic': False},
@tmc
tmc / gevent_poc.py
Created October 25, 2011 15:41 — forked from jmoiron/gevent_poc.py
gevent + zmq + multiprocessing poc
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""Simple gevent POC to check how to get ZMQ sockets working with
subprocesses spawned by a simple process."""
# this code doesn't seem to work properly; it has a
# tendency to hang at various parts of the req/rep process
# all of this stuff works flawlessly if you change:
travis@lappie:/usr/local/src/eio(master)$ time python perf_test.py
other greenlet running!
reading 50 megs from /dev/urandom
done.
real 0m4.656s
user 0m0.031s
sys 0m4.624s
@tmc
tmc / gist:1052254
Created June 28, 2011 21:22
gitify stunnel
#!/bin/bash
rsync -av rsync.stunnel.org::stunnel stunnel_clone
cd stunnel_clone
mkdir tmp
cp -p obsolete/*/*tar.gz tmp/
cp *.tar.gz tmp/
cd tmp
(
cat <<'EOF'
$ cat > ~/bin/TODO
#!/bin/sh
open ~/Desktop/TODO.rtf
^C
$ cd /usr/local/src/
$ git clone git://abackstrom.com/appify.git
$ cd appify/
$ sh appify.sh ~/bin/TODO ~/bin/TODO.app
@tmc
tmc / gist:828606
Created February 16, 2011 00:31
pyqt gevent compat example
diff --git a/session1/main.py b/session1/main.py
index 93a204c..6508d12 100644
--- a/session1/main.py
+++ b/session1/main.py
@@ -3,6 +3,7 @@
"""The user interface for our app"""
import os,sys
+import gevent
@tmc
tmc / gist:828553
Created February 15, 2011 23:56
fixed up backbone example
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Backbone example</title>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="underscore.js"></script>
<script type="text/javascript" src="backbone.js"></script>
@tmc
tmc / gist:787105
Created January 19, 2011 23:29
gevent nonblocking stdin
import os
import sys
import fcntl
import gevent
from gevent.socket import wait_read
def print_every(s, repeat=1):
print s
if repeat:
"""The :mod:`zmq` module wraps the :class:`Socket` and :class:`Context` found in :mod:`pyzmq <zmq>` to be non blocking
"""
__zmq__ = __import__('zmq')
from gevent.hub import _threadlocal
from gevent.socket import wait_read, wait_write
__patched__ = ['Context', 'Socket']
globals().update(dict([(var, getattr(__zmq__, var))
for var in __zmq__.__all__
if not (var.startswith('__')
@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.