PostgreSQL, MySQL or SQLite

April 4, 2004
9 comments Linux

I use PostgreSQL a lot but these benchmarking results surprise me. MySQL is often much faster than PostgreSQL and SQLLite is several times faster than MySQL.

What matters to me is how fast they work with Python, or in particular Zope. I need to make my own benchmark of MySQL and PostgreSQL with Zope and all the various database adapters.

The reason I moved from MySQL to PostgreSQL was partly because PostgreSQL has more enterprise features and that my colleges use PostgreSQL. But I suspect that for many of my projects I never even use these features.

Then I also found this from a Zope mailing list:

>The speed comparisions with PostgreSQL are very much an apples vs. fish
>sort of thing: the pgsql server was not tuned at all, and does a whole
>lot more that was never tested, such as multi-user writer access.

Challenge Osama with scimitar or sword

April 2, 2004
0 comments Politics

Knight Crusader "I challenge you to meet me with "scimitar"n:http://elfwood.lysator.liu.se/loth/e/d/edlund/scimitar.jpg.html or sword, to be pitted against myself and a holy sword consecrated to our Order-a sword that was forged to destroy evil. Here's the deal: if I win, Al Qaeda is disbanded-forever. If you win, then you can set the head of a Knight Templar on a pike outside your tent,"

A brave Christian challenges Osama bin-Laden to a sword fight. Brave.

"This Knight Templar calls you a craven coward and an infidel. He calls you a murderer of the innocent, and a defiler of holy places. He calls you the favourite son of Satan, for you above all men on the earth have done your best to do Satan's bidding."

What struck me about this is that it's a pretty clever way to convey a simple a message. Using the image of a classical sword fight to justify for calling Osama names. He sure doesn't hold anything back. Read it!

Anti-email-harvesting with JavaScript

April 2, 2004
0 comments Web development

Anti-email-harvesting is when you, as a web developer, tries to make sure the spam bots can not scan your pages for email addresses and then bloat these email addresses with spam. There are several different ways of doing it, or should I say attempting to do it? None is perfect, otherwise we'd all know about it. For this site I use a technique described in the second part of this blog entry.

Now I've put together a little proof-of-concept by using a JavaScript again and modifying something ugly to something nice looking. The idea is that web developers have to render their HTML like this:


<span class="aeh">peter_at_peterbe_._com</span>

Note, that the class has to be "aeh" and the tag must be a span.

This page explains it further. What do you think? The rules can be changed but the effect is really good. People without Javascript support see the email address as peter_at_peterbe_._com which they'll just have to figure out just like they figured out how to disable Javascripts. And people with Javascript will see it as if it was written in clear text. Spam-bots won't see shit. Or will they?

UPDATE

I have upgraded the script a bit now so that it does complain about invalid HTML on spaces in the href attribute. It also doesn't use a span tag anymore. Just set the class aeh on the a tag. Lastly, it uses proper DOM manipulation instead of the hackish innerHTML gadget.

See it in action here

Metamorphosis, Franz Kafka

March 31, 2004
2 comments Books

"One morning, when Gregor Samsa woke from troubled dreams, he found himself transformed in his bed into a horrible vermin."

On Sunday morning I heard that Project Gutenberg has started to provide some of their books in MP3 format. I did a "random" search and eventually started downloading The Trial by Franz Kafka. Whilst waiting I started to read Metamorphosis also by Franz Kafka.

We read it at school many years ago and I appreciated it even more this time. What a fantastic book it is. So incredible many subtle hints that you easily oversee. This time around I understood it much more. Maybe it's that I've matured more or maybe I read it too quickly last time. Last time I understood it as Gregor Samsa just felt forgotten and dying. This time I realised that it abstracts so many other forms of social development. I had not understood the importance of the mother, the father and the sister. They in themselves represent different layers of social groups in a very well hidden way. Before I used to think of the members of the family all as one entity.

This was also the first I've ever read a book on screen. It's definitely not an alternative to read long novels on the computer but Metamorphosis isn't very long and I was curious what it'd be like to read a book on the screen. The biggest problem I think is the sitting position. If laid back and comfortable and it becomes hard to focus on the little letters and to close you end up with neck strain and tear running eyes. Nothing beats the paper alternative. The question is, what's the next ideal digital alternative to reading from paper?

Fat food = fat kids?

March 28, 2004
216 comments Misc. links

baggy pants Kids love McDonald's, but should they? The picture says it all: Don't eat at McDonald's!

Apparently McDonalds is about to start selling kids-clothes that will endure "season after season". Of course you get suspicious.

But isn't it possible that McDonald's already have sponsored the awful baggy pants trend that's plagued the beginning of the 21st century.

EuroPython in Sweden, I should go

March 24, 2004
0 comments Python

I'm actually going to Sweden for a Kung Fu competition on the 12th to 13th of June this year. The competition is not too far away from Göteborg so maybe I can get both done in one trip.

Let's hope I have finished my exams by then.

Google PageRank algorithm in Python

March 21, 2004
27 comments Python, Mathematics

There are many articles on the net about how the PageRank algorithm works that all copy from the original paper written by the very founders of Google Larry Page and Sergey Brin. Google itself also has a very good article that explain it with no formulas or numerical explanations. Basically PageRank is like social networks. If you're mentioned by someone important, your importance increases and the people you mention gets upped as well.

We recently had a coursework in discrete mathematics to calculate PageRank values for all web pages in a web matrix. To be able to do this you have to do many simplifications and you're limited in terms of complexity to keep it possible to do "by hand". I wrote a little program that calculates the PageRank for any web with no simplifications. The outcome is that I can quickly calculate the PageRank values for each page.

Here's how to use it:


from PageRank import PageRanker
web = ((0, 1, 0, 0),
       (0, 0, 1, 0),
       (0, 0, 0, 1),
       (1, 0, 0, 0))

pr = PageRanker(0.85, web)
pr.improve_guess(100)
print pr.getPageRank()

Truncated! Read the rest by clicking the link below.

What's so bad about HTML guys?

March 20, 2004
2 comments Web development

Swedish 99Kronor.com decides to ignore the power of HTML completely. Their website is just one huge image with an image-map for the links. That one image is heavy to download and takes 15 seconds to download on a 56K modem according to Web Page Speed Report. This is considerable more than a few of their competitors I looked at as well.

The biggest problem is on the other hand that the pages are completely in accessible on basic browsers like mobile phone or PDAs. Blind or visually impaired people might as well give up on it. Not to mention the hassle in the future when they want to redesign things or change the content.