Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env python
import requests
import subprocess
import re
import string
import textwrap
import argparse
def parse_args():
View websockets.go
package main
import (
func main() {
codysoyland /
Last active Apr 23, 2017
A prime number generator using Python generators, inspired by concurrent prime sieve at
from itertools import count
def filter(input, prime):
for i in input:
if i % prime:
yield i
def get_primes(num):
g = count(2)
for _ in xrange(num):
codysoyland / requiredreading.txt
Created Jul 6, 2012 — forked from adamfast/requiredreading.txt
Preserved for #lawrence history, this was the "required reading" list of totally-non-work-related inside jokes of the World Online crew.
View requiredreading.txt
DJ Ango, yo!
The Whistles
Do it live!
codysoyland / gist:2505907
Created Apr 27, 2012
stupid gevent memcache server
View gist:2505907
from gevent.server import StreamServer
#import gevent
import time
class ClientDisconnected(Exception):
class Handler(object):
def __init__(self, cache, socket, address):
self.cache = cache
# Installation:
# Add this line to your .bashrc or .bash-profile:
# source /path/to/
# Go to your project folder, run "virtualenv .venv", so your project folder
# has a .venv folder at the top level, next to your version control directory.
codysoyland /
Created Jan 11, 2012
fabric gateway script
echo $* | ssh gateway "cat > /tmp/fab-runner; chmod +x /tmp/fab-runner"
ssh gateway -t screen bash -init-file /tmp/fab-runner
# Usage: fab production deploy
codysoyland / riak_zmq.erl
Created Aug 23, 2011
Riak postcommit ZeroMQ publisher
View riak_zmq.erl
-export([postcommit_publish/1, get_zmq_publisher/0, zmq_publisher/0, zmq_publisher/1]).
postcommit_publish(RObj) ->
Body = riak_object:get_value(RObj),
{ok, Pid} = get_zmq_publisher(),
Pid ! {send, Body}.
get_zmq_publisher() ->
codysoyland /
Created Jun 21, 2011
Context manager for monkey-patching django settings (useful in unit tests)
# Example usage:
# with temporary_settings(CELERY_ALWAYS_EAGER=True):
# run_task.delay() # runs task with eager setting enabled.
from contextlib import contextmanager
from django.conf import settings
def temporary_settings(**temp_settings):
orig_settings = {}
import gevent
from gevent.server import StreamServer
from gevent.pool import Group
from gevent_zeromq import zmq
context = zmq.Context()
class CodependentGroup(Group):
A greenlet group that will kill all greenlets if a single one dies.
You can’t perform that action at this time.