Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
import urllib, hashlib | |
from django import template | |
from django.conf import settings | |
from django.contrib.staticfiles.storage import staticfiles_storage | |
# To use this template tag: | |
# 1. Add it to the templatetags/ directory of your Django app. | |
# 2. Then load and use it in the template like so: | |
# | |
# {% load gravatar %} |
#!/usr/bin/env python2 | |
# This is a parser for bash-style variable assignments. | |
# It fully (?) supports the syntax w/o braces, the ${}-syntax | |
# is implemented very hackish. (There are also detailed | |
# TODO-comments in various places) | |
# This is meant for Archlinux' AUR to be used to parse | |
# PKGBUILD's properly. |
/* | |
Ratings Stars | |
(with as little code as possible) | |
*/ | |
.rating { | |
unicode-bidi: bidi-override; | |
direction: rtl; | |
text-align: center; | |
} | |
.rating > span { |
# encoding: utf-8 | |
from uuid import uuid4 | |
from elixir import * | |
from elixir.events import * | |
from sqlalchemy import UniqueConstraint | |
from sqlalchemy.sql import and_ |
/* | |
12306 Auto Query => A javascript snippet to help you book tickets online. | |
Copyright (C) 2011-2012 Jingqin Lynn | |
Includes jQuery | |
Copyright 2011, John Resig | |
Dual licensed under the MIT or GPL Version 2 licenses. | |
http://jquery.org/license | |
Includes Sizzle.js |
thunder://QUFodHRwOi8veGxpc3N1ZTExMC5zYW5kYWkubmV0L+Wkqea2r+aVsOaNri5rej9maWQ9RldLYVBiYUl0WjZLVUtyTTNTdHZGNC0yMVd1amU1RVhBQUFBQUxZVTRwNmNjUm1DTE9SQnBmUEVTdWpYYm9RVyZtaWQ9NjY2JnRocmVzaG9sZD0xNTAmdGlkPTRFN0VDNzRDMkM0NDdDQjVDNjUwOUJERkY1MzdEQ0ExJnNyY2lkPTExMiZ2ZXJubz0xWlo= |
;;; | |
;;; Copyright (C) Kresten Krab Thorup | |
;;; Available under Apache License, Version 2. | |
;;; | |
;;; | |
;;; This minor mode will highlight the indentation of the current line | |
;;; as a vertical bar (grey background color) aligned with the column of the | |
;;; first character of the current line. | |
;;; |
#!/bin/bash | |
if [ ! -d $1 ]; then | |
echo "Not a directory: $1" | |
exit -1 | |
fi | |
while read line; do | |
filename="$(basename $line)" | |
if [ "${filename##*.}" == "less" ]; then |
from django.db.models.query import QuerySet | |
from django.db.models import Manager | |
from django.contrib.contenttypes.models import ContentType | |
from django.contrib.contenttypes.generic import GenericForeignKey | |
class GFKManager(Manager): | |
""" | |
A manager that returns a GFKQuerySet instead of a regular QuerySet. | |
""" |