Skip to content

Instantly share code, notes, and snippets.

import redis
from contextlib import contextmanager
@contextmanager
def redisLock(r, key):
'''
Acquire a lock on a particular key (makes a new mutex key).
This is not meant for very high concurrency, just to avoid
data corruption in simple cases.
'''
# A partial port of http://geewax.org/introducing-appmake to Rake
PYTHON = "python"
APPENGINE = "/usr/local/google_appengine"
APP_ID = "" # replace with your app id
EMAIL = "" # replace with your email address
SERVE_PORT = 9091
SERVE_ADDRESS = "0.0.0.0"
DATASTORE_PATH = "./datastore"
# autocomplete.py - Redis autocomplete example
# download female-names.txt from http://antirez.com/misc/female-names.txt
# Ruby original: http://gist.github.com/574044
# Requires http://github.com/andymccurdy/redis-py/
from redis import Redis
r = Redis()
KEY = 'compl'
import java.io.IOException;
import java.util.Map;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.InputFormat;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.RecordReader;
import org.apache.hadoop.mapreduce.lib.input.LineRecordReader;
import org.apache.pig.LoadFunc;
import org.apache.pig.backend.hadoop.executionengine.mapReduceLayer.PigFileInputFormat;
@jeremi
jeremi / fabfile.py
Created November 4, 2010 21:00
A fabfile to manage git+appengine deployement
from __future__ import with_statement
import functools
import os
import sys
from fabric.api import *
from fabric.colors import green, red, green
import datetime
import re
window.addEventListener "DOMContentLoaded", ->
body = $ "body"
canvas = $ "#canvas"
chalkboard = $ "#chalkboard"
close = $ "#close"
ledge = $ "#ledge"
lightswitch = $ "#lightswitch"
output = $ "#output"
shade = $ "#shade"
share = $ "#share"
@joubertnel
joubertnel / merge_sort.py
Created November 8, 2010 23:45
Merge Sort
def merge(list1, list2):
result = []
index1 = index2 = 0
while index1 < len(list1) and index2 < len(list2):
key1 = list1[index1]
key2 = list2[index2]
if key1 <= key2:
result.append(key1)
index1 += 1
else:
@joshwand
joshwand / What Killed Waterfall could Kill Agile.textile
Created November 22, 2010 23:50
What Killed Waterfall Could Kill Agile.

ganked from unreadable scribd doc here: http://cleancoder.posterous.com/what-killed-waterfall-could-kill-agile

What Killed Waterfall could Kill Agile.

Robert C. Martin
20 Nov, 2010

In 1970 a software engineer named Dr. Winston W. Royce wrote a seminal paper entitled Managing the Development of Large Software Systems. This paper described the software process that Royce felt was appropriate for large-scale systems. As a designer for the Aerospace industry, he was uniquely qualified.

He began the paper by setting up a straw-man process to knock down. He described this naïve process as “grandiose”. He depicted it with a simple diagram on an early page of his paper. Then the paper methodically tears this “grandiose” process apart. In the end, Royce proposed a far more nuanced and insightful approach, leaving the reader to giggle at the silliness of the “grandiose” model.

<?php
namespace app;
include '../config/bootstrap.php';
use \Exception;
use \Http404;
@panesofglass
panesofglass / TcpServer.fsx
Created January 4, 2011 17:43
Asynchronous TCP server in F#
// [snippet: Async socket server using F# async computations.]
open System
open System.IO
open System.Net
open System.Net.Sockets
open System.Threading
type Socket with
member socket.AsyncAccept() = Async.FromBeginEnd(socket.BeginAccept, socket.EndAccept)