Skip to content

Instantly share code, notes, and snippets.

View pilosa-pulls.py
#!/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 (
"log"
"net/http"
"github.com/gorilla/websocket"
)
func main() {
@codysoyland
codysoyland / prime_sieve.py
Last active Apr 23, 2017
A prime number generator using Python generators, inspired by concurrent prime sieve at http://play.golang.org/p/9U22NfrXeq
View prime_sieve.py
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
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!
http://railsenvy.com/2007/9/10/ruby-on-rails-vs-django-commercial-7
The Whistles
http://www.youtube.com/watch?v=ccgXjA2BLEY
Do it live!
http://www.youtube.com/watch?v=2tJjNVVwRCY
REMIX: http://www.youtube.com/watch?v=5j2YDq6FkVE&NR=1
@codysoyland
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):
pass
class Handler(object):
def __init__(self, cache, socket, address):
self.cache = cache
View virtualenv-auto-activate.sh
#!/bin/bash
# virtualenv-auto-activate.sh
#
# Installation:
# Add this line to your .bashrc or .bash-profile:
#
# source /path/to/virtualenv-auto-activate.sh
#
# 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
codysoyland / gateway.sh
Created Jan 11, 2012
fabric gateway script
View gateway.sh
#!/bin/sh
echo $* | ssh gateway "cat > /tmp/fab-runner; chmod +x /tmp/fab-runner"
ssh gateway -t screen bash -init-file /tmp/fab-runner
# Usage: gateway.sh fab production deploy
@codysoyland
codysoyland / riak_zmq.erl
Created Aug 23, 2011
Riak postcommit ZeroMQ publisher
View riak_zmq.erl
-module(riak_zmq).
-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
codysoyland / temporary_settings.py
Created Jun 21, 2011
Context manager for monkey-patching django settings (useful in unit tests)
View temporary_settings.py
# 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
@contextmanager
def temporary_settings(**temp_settings):
orig_settings = {}
View socketproxy.py
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.