Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
# wordpress over fastcgi | |
server { | |
listen 81; | |
server_name _; | |
root /mnt/apps/airpair-blog/current; | |
index index.html index.php /index.php; | |
# restricting all dot files | |
location ~ /\. { return 403; } |
/** | |
* Copyright 2012 Akseli Palén. | |
* Created 2012-07-15. | |
* Licensed under the MIT license. | |
* | |
* <license> | |
* Permission is hereby granted, free of charge, to any person obtaining | |
* a copy of this software and associated documentation files | |
* (the "Software"), to deal in the Software without restriction, | |
* including without limitation the rights to use, copy, modify, merge, |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
from flask import Flask | |
from flask.ext.sqlalchemy import SQLAlchemy | |
from flask.ext import admin, wtf | |
from flask.ext.admin.contrib import sqlamodel | |
app = Flask(__name__) | |
app.config['SECRET_KEY'] = '123456790' | |
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///test.sqlite' | |
db = SQLAlchemy(app) |
import logging | |
import redis # http://pypi.python.org/pypi/redis | |
class RedisHandler(logging.Handler): | |
def __init__(self, lname, conn, *args, **kwargs): | |
logging.Handler.__init__(self, *args, **kwargs) | |
self.lname = lname | |
self.channel = lname + ":chan" | |
self.redis_conn = conn |
# Dynamically load virtualenvwrapper functions to reduce shell startup | |
# time. | |
# | |
# Copyright 2012 Aron Griffis <[email protected]> | |
# Released under the GNU GPL v3 | |
####################################################################### | |
# Python virtualenvwrapper loads really slowly, so load it on demand. | |
if [[ $(type -w workon) != "workon: function" ]]; then | |
virtualenv_funcs=( workon deactivate mkvirtualenv ) |
# autocomplete.py - Redis autocomplete example | |
# download female-names.txt from http://antirez.com/misc/female-names.txt | |
# Ruby original: http://gist.github.com/574044 | |
# Requires http://github.com/andymccurdy/redis-py/ | |
from redis import Redis | |
r = Redis() | |
KEY = 'compl' |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
import redis | |
import simplejson as json | |
import logging | |
import settings | |
import math | |
log = logging.getLogger(__name__) | |
# | |
# The following formulas are adapted from the Aviation Formulary |
#! /usr/bin/env python | |
import redis | |
import random | |
import pylibmc | |
import sys | |
r = redis.Redis(host = 'localhost', port = 6389) | |
mc = pylibmc.Client(['localhost:11222']) |