This guide assumes a fresh install of Mac OSX 10.7 Lion.
This file contains hidden or 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
| 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" |
This file contains hidden or 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.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. | |
This file contains hidden or 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 | |
| __author__ = 'Frank Smit <frank@61924.nl>' | |
| __version__ = '0.1.0' | |
| import functools | |
| import psycopg2 | |
| from tornado.ioloop import IOLoop, PeriodicCallback |
This file contains hidden or 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
| # 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 |
This file contains hidden or 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.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( |
This file contains hidden or 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 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 |
This file contains hidden or 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
| // 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 |
This file contains hidden or 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/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.) |
This file contains hidden or 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
| # 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. |