Caching a Django app with Nginx + FastCGI
I just spent a stupid amount of time trying to figure why Nginx was failing to cache my Django app responses. The Django app is running as a FastCGI backend and I have Nginx using the fastcgi_cache...
View ArticleBuilding Nginx 0.9.5 on Debian Lenny
Nginx is available in Debian Lenny, but the version in stable is the old 0.6.x series. Perusio maintains a useful repository with development versions built for Lenny, but it requires libraries newer...
View ArticleAdobe’s software update site is shit
This is written from the point of view of someone looking to keep abreast of software patches for Adobe‘s many excellent products (also Acrobat). Adobe’s Downloads page is mostly about downloading...
View ArticleAdobe Software Updates
What Adobe’s software update site needs is: An RSS / Atom feed of recent updates. This way you can subscribe to a list of recent updates in your favourite news reader and be informed when a new update...
View ArticleVCS for Cocoa Programming for Mac OS X
I am working my way through Aaron Hillegass‘ Cocoa Programming for Mac OS X (again). I find it a good book, despite the fact I’ve started it twice before and have abandoned my tuition twice before. I...
View ArticleStyling your Excel data with xlwt
This post is about how to create styles in Excel spreadsheets with the most excellent xlwt for Python. The documentation for xlwt (version 0.7.2) is a little sketchy on how to use formatting. So here...
View ArticleCSV sucks
For future reference: CSV is a terrible format for spreadsheet data. Any by spreadsheet data I mean CSV is a terrible format for text data that will be opened in Microsoft Excel (unless you only speak...
View ArticleLion: Spotlight still broken
I’ve installed Mac OS X 10.7 (upgrading from 10.6) and was very interested to see how the new search tokens feature would work in Spotlight. But on my Mac it doesn’t. Here’s the result of a search for...
View ArticleXPath bug in old versions of ElementTree
I figured out why my XML parsing code works fine using the pure-Python ElementTree XML parsing module but fails when using the speedy and memory-optimized cElementTree XML parsing module. The XPath 1.0...
View ArticleFree software FTW! Updated filetimes.py
Two years ago (flippin’ heck it seems like only yesterday) I wrote about converting between Unix timestamps and Windows timestamps using Python. In that post I linked to my very simple implementation...
View ArticleDate variables in InDesign
Interesting InDesign problem: the format for a modification date variable changes per document. (This post describes a problem using Adobe InDesign CS4 but applies just as well to CS5 and CS5 and a...
View ArticleWidths & Heights with xlwt + Python
This article about using xlwt to generate Excel in Python reminded me I needed to see exactly how to set column widths (the xlwt documentation doesn’t cover it). Let’s create a new Excel workbook and...
View ArticleSharpZipLib and Mac OS X
TL;DR When creating zip archives with SharpZipLib disable Zip64 format if you care about Mac compatibility. Extra TL;DR When creating zip archives with SharpZipLib make sure you set the file size,...
View ArticleSharpZipLib and Mac redux
I wrote a blog about generating Mac-compatible zip files with SharpZipLib, the conclusion of which was to disable Zip64 compatibility. It was wrong, wrong I tell you. The better solution is to just set...
View ArticleInspecting your routes in Bottle
Marcel Hellkamp recently added a small feature to Bottle that makes it easy to inspect an application’s routes and determine if a particular route is actually for a mounted sub-application. (Bottle is...
View ArticleCustom template folders with Flask
Someone was asking on Flask‘s IRC channel #pocoo about sharing templates across more than one app but allowing each app to override the templates (pretty much what Django’s TEMPLATE_DIRS setting is...
View ArticleA context manager for files or file-like objects
I usually design my Python programs so that if a program needs to read or write to a file, the functions will take a filename argument that can be either a path string or a file-like object already...
View ArticleHow to fix “ghost” files in the Finder
Sometimes the Mac Finder can get its knickers in a twist about files that you ought to be able to open just fine but Finder says no. You may see a message that says “Item XYZ is used by Mac OS X and...
View ArticleOptimizing queries in Haystack results
My Adobe software updates app (which uses Haystack + Django to provide a search feature) has a very inefficient search results template, where for each search result the template links back to the...
View ArticleTesting with Django, Haystack and Whoosh
The problem: you want to test a Django view for results of a search query, but Haystack will be using your real query index, built from your real database, instead of an index built from your test...
View Article