This file contains hidden or 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 contextlib | |
import datetime | |
@contextlib.contextmanager | |
def mock_now(dt_value): | |
"""Context manager for mocking out datetime.now() in unit tests. | |
Example: | |
with mock_now(datetime.datetime(2011, 2, 3, 10, 11)): |
This file contains hidden or 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 re | |
# Some mobile browsers which look like desktop browsers. | |
RE_MOBILE = re.compile(r"(iphone|ipod|blackberry|android.+mobile|palm|windows\s+ce)", re.I) | |
RE_DESKTOP = re.compile(r"(windows|linux|os\s+[x9]|solaris|bsd)", re.I) | |
RE_BOT = re.compile(r"(spider|crawl|slurp|bot)") | |
def is_desktop(user_agent): | |
""" |
This file contains hidden or 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
"""collapsespaces is a Django template tag that collapses whitespace characters between tags into one space. | |
It is based on Django's 'spaceless' template tag (spaceless is different in that it completely removes whitespace between tags). | |
Why is this important? | |
Given "<span>5</span> <span>bottles</span>", collapsespaces will preserve the space between the two span elements--spaceless will not. | |
In a web browser: | |
"<span>5</span> <span>bottles</span>" renders as "5 bottles" | |
"<span>5</span><span>bottles</span>" renders as "5bottles" | |
""" |
This file contains hidden or 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
/*! | |
* jQuery TextChange Plugin | |
* http://www.zurb.com/playground/jquery-text-change-custom-event | |
* | |
* Copyright 2010, ZURB | |
* Released under the MIT License | |
*/ | |
(function ($) { | |
$.event.special.textchange = { |