Monthly archives: September, 2006

The web is not to print, but to scan

This week I have had a lot of dead time in the office (while waiting for the client’s answers), and I’ve been reading some web usability articles from Jakob Nielsen’s website. I have read almost every column he wrote, and I think I already knew most of the key issues (like colors for links, big fonts, etc). He writes using the common sense, so it’s quite easy to arrive to most of his thoughts on your own. But I’ve also discovered some interesting ideas, that are letting me think about it… and I want to comment one of them: We scan web pages, so we don’t need perfect design.

In the office I’m surrounded by a lot of graphic designers, who spend most of the time building “perfect” designs. “Pixel perfection”. Everything perfectly aligned. Later we spend a lot of time translating them to HTML and CSS, keeping these exact pixel measurements in every known browser. I see some of my coworkers spending a lot of time making CSS hacks to fix such small design problems (and becomimg proud of this). Is it really necessary? Internet is not a print medium, where everything has to be in a perfect position. Internet is a place to look for information, where we scan pages, quickly. Of course, the look & feel of a website is quite important, to help us to figure out at sight if this is a “good or believable” place. But it doesn’t matter if the menu is moved 1-pixel to the left if you visit it with Explorer instead Firefox. Because what the user really want is information, served in an easy way to find out.

Hey girl, you look so pretty, but do you have something inside your head? No? Then the most you can aspire is an one-night relation, and the next day he will not remember you. Sad but sadly usual.

Update: I see these ideas, concerning to avoid working on pixel perfect positions, over and over. The last time that I’ve seen them, it has been reading “A List Apart” lastest article: “12 Lessons for Those Afraid of CSS and Standards“, where the author refers to these ideas several times.


Philosophical thought of the week

A morning office conversation:

Tony (a workmate): Is there a PHP function to stop for a moment the execution of a page?
Me: Yes, it is “sleep()”.
Tony: Just what I need, to sleep a little bit. Does it work with microseconds?
Me: No, it works with seconds. For example, if you write sleep(1), it is going to stop for 1 second.
Tony: Ok, thanks, you are a crack.
Me: And, even more, if you write sleep(2), it’ll stop for 2 seconds.
Tony: Why don’t we use it with a negative value? Probably we will speed up our websites!


Beware of the Python on the Window (XP)

Two years ago, I arrived to Barcelona to continue my Ph.D studies. Two years, how long!, who could imagine all the things that were going to happen? In those days I was looking for a programming language to “fast-prototype” my ideas. The final match was between Python and Ruby, and I finally started to learn “the snake”. But due to a lack of research funds, I had to stop it and start working in a private company, and I didn’t really make a lot of use of Python.

Now I’m rediscovering this programming language, because I feel I’m using PHP too much (among other causes). So I started using Python again, and to start with, I tried to solve a problem/need I had:
– I had 42000 files, containing Go games (*.sgf)
– I wanted rename those files from ugly numbers to something like year-player1Name-player2Name.sgf.
– Some files had the header information coded in UTF-8, with player’s names written in Japanese characters.

I love Unicode’s UTF-8, with these lovely Japanese ideographs (and, of course, my favorite one is code “7881“). I’m using WinXP (yes, I’m a masochist), and I’ve read it natively supports UTF-8, so I thought it was a nice idea to have file’s names with Japanese calligraphy. Finally the result was beautiful… but 2 problems appeared:
1- Most of the Go-game programs on Windows are not prepared to read UTF-8 files, and crash. So I had to make a version without ideographs :-(
2- Windows throws an error after renaming 10000 files… maybe renaming 42000 files is too hard a job for it :-(

The code itself:
——————————

import glob,re,os,sys

pats = [re.compile(r'DT[(d{2,4})'),    #year
        re.compile(r'PW[([^]]*)'),    #player White
        re.compile(r'PB[([^]]*)')]    #player Black

files=glob.glob('*.sgf')
for file in files:
    fp=open(file,'r')
    content=fp.read()
    fp.close()
    info=[]    #were I'm going to save header info
    for pat in pats:
        try:
            detail=pat.search(content).group(1)
            detail=detail.decode('utf-8')
            try:
                detail=str(detail)    
                info.append(detail)
            except:
                info.append('kanjis') # replace ideographs
        except:
            info.append('unknown')

        info.append(file)
        newName = reduce(lambda x,y:x+'-'+y,info)
        try:
            os.rename(file,newName)
        except:
            print "Unexpected error:", sys.exc_info()[1]

print("Done!")

——————————
I know I can group exceptions, but I prefer to write in this way for an easy understanding. By the way, exceptions are one of the strange things of Python… IMO they are too “hardware” for this kind of language.