I hereby claim:
- I am wolever on github.
- I am wolever (https://keybase.io/wolever) on keybase.
- I have a public key whose fingerprint is B5A9 A97F CE49 06AF 8E13 DE44 43D2 86AB B230 230D
To claim this, I am signing this object:
from django.conf import settings as s | |
from django.template import Parser, Lexer, Context, Library, StringOrigin | |
lib = Library() | |
def parse_template(library, origin, template_string): | |
if s.TEMPLATE_DEBUG: | |
from django.template.debug import DebugLexer, DebugParser | |
lexer_class, parser_class = DebugLexer, DebugParser | |
else: |
mkpkg() { | |
if [[ -z "$1" ]]; then | |
echo "mkpkg: $0 PKG_DIR" | |
return 1 | |
fi | |
if [[ ! -d "$1" ]]; then | |
mkdir "$1" || return $? | |
fi | |
touch "$1/__init__.py" | |
} |
I hereby claim:
To claim this, I am signing this object:
""" | |
Python's ``else:`` block is *only* executed when the ``try:`` block does not reutrn: | |
$ python else_block_example.py | |
Running function, returning in 'try:' block: False | |
in 'else' block | |
in 'finally' block | |
Running function, returning in 'try:' block: True | |
in 'finally' block | |
""" |
""" | |
Python 2: | |
$ python-2.7 finallyfun.py | |
e: Exception() | |
Python 3: | |
$ python3.3 finallyfun.py | |
Traceback (most recent call last): | |
File "finallyfun.py", line 9, in <module> | |
foo() |
-- Functions to create and draw histograms with PostgreSQL. | |
-- | |
-- psql# WITH email_lengths AS ( | |
-- -# SELECT length(email) AS length | |
-- -# FROM auth_user | |
-- -# LIMIT 100 | |
-- -# ) | |
-- -# SELECT * FROM show_histogram((SELECT histogram(length, 0, 32, 6) FROM email_lengths)) | |
-- bucket | range | count | bar | cumbar | cumsum | cumpct | |
-- --------+-------------------------------------+-------+--------------------------------+--------------------------------+--------+------------------------ |
global_var = 42 | |
def outer_func(): | |
outer_var = 21 | |
un_used_outer_var = 16 | |
def inner_func(): | |
inner_var = 7 | |
def inner_inner_func(): | |
inner_inner_var = 3 | |
# note: the outer_var must be explicitly referenced, otherwise it won't |
/** | |
* Toggles the CSS classes of an element based on a prefix:: | |
* > elems = $(".status") | |
* > elems | |
* [<div class="status status-active">, <div class="status status-pending">] | |
* > elems.toggleClassPrefix("status-", "status-pending") | |
* > elems | |
* [<div class="status status-pending">, <div class="status status-pending">] | |
*/ | |
$.fn.toggleClassPrefix = function(prefix, toAdd) { |
// A simple plugin which zooms the element when it's hovered: | |
// $("a").hoverzoom(); | |
// Demonstrates my preferred pattern for building jQuery plugins. | |
$.fn.hoverzoom = function() { | |
var method = arguments[0] || "init"; | |
var parentArgs = arguments; | |
this.each(function() { | |
var args = Array.prototype.slice.call(parentArgs); | |
args[0] = $(this); |
from django.template import Library | |
register = Library() | |
@register.simple_tag | |
def plural(n_str, singular, plural=None): | |
""" A better pluralization template tag. | |
The syntax is ``{% plural number "singular" "plural" %}``, where the |