This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> one_gig = 1024*1024*1024 | |
>>> thirty_two_gigs = one_gig * 32 | |
>>> one_gig * 32 == thirty_two_gigs | |
True | |
>>> for i in range(thirty_two_gigs): | |
... _ = f.write("\n") | |
... if i % one_gig == 0: print(i) | |
... | |
0 | |
1073741824 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import bisect | |
from UserDict import UserDict | |
from datetime import timedelta | |
from collections import deque, Counter | |
from peewee import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Detect if executed under test | |
TESTING = any(test in sys.argv for test in ( | |
'test', 'csslint', 'jenkins', 'jslint', | |
'jtest', 'lettuce', 'pep8', 'pyflakes', | |
'pylint', 'sloccount', | |
)) | |
if TESTING: | |
# If testing, move the default DB to 'mysql' and replace it | |
# with a SQLite DB. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Handlebars.registerHelper('trans', function(fn) { | |
return gettext(fn(this)); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function absoluteUrl(url) { | |
if (url.substr(0, 4) == 'http') | |
return url; | |
return location.protocol + '//' + location.host + url; | |
} | |
/** | |
* | |
* MD5 (Message-Digest Algorithm) | |
* http://www.webtoolkit.info/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
def walk(storage, top='/', topdown=False, onerror=None): | |
"""An implementation of os.walk() which uses the Django storage for | |
listing directories.""" | |
try: | |
dirs, nondirs = storage.listdir(top) | |
except os.error, err: | |
if onerror is not None: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os.path | |
from django.core.files.storage import FileSystemStorage | |
from django.core.files.base import ContentFile | |
from slimit import minify | |
class StaticFileStorageAndJSMinifier(FileSystemStorage): | |
""" | |
A storage backend to be used by the staticfiles app -- STATICFILES_STORAGE | |
setting. This backend operates just as a normal filesystem storage backend | |
except when it detects a javascript file. |