TIPS

robots.txt via Django, in one line

A significant difference between developing Django sites versus static-HTML-based approaches (among which I count PHP and the like) is that static files, aka “media”, live in a dedicated spot. Sometimes you need a piece of static content to be available at a specific URL outside your media root. robots.txt for example. This can be done in pure Django (i.e. without even touching your Apache configuration), and is especially nice if your robots.

Django LogEntry to the rescue

If you use Django’s admin application, you’re familiar with its “Recent Actions” sidebar. It gives a simple summary of your latest edits, including clickable links to the relevant objects (not any ones you deleted, naturally, but ones you added or changed). It’s probably not something you look at very often, unless you do such intensive work in the admin that you lose track of things. Django stores that log data (via the admin’s LogEntry model) for all admin users, a fact which has caused me to repeatedly daydream about writing a custom view or two to display it.

Keeping emacs backup files tidy

In the shell, emacs is my editor of choice. However, it has one default behavior that has gotten in the way more often than it has helped – automatic generation of backup files in the same directory as the original. Emacs is great for making quick edits to files on the web server. But I don’t want or need all those *~ files sitting around. The material is all in version control, so I can already revert to any point in history.

From PHP to Python

A former colleague from my days in print design (and a wonderfully loyal reader of my blog to boot) writes to ask whether he should learn Python. He’s a smart guy with a deep background in typography, publishing, and the Mac. He is not a programmer by trade, but has taught himself enough PHP to build a custom CMS for his newspaper. He writes: I’ve invested so much time in PHP, and am quite proficient now (not bad for it being more of an avocation), but I respect your opinion and for a long time have wondered about switching.

Racebike building and software engineering

I just came across this list in an old “should blog about this someday” file. It’s from a 1983 interview of legendary racing motorcycle tuner Rob Muzzy, speaking to legendary motorcycle journalist Kevin Cameron. It’s about how to be smart about going fast. I don’t do a lot of work that’s extremely performance-critical, but most of what Muzzy says rings true for me when applied to software systems. The engineering mindset looks remarkably similar across disciplines.

Understanding tuples vs. lists in Python

Python has two seemingly similar sequence types, tuples and lists. The difference between the two that people notice right away, besides literal syntax (parentheses vs. square brackets), is that tuples are immutable and lists are mutable. Unfortunately, because this distinction is strictly enforced by the Python runtime, some other more interesting differences in application tend to get overshadowed. One common summary of these more interesting, if subtle, differences is that tuples are heterogeneous and lists are homogeneous.

It's not "RAW", it's just "raw"

At the end of this old post by John Nack at Adobe I found corroboration of my feeling that putting “RAW” (as in, raw image files from digital cameras) in all caps is silly. Some might feel this is a level of detail that only concerns copy editors and trademark lawyers, but I’m like that sometimes. I’ve always preferred the nice, simple “raw” as the term for this sort of format.