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 %} |
Using Python's built-in defaultdict we can easily define a tree data structure:
def tree(): return defaultdict(tree)
That's it!
# -*- coding: utf-8 -*- | |
##################################################### | |
## Cloud CLI is a basic Dropbox client that lets you: | |
## upload, download, move and list files. | |
## | |
## Requirements: cmd2, Dropbox Python SDK | |
###################################################### | |
if (typeof (AC) === "undefined") { | |
AC = {} | |
} | |
AC.ImageReplacer = Class.create({ | |
_defaultOptions: { | |
listenToSwapView: true, | |
filenameRegex: /(.*)(\.[a-z]{3}($|#.*|\?.*))/i, | |
filenameInsert: "_☃x", | |
ignoreCheck: /(^http:\/\/movies\.apple\.com\/|\/105\/|\/global\/elements\/quicktime\/|_(([2-9]|[1-9][0-9]+)x|nohires)(\.[a-z]{3})($|#.*|\?.*))/i, | |
attribute: "data-hires", |
# | |
# .zshenv | |
# .zshenv is the 1st file zsh reads; it's read for every shell, even if | |
# started with -f (setopt NO_RCS) | |
# .zprofile | |
# read after zshenv, if the shell is a login shell | |
# .zshrc | |
# read after zprofile, if the shell is an interactive shell | |
# .zlogin | |
# read after zshrc, if the shell is a login shell |
#! /usr/bin/env bash | |
# Author: Damien Cassou | |
# | |
# This is the script I use to build Emacs packages for Ubuntu. These | |
# packages are uploaded to | |
# https://launchpad.net/~cassou/+archive/emacs/. Each package is | |
# either build from a Debian package or from | |
# http://emacs.naquadah.org/. |
import requests | |
from requests.auth import OAuth1 | |
url = u'https://api.twitter.com/1/account/settings.json' | |
client_key = u'...' | |
client_secret = u'...' | |
resource_owner_key = u'...' | |
resource_owner_secret = u'...' |
var user = { | |
validateCredentials: function (username, password) { | |
return ( | |
(!(username += '') || username === '') ? { error: "No Username Given.", field: 'name' } | |
: (!(username += '') || password === '') ? { error: "No Password Given.", field: 'pass' } | |
: (username.length < 3) ? { error: "Username is less than 3 Characters.", field: 'name' } | |
: (password.length < 4) ? { error: "Password is less than 4 Characters.", field: 'pass' } | |
: (!/^([a-z0-9_-]+)$/i.test(username)) ? { error: "Username contains invalid characters.", field: 'name' } | |
: false | |
); |