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 functools | |
import thread | |
def nonblocking(func): | |
""" | |
Decorator that runs the given func in a separate thread | |
when called, eg:: | |
@nonblocking | |
def some_blocking_func(): |
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 os, sys | |
c_like = {"single": "//", "multi_start": ("/*",), "multi_end": ("*/",),} | |
langs = { | |
"py": {"single": "#", "multi_start": ("'''", '"""'), | |
"multi_end": ("'''", '"""'),}, | |
"html": {"single": "//", "multi_start": ("<!--", "/*"), | |
"multi_end": ("-->", "*/"),}, | |
"js": c_like, |
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 | |
""" | |
Use a mercurial repository to generate a reStructuredText changelog. | |
""" | |
from datetime import datetime | |
from mercurial import ui, hg | |
from django.utils.datastructures import SortedDict |
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
def save(self, *args, **kwargs): | |
""" | |
Create a unique slug from the title by appending an index. | |
""" | |
if self.id is None: | |
self.slug = slugify(self.title) | |
i = 0 | |
while True: | |
if i > 0: | |
self.slug = "%s-%s" % (self.slug, i) |
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
""" | |
Stand-alone data generation routine that uses the ecommerce taxonomy found on | |
Google Base to generate a significant amount of category and product data, as | |
well as using the Flickr API to retrieve images for the products. The | |
multiprocessing module is also used for parallelization. | |
The Django models and environment used here are specific to the Cartridge | |
project but the approach could easily be reused with any ecommerce database. | |
""" |
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
<? | |
/** | |
* ghetto life stream script for http://jupo.org | |
* | |
* The main function of this script is to use the feed provided by Google Buzz | |
* to create a life stream of entries from various sources with specific | |
* handling for each different type of source. Sources are either directly | |
* integrated into Google Buzz such as Twitter and Flickr, or are subscribed to | |
* via Google Reader which when shared are then sent to Google Buzz. So far the |
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 copy import copy | |
from itertools import dropwhile, takewhile | |
from re import match | |
from django import template | |
from django.utils.datastructures import SortedDict | |
from django.utils.translation import ugettext as _ | |
NewerOlder