Skip to content

Instantly share code, notes, and snippets.

View fish2000's full-sized avatar
👉
My Python work is on the Mars helicopter, and ubiquitous on earth, and more!!!!

Alexander Böhn fish2000

👉
My Python work is on the Mars helicopter, and ubiquitous on earth, and more!!!!
  • Objects in Space and Time, LLC
  • Baltimore, MD
  • 02:59 (UTC -04:00)
  • X @fish2000
View GitHub Profile
@nathany
nathany / Vagrantfile
Created March 7, 2011 03:19
Vagrant Fabric experiment
Vagrant::Config.run do |config|
# Every Vagrant virtual environment requires a box to build off of.
config.vm.box = "debian_squeeze_32"
# The url from where the 'config.vm.box' box will be fetched if it
# doesn't already exist on the user's system.
config.vm.box_url = "http://mathie-vagrant-boxes.s3.amazonaws.com/debian_squeeze_32.box"
# Assign this VM to a host only network IP, allowing you to access it via the IP.
config.vm.network "33.33.33.10"
@pmclanahan
pmclanahan / managers.py
Created March 7, 2011 23:14
A class to reduce boilerplate for methods that should exist on Django model managers and querysets.
from django.db.models.manager import Manager
class PassThroughManager(Manager):
'''
Inherit from this Manager to enable you to call any methods from your
custom QuerySet class from your manager. Simply define your QuerySet
class, and return an instance of it from your manager's `get_query_set`
method.
@FSX
FSX / async_psycopg2.py
Created March 8, 2011 22:11
A module for asynchronous PostgreSQL queries in Tornado.
#!/usr/bin/env python
__author__ = 'Frank Smit <frank@61924.nl>'
__version__ = '0.1.0'
import functools
import psycopg2
from tornado.ioloop import IOLoop, PeriodicCallback
@jhalcrow
jhalcrow / test_serial.py
Created April 2, 2011 14:23
Benchmark of different serialization methods in Python, adapted from a J2 Labs Tumblr post
# Adapted from http://j2labs.tumblr.com/post/4262756632/speed-tests-for-json-and-cpickle-in-python
import time
import cPickle as pickle
import simplejson
import json
import cjson
import jsonlib
import ujson
@stefanfoulis
stefanfoulis / osx_developer_installation.rst
Last active May 5, 2025 05:14
Instructions on how to setup an OSX developer machine for (python/django) development

OSX Developer System installation

This guide assumes a fresh install of Mac OSX 10.7 Lion.

Brew User

@mikeyk
mikeyk / redis_session_backend.py
Created April 8, 2011 18:01
A redis backend for Django Sessions, tested on Django 1.3+
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.conf import settings
from django.utils.encoding import force_unicode
import redis
class SessionStore(SessionBase):
""" Redis store for sessions"""
def __init__(self, session_key=None):
self.redis = redis.Redis(
@robmurrer
robmurrer / rotozoom.py
Created June 9, 2011 16:28
RotoZoom for Django ImageKit
import math
from imagekit.lib import *
class RotoZoom(processors.ImageProcessor):
"""
Rotates image with the ability to scale change and apply offsets
angle - degrees counter-clockwise.
scale - defaults to no zoom (1) >1 zooms-in <1 zooms-out
left - left offset in pixels >0 moves right <0 moves left
top - top offset in pixels >0 moves up <0 moves down
@raisch
raisch / regex_tokenizer.js
Created June 10, 2011 13:29
Regular Expression Sentence Tokenizer (English)
// tokenize(str)
// extracts semantically useful tokens from a string containing English-language sentences
// @param {String} the string to tokenize
// @returns {Array} contains extracted tokens
function tokenize(str) {
var punct='\\['+ '\\!'+ '\\"'+ '\\#'+ '\\$'+ // since javascript does not
'\\%'+ '\\&'+ '\\\''+ '\\('+ '\\)'+ // support POSIX character
'\\*'+ '\\+'+ '\\,'+ '\\\\'+ '\\-'+ // classes, we'll need our
#!/usr/bin/python
# recreate the Sobel edge video demo from http://morepypy.blogspot.com/2011/07/realtime-image-processing-in-python.html
# in regular python, using openCV's python bindings.
#
# here's a screenshot: https://skitch.com/llimllib/fkry5/test.py-vim1
#
# this is not meant to say anything about performance! I just think it's neat to run, and
# opencv makes it nice and simple to write. (It does run perfectly in real time, though. I
# didn't bother to count the FPS.)
@ches
ches / install-pygtk.sh
Created July 20, 2011 11:34
Install PyGTK via Homebrew and virtualenv
# This LOOKS pretty straightforward, but it took awhile to sort out issues with
# py2cairo and pygobject, so I hope I've saved you some time :-)
#
# This assumes you already subscribe to a nice clean virtualenvwrapper workflow
# -- see https://gist.github.com/771394 if you need advice on getting there.
# There are some optional dependencies omitted, so if you're going to be doing
# heavy development with these libs, you may want to look into them.
#
# We go to some configure option pains to avoid polluting the system-level
# Python, and `brew link`ing Cairo which is keg-only by default.