Skip to content

Instantly share code, notes, and snippets.

View josiahcarlson's full-sized avatar

Josiah Carlson josiahcarlson

View GitHub Profile
'''
redis_search.py
Written by Josiah Carlson July 3, 2010
Released into the public domain.
This module implements a simple TF/IDF indexing and search algorithm using
Redis as a datastore server. The particular algorithm implemented uses the
'''
Copyright 2010 Josiah Carlson
Released into the public domain
copy_redis.py
A convenient utility function for copying data from one redis server to
another.
Requires http://github.com/andymccurdy/redis-py .
'''
Copyright 2010 Josiah Carlson
Released into the public domain
alternate_tile.py
This will generate the integer-grid tiles of a provided polygon, similar in
fashion to Polygon.Util.tile(), though this uses a BSP-like algorithm to
partition the space for faster overall execution on large polygons with many
tiles.
@josiahcarlson
josiahcarlson / simple_svn2git.py
Created November 22, 2010 07:42
Convert PyPE's svn repository to git
'''
simple_svn2git.py
Written November 2010 by Josiah Carlson, released into the public domain.
This script was used to convert PyPE's svn repository on sourceforge to git.
Setup included checking out/cloning the two repos:
svn co https://pype.svn.sourceforge.net/svnroot/pype pype
# Josiah Carlson - Programming Challange from Erann Gat:
# http://www.flownet.com/ron/papers/lisp-java/
# Given a list of words and a list of phone numbers, find all the ways that
# each phone number can be expressed as a list of words.
from collections import defaultdict
import sys
MAPPING = {'e':0, 'j':1, 'n':1, 'q':1, 'r':2, 'w':2, 'x':2, 'd':3, 's':3,
'y':3, 'f':4, 't':4, 'a':5, 'm':5, 'c':6, 'i':6, 'v':6, 'b':7, 'k':7,
@josiahcarlson
josiahcarlson / poly1305.py
Created January 24, 2011 00:51
Imeplementation of DJB's Poly1305-AES algorithm
'''
Implementation of Poly1305-AES as described by Daniel J. Bernstein in
documents linked from: http://cr.yp.to/mac.html
Implemented by Josiah Carlson <josiah.carlson@gmail.com> on 2011-01-23,
released into the public domain.
Note: this implementation of Poly1305-AES uses Python's built-in long integer
implementation, so is not terribly performant, and likely suffers from a
side-channel attack related to the timing of bigint modulo. It also uses
@josiahcarlson
josiahcarlson / divide_maze.py
Created April 5, 2011 22:06
Recursive Division algorithm for maze generation
'''
This is an implementation of the Recursive Division algorithm for maze
generation, primarily derived from the algorithm presented here:
http://weblog.jamisbuck.org/2011/1/12/maze-generation-recursive-division-algorithm
The input grid can be generated via:
grid = [width*[0] for i in xrange(height)]
The initial call should be of the form:
divide(grid, 0, 0, width, height)
@josiahcarlson
josiahcarlson / streaming_api.py
Created May 20, 2011 09:38
A way of implementing a Twitter-like streaming API without pubsub
'''
streaming_api.py
Written May 17-20, 2011 by Josiah Carlson
Released under the GNU GPL v2
available: http://www.gnu.org/licenses/gpl-2.0.html
Other licenses may be available upon request.
Given a Redis server and a task queue implementation, this code implements the
@josiahcarlson
josiahcarlson / redis_simple_chat.py
Created June 24, 2011 22:07
A way of implementing a poll-based chat inside Redis
'''
redis_simple_chat.py
Written June 24, 2011 by Josiah Carlson
Released under the GNU GPL v2
available: http://www.gnu.org/licenses/gpl-2.0.html
Other licenses may be available upon request.
@josiahcarlson
josiahcarlson / git_prompt.bash
Created October 17, 2011 23:48
shell prompt with colored username, host, and git branch
PS1="\[\e[34;1m\]\[\033[01;34m\]\u@\h\[\033[00m\]\[\e[0m\] \w:\[\e[35;1m\]\`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\\\\\*\ \(.+\)$/\(\\\\\\\\\1\)\/\`\[\033[0m\]$\[\033[0m\] "