Archive for the 'python' Category

Rails vs Grails vs Django models

Coming back to Rails after being away from some time in Django land I discovered a huge difference in how Rails and Django treats your models…

Integrating Yahoo Search in a Django site in 5 easy steps

I have been experimenting with various search options for the eutveckling.se site for a while. Google Custom Search is nice and very fast, but the number of ads appearing in the search result page makes it difficult for users to separate result items from ads. (Update: I am sticking with Google Custom Search until I [...]

Improving Django performance with better caching

The Django cache middleware is great, but has one drawback. If you are caching views (which can give a nice performance boost) Django will only use the path segment of the URL to create a cache key. If you are an avid reader of RFC 3986 you may remember that a URI consists of multiple [...]

Stuff I learned over the weekend

1. Finding stuff in lists of dicts in Python
If you have a list of dicts in Python like this:
aXRlbXMgPSBbeyJpZCI6MSwgIm5hbWUiOiAiUmFzbXVzIn0sIHsiaWQiOiAyLCAibmFtZSI6ICJSaWNrIn1d
…and want to check if there are any dict items with an id of a specific value (e.g. 2) I first came up with this:
MiBpbiBtYXAobGFtYmRhIHg6IHhbJ2lkJ10sIGl0ZW1zKQ==
The downside is that it will loop all items which may be inefficient [...]

What’s your history|awk…

Via Bill de hÓra. Run this from the command line:
history|awk ‘{a[$2]++} END{for(i in a){printf “%5d\t%s “,a[i],i}}’|sort -rn|head
I get:
108 ls
78 cd
53 sudo
29 python
13 cap
9 django-admin.py
9 ruby
8 vim
6 easy_install
3 bzr
1 ex
1 python2.5
1 ln
1 mksir
1 cat
1 cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc
In short:

I have trouble with my default python installation.
I am trying Django for small project.
I was hit by the Leopard keyboard repeat freeze bug.
I am poor at spelling simple commands.

Come celebrate Niklas Lindström’s birthday

You may ask yourself “who is that?” or “wtf?!” but the fact is that in the near future he will have a much greater impact on your life than you may think. Here is why you should head over to his blog and post a random comment about Yak shaving and, if possible, create a [...]

Software architects as management deadwood

Two interesting quotes from Dietrich Kappe:
So no, we don’t hire architects. We hire developers. In a small team, there is no room for management deadwood.
I agree completely. My view is that the title “Software architect” is a misnomer for what most architects in the software industry do, or at least what they should be doing. [...]