XOR Media

Coding, Operations, Etc.

String Truncate Middle With Ellipsis

There are times when you need to middle truncate a string. In many cases it's for UX/human purposes, though in some situations it's the best way to generate unique string for a length-limited field. This is the case I ran in to recently in trying to automate ...

(more)
In code, tagged: python, coding, examples, and strings.

Natural Sort Order with Zero Padding

Which of the following lists is sorted in the most "natural" fashion?

A:
    Elementary Season 1 Episode 1
    Elementary Season 1 Episode 10
    Elementary Season 1 Episode 11
    Elementary Season 1 Episode 12
    Elementary Season 1 Episode 13
    Elementary Season 1 Episode 2
    Elementary Season 1 Episode 3
    Elementary Season ...
(more)
In code, tagged: python, coding, examples, and sorting.

High Performance Web: Asynchronous HTTP

Async-What

The secret to building high performance sites which depend on external web services is asynchronous HTTP. The trick to asynchronous HTTP (or anything with the exception of UI) is to avoid callback hell. Enter futures/promise objects. When used correctly they make doing substantial asynchronous IO, relatively straightforward.

It ...

(more)

Keeping Track with Graphite and Statsd

I recently gave a presentation on graphite and statsd to the East Bay Django meetup It's more about the importance of stats in general when running services, web or otherwise. The slides are available and embedded here. There's also a related demo project that turned out to be ...

(more)
In ops, tagged: django, performance, python, and stats.

Django ALLOWED_HOSTS and Amazon Elastic Load Balancer

A recent Django security release added a new configuration option, ALLOWED_HOSTS. It's optional in 1.3 and 1.4, but required in 1.5 setups. The relevant detail is that when enabled in production Django will throw 500 errors if the Host header doesn't match one of the ...

(more)
In ops, tagged: aws, django, elb, and python.