Category Archives: Python

Heaps

Heaps are slightly obscure data structures that underlie some common higher-level programming constructs, and that may come in handy if you find yourself solving certain classes of problems. (They also come up in certain types of programming interviews, which, to … Continue reading

Posted in Python | Comments Off

Turbo OAuth for Django

Presented for your consideration: an implementation of an OAuth server for Django. Aside from one application-specific piece it is production-ready, and you’re free to use it (and/or modify it) without restriction. I think it’s also worth a look if you’re … Continue reading

Posted in Python | Comments Off

Amateur Geometry

Editorial Note: This one is mostly for me. I want to record my solution to a puzzle so that I can throw out my notes. A few days ago I began to play with the Platonic solids. (I was fooling … Continue reading

Posted in Projects, Python | Comments Off

NSURL, Trailing Slashes, and OAuth

Here’s a surprisingly important note from the documentation for the NSURL class’ path method: Return Value The path of the URL, unescaped with the stringByReplacingPercentEscapesUsingEncoding: method. If the receiver does not conform to RFC 1808, returns nil. If this URL … Continue reading

Posted in iPhone, Python, Web stuff | Comments Off

Django Project Layout

As a sort-of-followup to my brief remarks of last week, today I’m going to say a few words about how I lay out my Django projects, and how I configure the Apache server to present them. There’s nothing too surprising … Continue reading

Posted in Python, Web stuff | Comments Off

OAuth and mod_wsgi

Just a quick tip: If you’re building an (e.g., Django) application that: Relies on mod_wsgi, and Acts as an OAuth server, and Relies on the HTTP Authorization header to pass OAuth parameters, then you need to ensure that you set … Continue reading

Posted in Python | Comments Off

Synchronization Efficiency Proof

Last Friday I described an algorithm that would generate lists of insert and delete operations which would transform a subject list s.t. it would match a target list. I wanted the algorithm to be efficient, both in terms of its … Continue reading

Posted in Python | Comments Off

Synchronizing Ordered Lists

How can two ordered lists be synchronized with the minimum of insert and delete operations, given that only those operations are allowed? Let’s take a cut at this problem, using Python lists for illustration. (Editorial note: There’s probably an elegant, … Continue reading

Posted in Python | Comments Off

District Scraping

Today, just a quick little project: Let’s use Python to extract Congressional Districts from web pages. This is mostly a regex demo.

Posted in Projects, Python | Comments Off

Tuesday’s Child

John Derbyshire has posted an interesting problem/puzzle, discussed in some detail here. Briefly, the problem is this: A man says: “I have two children. One is a boy born on a Tuesday. What is the probability I have two boys?” … Continue reading

Posted in Python, The Hard Way | Comments Off