python

Periodic Status Update (exclaimation, exclaimation, one, exclaimation)

brad's picture

Because Blogging has become a secondary industry to Having a Family, and Working, and Living In Cape Town, I figured it was time for a generic status update, for those of you who dont use Twitter, and/or live near me. It is a hodge-podge, so apologies to any random internet search victims who think this page contained what they were looking for.

Intrepid Ibex

brad's picture

A Nubian Ibex, from http://commons.wikimedia.org/wiki/Image:Capra_ibex_ibex_%E2%80%93_02.jpg
In celebration of the newly announced "Intrepid Ibex" (or Ubuntu 8.10), I once again bring your attention to my python script which generates alternative Ubuntu names. I brute forced some names starting with I and came up with these alternatives (which suggests maybe Intrepid Impala would be a nicer name for 8.10).

The Zen of Python, by Tim Peters

Tagged:
brad's picture

radbrad@Cylon:~$ python
Python 2.5.1 (r251:54863, May  2 2007, 16:56:35) 
[GCC 4.1.2 (Ubuntu 4.1.2-0ubuntu4)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!

Hardy Heron

brad's picture

In celebration of the newly announced "Hardy Heron" version of Ubuntu (8.04) I built a script to randomly generate a name for Ubuntu releases. I did not have a huge corpus of animal names, and I tried to find as many adjectives as I could find, but I used the adjectives and animals from the ubuntu wiki, and here is the script in all it's glory

Statistics logging for Django - part 2

brad's picture

In part 1 I explained how to build middleware and an associated model to capture page accesses, and tie them to a user session. Now that we have all this useful info logged we need to do something with it, like, display it. Unfortunately Django doesn't have a facility for using GROUP BY with mysql, so you have two major choices (there are more but we can ignore them): implement a custom request in a custom Manager (see snippet and snippet, or tagged snippets), or exploit a mysql view and model it in Django. Now for me I prefer the latter because it means my custom sql becomes a mysql customisation and as far as Django is concerned it is dealing with a normal table (but don't tell Django that it is read only), and thus the model code works, so subsequent queries and manipulations can exploit the ORM easily. My subjective and non-scientific experience is that using views is a lot more efficient/quick than using custom queries in the manager (it probably has to do with whatever optimisations exist with views, and the fact that you only fetch items when Django decides you need to fetch a row). So, how the hell do we do it?

Hey Rhythmbox, go pause yourself!

brad's picture

A while back NBM wrote a script to pause Amarokk when his screensaver turned on. Since I get competitive I felt I could do it better, and do it for the media player that I love, Rhythmbox. If you are wondering what purpose this really serves, imagine you are away from your desk for a long time, you want to make sure the music is the same when you come back, and you don't want to bug any co-workers.

Statistics logging for Django

brad's picture

Last night I built some middleware/models for a django application to log visitor/user activity on the site. The intention is to be able to do better user tracking, and build more comprehensive statistics stored in the mysql db (obviously I am also logging everything with apache). The current set up still needs some periodical scripts to conflate data into statistics. I was thinking of doing a daily-weekly-monthly routine (i.e. once a day stats are conflated for yesterday's stats, and once a week they are turned into weekly stats, and once a month they are minimised into a monthly overview.

Python and cybersmart Caps

brad's picture

I recently got DSL at home (after 22 working days), and signed up with a local ISP (cybersmart - you can tell them bwhittington@cybersmart.co.za referred you) because it was the cheapest 3 Gig cap available. What I also like about them is they provide a very simple web page that helps you keep track of your usage. I knew a bit of python, and I wanted to further my skills, so I decided to tap out a python script to bring my cap usage to the desktop. The result:

cybersmart-cap.png

Syndicate content Syndicate content

Recent comments

About this website

Whijo.net is the online internets of Bradley Whittington, Amanda Joseph, and our son Finley James Whittington. "Whijo" is 29% Whittington, 33% Joseph, and 37% Internet. Quite Web 2.0 of us.