Skip to content

Instantly share code, notes, and snippets.

$ git log --graph -50 e8f43ba
* e8f43ba (Merging., Fri Mar 19 23:08:01 2010 -0500, Chris Moffitt)
|\
| * 1a0573a (docs/configuration: change indentation for SATCHMO_SETTINGS block, Thu Mar 18 15:17:04 2010 +0800, Tay Ray Chuan)
| * d275386 (docs/configuration: improve LIVESETTINGS_OPTIONS block, Thu Mar 18 15:04:15 2010 +0800, Tay Ray Chuan)
| * 41be3c0 (docs/configuration: replace tabs with spaces, Thu Mar 18 14:33:14 2010 +0800, Tay Ray Chuan)
| * bf0f490 (docs/configuration: use data markup for L10N_SETTINGS, Thu Mar 18 14:16:48 2010 +0800, Tay Ray Chuan)
| * e488428 (docs/configuration: add reference to category and product urls, Thu Mar 18 13:58:43 2010 +0800, Tay Ray Chuan)
| * 1f0a0a0 (docs/configuration: use inline literals for settings keys, Thu Mar 18 13:53:14 2010 +0800, Tay Ray Chuan)
| * 9831229 (docs/configuration: use inline literals for code, Thu Mar 18 13:40:27 2010 +0800, Tay Ray Chuan)
@rctay
rctay / dulwich-test.sh
Created March 24, 2010 11:38
(MOVED 1122404) [dulwich] running tests
# dulwich - test commands
python setup.py test -s dulwich.tests
python setup.py test -s dulwich.tests.test_repository.RepositoryTests
# with nose - exclude compat
nosetests -e compat
@rctay
rctay / sphinx-0.6.5-autodoc.patch
Created March 27, 2010 04:47
[sphinx] autodoc support for module-level properties
diff -r f76fb0be8011 sphinx/ext/autodoc.py
--- a/sphinx/ext/autodoc.py Mon Mar 01 23:12:59 2010 +0100
+++ b/sphinx/ext/autodoc.py Sat Mar 27 12:46:20 2010 +0800
@@ -336,7 +336,7 @@
Get the real module name of an object to document. (It can differ
from the name of the module through which the object was imported.)
"""
- return self.get_attr(self.object, '__module__', None) or self.modname
+ return self.modname or self.get_attr(self.object, '__module__', None)
@rctay
rctay / test-hg-git.sh
Created March 28, 2010 04:28
(MOVED 1122404) [hg-git] running tests
# from tests/ directory
python run-tests.py -v --with-hg=/usr/local/lib/python2.6/dist-packages/mercurial/ -f
@rctay
rctay / route-rm.sh
Created March 29, 2010 04:01
[linux] deleting a route
# to remove the route
# Kernel IP routing table
# Destination Gateway Genmask Flags Metric Ref Use Iface
# 0.0.0.0 10.0.2.2 0.0.0.0 UG 100 0 0 eth1
sudo route del -net 0.0.0.0 gw 10.0.2.2 dev eth1
@rctay
rctay / print-order-summary.py
Created June 6, 2010 08:27
[satchmo] useful scripts
"""
Prints a comme-delimited list of:
- id
- first product of order
- total amount
- buyer's full name
- buyer's phone number
- payment method
@rctay
rctay / memoize_yaml_load.py
Created June 10, 2010 12:42
memoize yaml.load
class memoize_file(object):
"""
The usual memoize pattern, but with special handling for functions that take
a file argument - use file.name as the key, instead of the file object
itself. This doesn't guarantee 'freshness' across file content changes, though.
"""
def __init__(self, func):
self.func = func
self._cache = {}
@rctay
rctay / README.md
Created June 11, 2010 16:44
[django 1.2, 1.3] using nested transactions for testing

Description

Load fixtures on a per-TestCase basis, instead of per-test method, giving a nice performance boost.

This is done by grouping tests per-TestCase. Before any tests of the TestCase runs, the TestCase's fixtures are loaded (as usual); a transaction savepoint is then created before each test method runs, and rolled back to after the method returns, thus preserving fixture data between test method runs.

@rctay
rctay / runner.py
Created June 12, 2010 01:23
[django] traceback on Ctrl-C
"""
In django 1.2 (ie. after revision #12034), pressing Ctrl-C on a test run no
longer gave a convulted traceback.
However, sometimes it may be desirable to get this traceback - for example, for
profiling reasons; see
http://stackoverflow.com/questions/375913/what-can-i-use-to-profile-c-code-in-linux/378024#378024
"""
@rctay
rctay / gae_log_sum.py
Created June 14, 2010 14:34
[gae] deferred stats
"""
Parses GAE single-line logs and computes the sum of the time-related fields:
total time, cpu time and api time.
"""
from operator import add
def parse_file(url_path, file_path):
def parse_line(line):