Posts in July, 2009

An ETag is a feature of HTTP that allows for a web server to know if content has changed since the last time the browser visited the page. The client sends the ETag from the cached page in a header. If the ETag in the header matches the current ETag then the server lets the browser know that the cached is up-to-date by sending back a 304 Not Modified response.

The most natural way to build an ETag is to generate it from the HTML returned by the view, which I believe is how the default view caching works in Django. The downside of this is that the page is generated even if the client has a cached copy, and all that is saved is the cost of sending the page to the client. continue reading…

Here's an interesting bit of Python code I hacked together – it's a script that takes an image and warps it so that it is tileable (making it suitable for a repeating backgound or a texture in a game).

A Mandlebrot fractal

If you use it on a photograph, it will come out looking like a fair-ground mirror. But it works well when applied to a pattern, or something more abstract, such as the fractal image on the left.

The code is public domain – use it for whatever the heck you want!

Update: Here's another, more interesting example, The original is here.

My employer is looking for a new Python developer to work here in Oxford, UK. The company I work for runs 2degreesnetwork.com, which is collaboration service for sustainable business. Basically, it's a social networking type of site for businesses to collaborate on climate change and related issues. I'm not officially allowed to say this, but the closest analogy is ‘Facebook for Businesses’.

This is the office. Ignore the man in the far corner, he is just a hobo that wandered in.

The site is built with Django, so obviously Django experience would be a bonus, but experience with any MVC framework would be valuable. We're looking for someone who isn't necessarily a specialist and who doesn't mind getting to grips with new technology and dabbling in the front-end from time to time. continue reading…

I noticed recently that I say ‘err’ or ‘umm’ a lot when asked a question, particularly for questions that aren't factual in nature, and have no right or wrong answer. For instance, if I were asked “what is the capital of Turkmenistan” I would answer “Ashgabat” (which everyone knows) without any umming or erring. But if I were asked “would you like milk in your Americano?” I would answer “err… yes”.

This is a pretty mundane thing; everyone does it to some extent, as a way of buying time while considering the options, but I do it even when I know the answer before-hand. I always take milk in my Americano. It's not like I am weighing up the pros and cons of milk before I respond – in fact, I know the answer before I have even opened my mouth to say ‘err…’! continue reading…

Today is my birthday. The universe is officially 35 years old today! :-)

Another year without anyone discovering that I have been faking being a grown-up for all these years. Maybe soon I'll have to start being all responsible.

My forties are not long off. Funny how round numbers are psychologically significant; there is nothing I can do at forty that I couldn't do at thirty nine (or vice versa). Then again, maybe I'll start wearing knitted cardigans and voting conservative – who knows!

Actually I think I'm going to avoid all that “OMG I'm going to be forty!” nonsense, and only worry about ages that are a power of two. Sixty-four is a long ways away, so I can relax for a while. Maybe by then I'll also be a grown-up for real, or I may just leave that for my one-hundred-and-twenty-eighth birthday.

Here's the most convoluted “Hello World!” script I could come up with (in response to this). I don't know if it works. I've proven it correct, but I haven't tested it.

I promise my production code is (marginally) more readable this this…