Jinja2 Rocks!

Jinja2 is an awesome templating system! I've always been happy with the builtin templating framework in Django until about a week ago when I needed to render large amounts of tabular data. Then the Django templating system more or less breaks down because the rendering takes over 2 - 300 milliseconds which is to much time.

My first solution was to aggressively cache rendered pages using the cache middleware. Unfortunately that makes it hard to keep data changes in sync with what visitors see on the site. Plus, the first time the page is accessed is still slow.

The real solution was to throw out the old Django templates and start to learn Jinja2. It's not done yet, but I'm getting there. Meanwhile, here is a performance test that shows how much superior Jinja2 is:

# First the Jinja2 variant from jinja2 import Template from time import time t = Template(''' {% for obj in objs %} <tr> <td>{{ obj.x }}</td> <td>{{ obj.y }}</td> <td>{{ obj.x }}</td> <td>{{ obj.y }}</td> </tr> {% endfor %} ''') class O: x = 3.4 y = 2.5 objs = [O() for x in range(350)] s = time() for x in range(10): print t.render(objs = objs) print (time() - s) / 10.0 # Then Django templates. from django.template import Context, Template from time import time t = Template(''' {% for obj in objs %} <tr> <td>{{ obj.x }}</td> <td>{{ obj.y }}</td> <td>{{ obj.x }}</td> <td>{{ obj.y }}</td> </tr> {% endfor %} ''') class O: x = 3.4 y = 2.5 objs = [O() for x in range(350)] c = Context({'objs' : objs}) s = time() for x in range(10): t.render(c) print (time() - s) / 10.0

Warning for WebFaction

UPDATEAs you can see, this blog post is more than a year old. Since then Webfaction's servers performance has improved considerably. Their support is also much more pleasant to deal with so today I would consider them a pretty decent hoster.

There are lots of great, professional hosting companies out there. Most of them are qualified for what they do and provides exactly the service you're paying for.

WebFaction is not one of them.

The question is what can you expect for $8.50 per month plus VAT? Maybe not a whole lot, and maybe I'm expecting to much. When I signed up, it was to host my GtkImageView project which I'm still keeping at them, but I'm getting increasingly frustrated with them and will migrate before the year runs out if time permits.

What is promised on their site is the ability to run Trac and Subversion which is exactly what I need. Though when it takes over ten seconds to load a single page, thanks to congestion on their servers and overselling, then that is not ok! It is worse than ok because it gives the impression that something should work decently when in reality it sucks majorly. If you don't believe me, then try checking out GtkImageView using Subversion. It is sloooooow.

In the future, I will likely move GtkImageView to some other hosting provider. Possibly to GNOME:s infrastructure if they want to host it. I think they can do a much better job than me, because dealing with hosting related issues is much more work than it seems. Or maybe to Google Code, fast and efficient.

Anyway, I sincerely want to anti-recommend WebFaction. You will be disappointed.

Inga Pengar till Föreningen för Demokrati och Mänskliga Rättigheter i Iran

En organisation som kallar sig för "Föreningen för Demokrati och Mänskliga Rättigheter i Iran" (FDMRI) samlar just nu in pengar i centrala Stockholm. Det verkar vara en lovvärd organisation och deras hemsida ser legitim ut. De har ett postgirokonto, men inget 90-nummer. Frivilligorganisationernas Insamlingsråd avråder folk från att skänka pengar till organisationer utan 90-konton och FDMRI är med på deras lista.

Det är säkrare att bidra till en organisation med ett 90-konto, till exempel Amnesty för då kan man vara säker på att allt går rätt till. Till FDMRI: Om ni är lika pålitliga som era insamlare verkar är det hög tid att skaffa ett 90-konto!

Launched a new Site

Getting it ready took longer than expected. Have been working for 20 hours straight. It is perfect. So tired. Want lots of visitors.. tail -f tail -f.

The greatest Django CMS

There are a lot of Django CMS solutions to choose from. I've spent most of the day comparing each of them and trying to figure out which work and which doesn't. My conclusion is that the good one is django-cms which is the only one that didn't bug out on me and also had full and easy to use i18n support. I believe it is a very good CMS tool when you understand how to use it. It has a steep learning curve and poor documentation you have to suffer through first though.


Till alla bilkörande idioter som inte borde ha körkort: Lämna företräde till gående som går över övergångsställena. Till den äcklige gubbe i svart volvo på Malmskillnadsgatan idag under lunchen som inte fattade det, sug kuk gubbjävel. Hoppas du och din fula hora till fru blir ihjälslagna med baseballträn.

My Small Predictions

In less than three years time, 99.99% of all web traffic will be from automated bots. So 1/10,000 requests will be from a human which is silly little. Also in the future, computer systems will not be measured in mhz or mips but instead in http requests per second.

I think consumer grade 100 Tbit links are just around the corner. No purely human directed traffic can saturate pipes like that. Not even superHD video whatever that will be. Something else will fill them. A lot of resources will be spent maintaining a personal google index for each and every person. Imagine that. Your own search engine backed up by a huge neural network which learns your likes and dislikes, your writing style so you will only have to spend minimal effort searching for what you are after. Having to use a regular search-engine will become very hard because you will be so accustomed to the personal one that it will be like trying to speak a foreign language.

There will be competent ghost writer bots. Those bots will index all kinds of literature available on the internet and suggest precise, colorful or humorous formulations for you to write your blog posts with. It will be like autocomplete in forms, except it will work in textareas and for multiple paragraphs at the same time. The only downside is that, while more prose will be written, a smaller portion of it will be read by humans. The rest will be consumed by bots.

And that's just some advances that will happen in the area of text-processing. Then we will get accurate image and video recognition. I'm to tired to speculate but it will be quite cool.

Best invite so far

I've participated in beta programs and gotten invite links before. But this one is by far the best one of them all:
Thanks for your interest in Google Storage for Developers. Here is the invite link you requested: https://sandbox.google.com/storage/m/?invite=arglebarglemarlge Please note that this invitation is not transferable. In addition, Google Storage is available for US developers only at this time. During the preview period, you will receive up to 100GB of data storage and 300GB monthly bandwidth at no charge
/me has not told them where I live. :) Saweeet! Now I just need to think of something to do with 100gb of data that does not involve copyright infringement.

Gratuitous Breakage

This morning I got the following email from ShrinkTheWeb:


So they are changing their api. For those who do not know, ShrinkTheWeb is a kickass web service which enables you to easily take screenshots of web pages. I use it for, among other things, The VPS List.

While I realize that api has to be broken from time to time, the proposed changes are just silly and it is humourous that they weren't able to insulate end users from them.

Change www.shrinktheweb.com/xino.php TO images.shrinktheweb.com/xino.php

Or your web server could be set up to serve the same php script at both links.

make all stw variables lowercase

Because it is so hard for you to lowercase all variables yourself before processing them? :)

use the newer stw-specific variable names

I don't get this change either. What advantage is there in prefixing GET-variables with a stw-prefix?

Don't get me wrong, ShrinkTheWeb is a very useful web service, but the above mentioned stuff is basically the very definition of gratuitous breakage.


Uppspelningen av den här filmen kräver en Module Music Format (MOD)-avkodare-insticksmodul som inte är installerad.

Hade det varit så jävla svårt att skriva vad insticksmodulen heter så jag slipper leta runt bland tio miljarder paket efter den? Hittade tillslut "gstreamer0.10-plugins-bad" Verkligen intiutivt...

Getting into DMOZ

I'm trying to get The VPS List included in DMOZ.. But the submission message is discouraging:

Once your site has been accepted into the Open Directory, it may take anywhere from 2 weeks to several months for your site to be listed on partner sites which use the Open Directory data, such as AOL Search, AltaVista, HotBot, Google, Lycos, Netscape Search, etc.

Guess it will be a long wait. :/

Sex års väntan är över...

Antiklimax. Icke-tillfredsställande. Klichéartat. Långt under förväntan. Vad hände egentligen? Frustrerande att de får göra på det här sättet. Alla manusförfattare måste fått hjärnblödning eller något, så mycket fusk var det.

Bason Journe,

You suck!

Killing the Xserver

Xorg has an xorg.conf setting called "DontZap" which you can use to enable the Ctrl+Alt+Backspace key combo to kill the Xserver:

Section "ServerFlags" ... Option "DontZap" "false" ... EndSection

Nice double negation there. But it doesn't work in GNOME. Here is how you do it there: Go System -> Settings -> Keyboard -> Layouts -> Options -> Expand the triangle "Key sequence to kill the X-server" -> Check the checkbox. Took me a while to figure it out. In the future, it would be nice if GNOME could sync that setting with what is stated in xorg.conf.

Ubuntu Lucid

Håller på och testar Ubuntu Lucid Lynx för fullt. Som vanligt när man uppgraderar Ubuntu är det alltid något som strular. Den här gången bara alt-tab som inte funkar och xorg tror att min 1600x900 skärm är 1024x768.

GNOME håller fast vid den idiotiska principen att dölja de applikationer som är för "power users" i startmenyn. Hur får man tillbaka gconf-editor? Perkele.

Dagens irritationsmoment

Okej för att Suns Java har fasats ut i Ubuntu 9.10 och ersatts med OpenJDK, det kan jag leva med. Men vad är det här?
# apt-get install openjdk-6-jdk ... Följande NYA paket kommer att installeras: ca-certificates-java hicolor-icon-theme icedtea-6-jre-cacao java-common libaccess-bridge-java libaccess-bridge-java-jni libasound2 libatk1.0-0 libatk1.0-data libcairo2 libdatrie1 libdirectfb-1.2-0 libflac8 libfontenc1 libgif4 libgtk2.0-0 libgtk2.0-bin libgtk2.0-common libice-dev libice6 libjasper1 libjline-java libjpeg62 liblcms1 libnspr4-0d libnss3-1d libogg0 libpango1.0-0 libpango1.0-common libpixman-1-0 libpng12-0 libpthread-stubs0 libpthread-stubs0-dev libpulse0 libsm-dev libsm6 libsndfile1 libthai-data libthai0 libtiff4 libts-0.0-0 libvorbis0a libvorbisenc2 libx11-6 libx11-data libx11-dev libxau-dev libxau6 libxcb-render-util0 libxcb-render0 libxcb1 libxcb1-dev libxcomposite1 libxcursor1 libxdamage1 libxdmcp-dev libxdmcp6 libxext6 libxfixes3 libxfont1 libxft2 libxi6 libxinerama1 libxrandr2 libxrender1 libxt-dev libxt6 libxtst6 openjdk-6-jdk openjdk-6-jre openjdk-6-jre-headless openjdk-6-jre-lib rhino shared-mime-info tsconf tzdata-java x-ttcidfont-conf x11-common x11proto-core-dev x11proto-input-dev x11proto-kb-dev xfonts-encodings xfonts-utils xtrans-dev
Kan någon förklara varför jag nödvändigtvis behöver GTK+, Cairo, Xorg och andra desktoprelaterade paket för att köra java på en server?


Patetiskt att inte Skatteverkets site klarar belastningen från alla som försöker deklarera. Deras servrar går just nu på knäna och man kan inte logga in för det finns inget minne kvar till att skapa nya sessioner. Kanske är det för svårt för teknikerna att förutse att ifall X miljoner människor inte har deklarerat när det är N timmar kvar innan deklarationen ska vara inlämnad, måste servrarna klara av att hantera X/N deklarationsinlämningar per timme.

Looking for a Django Multilingual Solution

One that actually works that is. django-multilingual is quite nice when it works, but has some quite severe bugs. It doesn't work with Django 1.2 due to Issue 1114 and it seems that it wont be fixed before 1.2 is out.

It's trunk doesnt work either: Issue 95. django-multilingual-ng looks nice and apparently was created to solve these problems, but it has its own issues and doesn't work with Django 1.1.

The VPS List

Den senaste tiden har jag fokuserat stort på mitt nya projekt, en site om VPS:er: The VPS List. Det är en prisjämförelsesite för virtuella servrar. Jag gillar tabeller och statistik och det finns det mycket av på siten.

Koden är på det hela taget nästan klar. Listan kan sorteras, valutan kan ändras, användarbetyg och omdömen kan publiceras. Den roliga biten alltså. Nu återstår att försöka dra trafik till siten vilket är både svårt och tidsödande. En website är ganska meningslös om den inte betjäner någon trafik. Tyvärr räcker det inte med att ha mycket innehåll. Utan marknadsföring hittar ingen dit. Exempelvis har jag kontinuerligt uppdaterat den här bloggen i över fem år men drar ändå inte mer än c:a tio besökare per dag. Visserligen är det mesta värdelöst svammel, men ändå.

Något som jag kan rekommendera andra i samma situation (en ashäftig site men inga besökare) är att regga siten på AboutUs, en wiki som fungerar som en telefonkatalog för webbsiter. De verkar inte sky kommersiella webbplatser heller vilket är trevligt.