Skip to content

Instantly share code, notes, and snippets.

@rctay
rctay / clear_memoizer_cache.patch
Created June 14, 2010 15:05
[gae][bloggart] clear memoizer cache
diff --git a/admin.py b/admin.py
index b55e0cd..bbc08cd 100644
--- a/admin.py
+++ b/admin.py
@@ -17,6 +17,8 @@ application = webapp.WSGIApplication([
(config.url_prefix + '/admin/regenerate', handlers.RegenerateHandler),
(config.url_prefix + '/admin/post/delete/(\d+)', handlers.DeleteHandler),
(config.url_prefix + '/admin/post/preview/(\d+)', handlers.PreviewHandler),
+
+ (config.url_prefix + '/admin/clear_cache', handlers.ClearHandler),
@rctay
rctay / __init__.py
Created June 29, 2010 07:42
[python] import with a string
We couldn’t find that file to show.
@rctay
rctay / __init__.py
Created July 4, 2010 04:43
[django] clean field
from clean_field import *
@rctay
rctay / __init__.py
Created July 8, 2010 17:09
[django] javascript widget factory
We couldn’t find that file to show.
@rctay
rctay / __init__.py
Created July 9, 2010 08:07
[django] admin view wrapper cum url() factory method
We couldn’t find that file to show.
@rctay
rctay / uncollapse_all.js
Created July 11, 2010 11:39
[django] uncollapse all collapsible fieldsets
/**
* Provides the function 'uncollapse_all' that expands/uncollapses all
* unexpanded/uncollapsed fieldsets.
*
* Known to work with django 1.2<=, <=1.3.0a0.
*/
django.jQuery(document).ready(function($) {
var e = $("fieldset.collapse a.collapse-toggle");
// obtain the jquery click handler that toggles the groups; we assume
@rctay
rctay / git-post-install.sh
Created July 24, 2010 01:44
[git] replace hard linked-builtins with symlinks
#!/bin/sh
BINDIR=/usr/local/bin/
EXECDIR=/usr/local/libexec/git-core
X=.exe
GIT=$BINDIR/git$X
for p in $(ls -1 $EXECDIR); \
do
p=$EXECDIR/$p # already contains the postfix $X
test $p -ef $GIT && \
@rctay
rctay / vim-cyg.sh
Created July 27, 2010 05:17
[cygwin] win32 vim wrapper
#
# Wraps Win32 vim, converting cygwin paths to windows ones; after saving this,
# you can setup the alias vim
#
# alias vim=~/vim-cyg
#
# and just type "vim path/to/file" instead of the full path to this script.
#
# Note: You can't set your EDITOR environment variable to the alias though.
#
@rctay
rctay / benchmark.scm
Created August 16, 2010 14:18
[racket] benchmark helper
;
; Runs '(proc)' over 'n' times of 'MAX_RUNS', display stats collected from
; '(time-apply)'.
;
; Sample session:
; > (define (factorial-iter n)
; (if (<= n 1)
; 1
; (foldl * 1 (build-list n add1))))
; > (benchmark 5 factorial-iter 100)
@rctay
rctay / gist:527113
Created August 16, 2010 15:18
[django] check if db table exists
"""
Came up with this for satchmo's downloadable product migration, 0001_split.
"""
def db_table_exists(table, cursor=None):
try:
if not cursor:
from django.db import connection
cursor = connection.cursor()
if not cursor:
raise Exception