Skip to content

Instantly share code, notes, and snippets.

@cfmonkey
cfmonkey / pyramid_notfound.py
Created June 8, 2012 03:21
url redirect when it's not found.
from pyramid.renderers import render_to_response
from pyramid.view import notfound_view_config
from pyramid.httpexceptions import HTTPFound, HTTPNotFound
from pyramid.interfaces import IRoutesMapper
def find_route(path, request):
q = request.registry.queryUtility
mapper = q(IRoutesMapper)
if mapper is None:
@cfmonkey
cfmonkey / gist:722014
Created November 30, 2010 17:25
bitmap sort
#-*- coding: utf-8 -*-
def bitsort(inlist):
tmplist = list([0] * 100)
for item in inlist:
tmplist[item] = 1
outlist = [i for i, item in enumerate(tmplist) if item == 1]
return outlist