Simon Willison’s Weblog

Subscribe
Atom feed for code

3 items tagged “code”

2010

countdown_to_newyear.py. A quick Python / OS X script I knocked up last night to count in the new year (using the OS X “say” command).

# 1st January 2010, 4:24 pm / scripts, code, projects, python, osx, say, newyear

2008

csrf_protect.php. A PHP class for applying CSRF protection to existing PHP applications, using output buffering to rewrite any POST forms on a page. Heavily inspired by Django’s CSRF middleware. Tell me if you spot any bugs!

# 24th September 2008, 2:52 pm / projects, code, php, csrf, security, middleware, outputbuffering

Django snippets: RequestFactory. I’ve been wanting this for ages; when I finally got around to writing it it turned out to only be a dozen or so lines of code. Makes it easy to create mock request objects in Django, which you can then use for testing view functions directly (bypassing the current test client mechanism which requires views to be assigned to a URLconf before they can be tested).

# 12th August 2008, 12:40 pm / django, testing, requestfactory, code, python, httprequest