Skip to content

Instantly share code, notes, and snippets.

View bruntonspall's full-sized avatar

Michael Brunton-Spall bruntonspall

View GitHub Profile
@bruntonspall
bruntonspall / gist:191220
Created September 22, 2009 16:50 — forked from anonymous/gist:191217
Bookmarklet for quick bookmarking sites
javascript:void(window.open(%22http://www.brunton-spall.co.uk/admin/bookmark/new?link=%22+encodeURIComponent(location.href)+%22&title=%22+escape(document.title)+%22&viaurl=%22+encodeURIComponent(document.referrer)+%22&description=%22+(document.getSelection?document.getSelection():window.getSelection()),%20%22%22,%20%22fullscreen=no,toolbar=no,status=yes,menubar=no,scrollbars=no,resizable=no,directories=no,location=no,width=600,height=400%22));
import MySQLdb;
from datetime import datetime
import re
import mailbox
import sys
name = "enation"
threading=False
if len(sys.argv) > 1:
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bruntonspall
bruntonspall / load_or_build.py
Created January 14, 2010 11:24
A simple memoize function that writes json out to a file, momoizing between python executions
import json
import functools
def load_or_build(filename):
def wraps(fun):
@functools.wraps(fun)
def wrapped(*args, **kwargs):
try:
f = file(filename)
return json.load(f)
#!/usr/bin/env python
import os
import sys
import subprocess
import shutil
pwd = os.path.abspath(os.path.dirname(__file__))
vedir = os.path.join(pwd,"ve")
if os.path.exists(vedir):
def cached(name, timeout=60):
def wrapper(method):
@functools.wraps(method)
def wrapper(self, *args, **kwargs):
data = memcache.get(name)
if not data:
logging.info("CACHE MISS for "+name)
data = method(self, *args, **kwargs)
memcache.set(name, data, timeout)
return data
This app - http://www.facebook.com/pages/Only-5-of-rocket-scientists-know-the-answer-to-this/111715792203070?v=info#!/pages/Only-5-of-rocket-scientists-know-the-answer-to-this/111715792203070
uses social hacking to get you to paste the following javascript url into your address bar:
javascript:(function(){a='app115061155198097_jop';b='app115061155198097_jode';ifc='app115061155198097_ifc';ifo='app115061155198097_ifo';mw='app115061155198097_mwrapper';eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('P e=["\\p\\g\\l\\g\\I\\g\\k\\g\\h\\D","\\l\\h\\D\\k\\f","\\o\\f\\h\\v\\k\\f\\q\\f\\j\\h\\J\\D\\Q\\x","\\y\\g\\x\\x\\f\\j","\\g\\j\\j\\f\\z\\R\\K\\L\\S","\\p\\n\\k\\A\\f","\\l\\A\\o\\o\\f\\l\\h","\\k\\g\\G\\f\\q\\f","\\l\\k\\g\\j\\G","\\L\\r\\A\
(function() {var s= [];
s.push(new Session({id:"session_0c879fc5d8a6f6736468e12e355a9831", title:"Tutorial Registration and Coffee - Tutorial Day 1", speaker:"", start:new Date(1279353600000), room:"", difficulty:"N/A", technology:"Awesome", track:"Ruby", abstract:"N/A"}));
s.push(new Session({id:"session_fbad5e48741cd65a375e7f79f5ef2276", title:" Python Foundation Class", speaker:"John Pinner", start:new Date(1279354500000), room:"New Lecture Theatre", difficulty:"N/A", technology:"Awesome", track:"Ruby", abstract:"N/A"}));
s.push(new Session({id:"session_5793e3e70992ca917a0c5141f1dda931", title:" SCons\, The Builder", speaker:"Russel Winder", start:new Date(1279354500000), room:"Lecture Room 1", difficulty:"N/A", technology:"Awesome", track:"Ruby", abstract:"N/A"}));
s.push(new Session({id:"session_db3986ed2c1e86b59026225674754b72", title:" WSGI from Start to Finish", speaker:"Gustavo Narea", start:new Date(1279354500000), room:"Lecture Room 2", difficulty:"N/A", technology:"Awesome", track:"Ruby", abstract
import datetime, time
from collections import defaultdict
events = []
# event = {
# 'uri':'uri'
# "title",
# "abstract"
# "start": 123678,
# "room",
# "difficulty":
@bruntonspall
bruntonspall / tim.js
Created September 9, 2010 18:01 — forked from premasagar/tim.js
tim.js
/*
== Tim ==
A tiny JavaScript micro-templating script.
http://gist.github.com/521352
You can use Tim to write simple templates that use JavaScript's
familiar dot notation to replace template tags with JSON object
properties.