- GitHub Staff
- @codysoyland
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.template import Parser, Lexer, Token, Context, TextNode, TOKEN_BLOCK, TOKEN_COMMENT, TOKEN_TEXT, TOKEN_VAR | |
from django.conf import settings | |
LITERAL_DELIMITER = '8====D' | |
class LiteralNode(TextNode): | |
pass | |
def parse(parser): | |
depth = 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
echo "Purging pyc files and empty directories..." | |
# Start from the repository root. | |
cd ./$(git rev-parse --show-cdup) | |
# Delete .pyc files and empty directories. | |
find . -name "*.pyc" -delete 2>&1 > /dev/null & | |
find . -type d -empty -delete 2>&1 > /dev/null & |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import requests | |
import subprocess | |
import re | |
import string | |
import textwrap | |
import argparse | |
def parse_args(): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import functools | |
class memoize(object): | |
def __init__(self, func): | |
self.func = func | |
self.cache = {} | |
def __call__(self, *args): | |
return self.cache_get(args, lambda: self.func(*args)) | |
def __get__(self, obj, objtype): | |
return self.cache_get(obj, lambda: self.__class__(functools.partial(self.func, obj))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-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() -> |