The Geeks Revenge

April 29, 2005
0 comments Misc. links

This is yesterdays's Dilbert (28 April 2005) but I guess its genius had to sink with my slow brain. It's just so funny. Yesterdays Dilbert

Being a geek myself I unfortunately resemble myself in Alice here.

TAL here hack in Plone

April 28, 2005
1 comment Plone

Had to do a very useful and ugly but also smart hack in Plone today.

In the portal root I have a Document with Id index_html that the client is changing with the WYSIWYG editor. What I wanted to do was to change some METAL calls in the <head> tag of that one document. In fact, what I wanted to do was to cover up the left hand column which is done this way:


  <head>
       <metal:override fill-slot="column_one_slot" />
 </head>

The problem was that the index_html Document is a Document so I can't edit it's TAL. I could have customized document_view.pt but that would have applied for all Document objects in the site. Here's how I solved it:

Truncated! Read the rest by clicking the link below.

Gmail shortcuts

April 26, 2005
4 comments Linux

If you use Gmail but haven't started to use the keyboard shortcuts, then you're really missing out on something.

A peculiar thing is that when you enable it you get the extra > pointer along the side which makes it possible to navigate up and down. Anyway, when you're in the inbox you us k for going up (new emails) and j for going down (older emails). BUT when you click on a conversation (several emails all with the same subject line for people who aren't familiar with Gmail yet) there are other keys for going up and down. This time it's p for going up and n for going down. Why can't it be the same which would make it two keyboard commands less to remember?

Truncated! Read the rest by clicking the link below.

Grep results expanded

April 23, 2005
5 comments Python, Linux

I find myself often running a grep command with the -n which means that when it shows the filename it also shows the line number it matched it on. Then what I often do is that I open the found file with my editor and move to that line with the gotoline feature. Here's a cute little bin Python script that expands the result a little bit. Try:


$ grep -rin 'def set' *      
frintranet/sequence/tests/testSequence.py:26:    def setUp( self ):
slimmer/tests/testSlimmer.py:37:    def setUp(self):
slimmer/tests/testSlimmer.py~:37:    def setUp(self):
slimmer/tests/testSlimmer.py.bak:42:    def setUp(self):

Truncated! Read the rest by clicking the link below.

Serious flaw in Bose headphones

April 23, 2005
7 comments Music

Perhaps you saw my praise over my new Bose headphones with noise reduction a couple of days ago. Well, now I've discovered a serious flaw that I didn't realise before.

When you run out of batteries, like I have now, the headphones don't work at all. Granted that the noise reduction feature can't work without batteries but I should at least be able to listen to music in them don't you think?

It should work like this:


function listen2music():
    if hasBatteryPower():
       playMusic(enable_noise_reduction=true)
    else:
       playMusic(enable_noise_reduction=false)

pg_class to check if table exists

April 20, 2005
4 comments Linux

I just learnt a better way to check if a PostgreSQL table exists. Before I did this to find out if table mytable is defined:


SELECT * FROM 'mytable' LIMIT 1;

But this had to be wrapped in exception catching application code because I was able to tell if the table existed if the select statement worked. That's the wrong and naive way. The correct way is to use pg_class and look at how many rows were returned:


SELECT relname FROM pg_class 
WHERE relname = 'mytable';

Why have I missed this before? No explanation?

A disadvantage with using pg_class is that it's not ISO standard, meaning that it's specific to PostgreSQL only. The first pattern will work on all relational databases.

Google blogs about their Maps

April 19, 2005
0 comments Misc. links

This is possibly the best blog entry I've seen in many months. It's a summary of some really interesting Google Maps searches

The quality still isn't great but the potential sure is interesting. I for one love the airplane graveyard search

North america sure is interesting geographically because it's so varied but just imagine the potential when Google Maps reaches the whole world! (probably not North Korean) And on this page, make sure you have a look at the slideshow in the Wired article they link to.

"Can you help me about ZOPE?"

April 18, 2005
2 comments Zope

Not sure what people think of me but I get a lot of strange emails. Last week I got an email about a guy wanting me to teach him Kung fu via email correspondence. Today this arrived plus can see what my reply was:


Yeah, sure. Don't bother reading any documentation or books. Forget 
about installing it and playing with it because the only way you'll 
ever learn is by me explaining everything via email to you. Now, were 
do we start? Shall I maybe just take the rest of the day off and 
theorise about the kind of questions you might have?

On 4/18/05, [[name hidden]] <[[Email hidden]]@yahoo.com> wrote:<br />
> Could you help me about ZOPE. <br />
>  
> 
>  ________________________________
> Yahoo! Mail Mobile
>  Take Yahoo! Mail with you! Check email on your mobile phone. 
> 
> 

-- 
Peter Bengtsson, 
work www.fry-it.com
home www.peterbe.com
hobby www.issuetrackerproduct.com

Do you think I was too harsh on him/her? Or more interesting, do you think he/she understands my sarcasm?

Noise reduction headphones

April 16, 2005
1 comment Work

My kind company just gave me a little gift to make our office environment less noisy. A pair of Bose noise reduction headphones. Click here for a picture

I was sceptic at first thinking that noise reduction will work but only in such a small way that one might as not bother. Boy was I wrong! It actually only really works if you play music through them. Unsurprisingly the sound quality is stunning (wouldn't expect less for that price :) and when you play music it starts to look like people are miming and you stop hearing little noises like tapping the keyboard, distant phones ringing and air conditioners. From now I'll have to keep my mobile in my pocket so that I can feel it vibrating because I've missed a call when the mobile was on my desk and I didn't notice at all.

They really work! A word of warning though, not having music is pointless. Noise is reduced but you can actually hear the headphones themselfs in a strange way. It's difficult to explain but it sort of rings in your ears like when you exit a nightclub and come somewhere it's quiet. If you don't want music and just quiet, just buy some ear plugs