Blog

Cooking eggs

Ok, I have to admit it – they tricked me. Maybe I’m becoming old… There was this picture of an egg between two mobile phones. The text: “Set the two mobiles to call each other and after an hour or so you’ll find that the egg is cooked.” (For a more convoluted story in italian or another one in english). Now there should have been some warning signals. I mean, I know that the maximum emission of RF-energy from a mobile phone is from its back, so that it won’t waste energy into your brain, but in the opposite direction which is more promising for being obstacle free. Also, the GSM frequencies are not the same of your microwave oven. And microwave oven frequencies are tuned to have the best warming effect on the water molecule in foods. Alas, believing that something so simple and dramatic at the same time could reveal the real danger of pervasive wireless communications was too tempting.
The hoax is easily spot if you could do some math. I should have done it first, before blindly believing.
Talking about believing, I found this site (in Italian) that is plenty of food for thoughts, just be careful of not eat too much. Avoid it if you are sensitive on religious topics.
The link of the day is the Linux revenge for my rants against it. If you have Windows XP then you may have tried to search a bunch of file for a specific word. If files are recognized by Windows then there is no problem, but if files are not recognized (maybe just an unknown extension) then you won’t find anything. To “fix” this behavior is really simple, just twiddle bits in the registry. Enjoy!

Humble programmer

This thing of Humble Programmer really got me. I think that, in the unlikely case that someday a wannabe programmer would come to me asking for advices on how to learn programming and how to become really good at it, I would suggest that he needs just two things – humility and will to understand. I have to be honest, I didn’t read the original paper by Dijkstra. I tried, but it is very long and the introduction is nearly as long, and … ok I know, I should have. Nonetheless I read books and magazines and grasped the idea of “humble programmer” elsewhere.
So, what so powerful in being “humble” at programming?
Well there is so much to learn, because you question your approach and your solution rather than the world. How many times, when the code is malfunctioning, do you blame Microsoft, the libraries, the kernel, the compiler?
It is easy to take for grant that the problem is someone else fault without really investigate the matter seeking for objective proofs. If humility is not for you, then you can consider it as a sort of attempt of substantiated arrogance. From my experience during investigations I realize that a) it was my fault (more or less subtle anyway) and b) now I better understand the system and c) not only I’ll avoid this problem in future, but also I’ll avoid an entire family of related problems.
It is a long time I don’t stumble in a compiler bug. Really. I was used to finding some back at Amiga days (Lattice C), and still some at the beginning of (my) PC era (Watcom C/C++), but that means 10 years ago. And that makes sense. Both Gcc and Microsoft Visual C are very mature products (ok, let’s forget for a while the problems with managed C++ and the like, these are young, recently introduced technologies). The chance of hitting a bug writing even non-trivial code are so far fetched that maybe it’s more likely being hit by an asteroid while walking in the street.
Anytime someone calls me invoking a compiler bug as the cause for a problem, my eyebrow automatically raises in a Spock-like manner.
The will to understand is the complementary force guiding to great programming. Every time you are in a hurry, twiddling the code to make it work, without really understanding what’s going on, you are in double trouble. First if you don’t understand what you are doing (that’s research? ;-)) you are likely to fill the matter with subtle problems ready to strike on your back as soon as you get distracted. Then you are wasting the chance to increase your comprehension of the system, the chance to better handle it in the future, you are intentionally keeping your tool chest from growing with new powerful tools.
Ok, humble, but boring, I’m quitting here 🙂

Deception Point

This book (Italian title – “La Verità del Ghiaccio”) is definitively confirming the idea I have about Dan Brown. I think that he is a master in writing addictive books, but he is equally poor in devising characters and plots. The scenario is the election of the president of the United States. There is the Good Guy who is the president in charge and the obviously Bad Guy who is the contender.
In the foreground there is the Hero (more specifically a Heroine) that is called in Antarctica to examine an amazing discovery made by NASA.
But somewhere there is the Evil Guy who is maneuvering in order to keep curious and too bright people away from the truth. The Evil Guy is using the mythical Delta Force a special army that has no limit for its action and is used in covert operations.
The heroine and her friends risk their life several times and at the end the reader (maybe earlier if he/she is attentive) discovers who the Evil Guy is and how the Good Guy will prevail.

Dan Brown is able to write a book which you can’t drop after you start reading it. There is such a strong hook at the end of each chapter that closing the book requires an incredible amount of will.
Aside of this he plays cheap trick to channel the reader attention, to make him/her ignore the obvious solution. It is impossible that any scientist, even if at the beginning of the career could think that sea water fills a shaft well above the sea level. There is no need for the polar base commander to send a group of valuable scientist to do measurement by feet during a storm when they could use a vehicle.
The deception of the Evil Guy is the very same of the other two books. The Evil Guy is someone that is put under so good-natured light that the reader cannot suspect. A False Evil Guy is proposed so the reader is further distracted…. As I said cheap tricks, already seen in the “Da Vinci Code” and “Illuminati” (“Angeli e Demoni” in italian).
So, it is a strange feeling, I couldn’t actually put down the book, but I couldn’t like it. What a pity.

Two computers are better than one

So you are at the office and you badly need Linux as badly as Windows. Linux hosts the cross compiler and the tool chain for your project, while Windows keeps you in synch with the rest of the company.Dual boot is, of course, the way NOT to go. From my experience you end by using just one system. Beside that Fedora Core 5 support for NTFS is, to put it mildly, rough. You can read NTFS partition, but you cannot write, despite all the claims you find on Linux-Ntfs website. If you are incoscien… ehm, brave enough you can even try a captive NTFS driver that is supposed to wrap windows NTFS drivers. These drivers are pre-built for Fedora Core 4 and I wasn’t able to get things working on FC5. I actually have some work to do rather than playing with the OS.
Another option I haven’t tried (yet), but that friends tell me is working well is to use VMware. This is a system virtualization software that runs below one or more operating systems letting them believe they are alone.
Anyway having two PCs is always preferred, it is just annoying that you need two keyboards, two mice, and it becomes quite difficult at copy’n’pasting between the two.
Until this morning.
This morning, while sneaking over Freshmeat I found x2vnc a nice hack that, using the VNC system allows you to share the same keyboard and mouse with two PCs, one running Linux and the other running Windows, as it would be one dual headed system.
Now when I move the mouse pointer over the left edge of the Linux machine, the pointer “flows” into the Windows screen. Move it over the right edge of the Windows screen … et voila, it’s back to Linux. It even works fine when the Windows system is at the login screen (i.e. no user has yet logged in). It is so sweet that Copy’n’Paste works, too.
Great Hack.

Time awareness

I find extremely difficult being aware of the time required for various activities. I usually underestimate the time it takes to do stuff. Maybe the trouble is the delta between the speed of though and the speed of life. Usually life is slower and much more troublesome.An interesting technique for dealing with the troubled nature of real world is to add a margin to you planning. In “Game Development and Production” Erik Bethke suggest to consider a day a week as non-working in the planning so to get estimations that can survive to occasional disasters the universe is so generously filled. I usually do this and I find it is good, nevertheless my estimations tend to be optimistic.
One of the point of being aware of time is to recognize when using something pre-made is faster than rolling your own solution. So at last I have to admit that rewriting a new version of my website software from scratch is not something I can do now.
It is true that since I changed my job I have more time at home, but it is equally true that my main source of development time was in train commuting (notebook PCs rule). And I can’t do software development while driving car (apart from the travel to be much shorter).
So at last I resorted to look around what ready made software could do. I found two package that look promising: Drupal and phpWebSite. Unfortunately both require an SQL database which is not available in my current provider subscription. So I spent a bit of time and found pDB a complete SQL database implementation in PHP.
So now it is only a matter of making one of those package to use pDB and I should be done, fast and easy… wishful thinking 🙂

Fedora Core 5 – ready for the masses?

It is now somewhat more than a month that I’m using Linux Fedora Core 5 all day long. I have never used Linux so extensively at workplace (maybe with the exception of some periods when I worked at ABB, but then it was RedHat 4.2). How the system is doing when compared with, let’s say, Windows XP? Well it’s doing quite well. I mean that for a naive user everything should work as expected with minor annoyances. Quite unexpected the Windows power user could have some not so pleasant surprises. For example the default browsing system is a real pain in the neck. Every time you double click a folder a new windows pops up with that folder content, leaving the old window to clutter the desk. Moreover there is no way to turn this kind of windows (I reckon it is named “spatial browser”) into more conventional browser with their sidebar of directory tree. Every Linux enthusiast will advocate that you can turn off the spatial browser sticking back to what I would call the standard file system browsing window. It’s true, you just have to twiddle with some registry key. Well, yes, after all the criticism against Windows registry, Linux has one registry, too. It’s not something new in FC5, I think that this dates back around RH9. We can argue that is somewhat more friendly than the Windows one, yet, strictly speaking it is a registry.
After some time and frustration you can get used to right click on directory and select “Browse” in order to get the standard browser. It is not too close to the windows file browser (it can show files in the directory tree, and the navigation is not always intuitive) anyway could do.
Now, that you have a browser, maybe you are looking for a specific file. Windows users will find a “Search” (or “Find”, I’m not sure about the english text) item in the context sensitive menu of directory and drive objects. When turning to linux the same users will have quite an hard time to locate the same command. Being a long time unix user I find faster to open a terminal and cast a ‘find’ invocation. In the same way the context sensitive menu in the browse area doesn’t contain a “New folder” option, you have to right click in the directory tree sidebar.
When using windows, you can create a shortcut that points to anything you can browse in the file browser. That’s quite intuitive, I would dare to say that they have copied the Unix concept of soft link. Double clicking on the shortcut it is the same as double clicking on the object pointed to by the shortcut. In Linux you have basically the same tool, but it doesn’t work if you link a file in the network. I don’t know exactly what the problem is, I think that not every application recognizes the network file names (that look something like smb://host/path or cifs://host/path). If you want to do something like that, you need to be root and mount the network server into your filesystem and then create a local link.
While talking about files, the Windows user expects to share her/his files on the network. It is useful. After all what would be the purpose of the network if not sharing files? Under Linux the normal user is prevented to create a share where she/he wants to be. If you browse the documentation long enough, you’ll discover that you can create a directory named Public in your home directory that can be shared. First root must enable this feature, then the user has no way to control the access in this share. With Windows it is straightforward to set the share permission so that only some users or computers can read or write.
Let’s quit playing with and do some real work. Fire up openoffice calc … wait while the application fully ignite… then start working. FC5 is much faster than previous FC, but it is still slower than Windows when it comes to launch office applications. Now insert some data, formulas and create a pretty diagram. The average spreadsheet user shouldn’t complain for lacking of functionalities. Now that you have such a beautiful diagram you want to show it to someone, possibly your boss. Easy. Select the diagram, copy it, create a new html/rtf mail message in Evolution and paste it… and stare at the empty message. There is no way to do it. You can quite confidently copy’n’paste plain text, rendered HTML works fine too, but images don’t. The only way I found to do this is to export the diagram in some standard file (EPS or SVG) and then import it in the mail message.
It is time to talk about system stability. The matter is very delicate, there are a number of factors (broken or nearly broken hardware, broken software or messed up configurations) that can bring a system to its knees. I remember the first times in UbiSoft when my Win2000 blue screened every day. Eventually it turned out it was a problem with bugged video drivers. I had quite busy Linux box running without a hitch 24h a day for nearly a year. So this talk is to be taken with a grain of salt. Well I found FC5 not very stable. I have either to log out, or to power cycle it about once in two working days. It is true that I had to compile my own wi-fi USB dongle drivers, on the other hand it is true that the dongle has Windows drivers. In a perfect world I wouldn’t be required to compile my drivers. The weak component seems to be the user interface that sometimes loses interest for the world in general and for my input in the specific case. But I had also the keyboard stopping to work (no caps/num lock toggling), the system freeze on USB dongle removal and so on.
Ok, you get what you paid for, and to be honest, with FC5 you get a lot more than you paid for. Anyway, despite the long way it walked from slackware days, Linux has still some road to go to catch up Windows in everyday usage.
The trick of the day is “How to have lot of screensavers in FC5”. You are a geek (otherwise you wouldn’t be using linux), so screensavers are an indication of your geekness. The more the geeker. You would be rather disgruntled to find that FC5 comes, by default, with 5 dumb and dull screensavers. Searching the rpm package list, you find the good old xscreensaver. You install them, but… you still are stuck with the 5 boring ones. You have to convert xscreensavers, with the following commands:

# cd /usr/share/gnome-screensaver/themes
# /usr/libexec/gnome-screensaver/migrate-xscreensaver-config.sh  /usr/share/xscreensaver/config/*.xml

Since I’ve been really kind to Microsoft, I think it is fine to rebalance the post, therefore the link of the day is John Dvorak’s Eight Signs MS is Dead in the Water a pointer to an article that expresses some concerns about Microsoft future.

ATM PIN

I would expect that the PIN digits have a quite good random distribution. Although impractical at the ATM point a smartened brute force attack could effectively work provided you have some machinery at home.Assuming that the distribution of the dirt per finger (or the distribution of cleaning factor per finger) is flat then the ATM pad at the gasoline station where I usually refuel my car provides some odd evidences.
The numeric pad has some keys clearly cleaner than others – ‘7’ and the square ‘5’, ‘6’, ‘2’ and ‘3’ are much more clean than the rest.
The site of the days is also the application of the day: GNU Talk Filters. Moreover cleans up the mistery about how Zom3 PE0pl3 sUCc33dZ pErZYZt3N7lY IN wRYT!n6 l1cE Th!S.

Adventure in cross compiling land

If you have a C background you may find correct and appropriate that filenames are case sensitive. After all ‘a’ is different from ‘A’ as much as 65 is different from 97. If you have a BASIC background you may equally find correct and appropriate that filenames are case insensitive. It doesn’t matter how you write it, it is always the same character.
Every approach has its strengths and good arguments. The problem arise when one of the parties blindly ignores the rest of the world.
Well this may sounds like gibberish until you try to compile the linux kernel on windows. In this impressive set of source there are a bunch of files in the same directory that have the same name case-insensitive-wise. Moreover, if you untar the sources you get no warning sign since the tar command silently overwrites existing files. You get some hint of the problem when you copy sources with the windows GUI from a samba share to you local disk.
The problem is not so hard indeed, but if you don’t want to tamper source file structure it is better to rely on a case sensitive filesystem. That means that you cannot use Windows.
So I switched to Linux. After all FreeScale gives you the ready made cross compiler for Linux, so it is a clear sign of the way to go.
At workplace I installed the recently released Fedora Core 5. (Yes, I just completed a satisfactory configuration of the FC4 on my laptop 🙁 ). I must admit that Fedora Core, at last, has an original look. And a good look. Apparently they stopped following Redmond and Cupertino and started to set their own trend. Well done, I like it.
On the other hand having FC5 seamlessly working in a Windows environment is not something for the faint hearted. Be prepare to a good amount of swearing before you can resolve names, browse windows shares and access files there contained. Once done it works very well.
Back to Linux kernel compilation. Despite of what you may think by a look at my desk, I like cleanness and order, at least in files. So I want to store in the versioning system nothing that can be derived, just primary sources. With Kernel source this is a little fuzzy. In fact you download sources that are ‘distclean’ed. I.e. no kernel configuration is set. First you configure the kernel either by issuing one of ‘make menuconfig’, ‘make oldconfig’, ‘make xconfig’ or by picking up one of the precanned configuration by typing something like ‘make xyz_config’.
Anyone of these performs some operations – a file ‘.config’ is placed in the kernel source root, some symlinks and some files are created. So far so good. A file named ‘autoconf.h’ is required in order to build the kernel. This file is just the C version of the ‘.config’ file. In other words and simplifying a bit, in ‘.config’ you find something like ‘VALUE=y’ and in ‘autoconf.h’ you find ‘#define VALUE 1’.
Now I would expect that ‘autoconf.h’ is created from ‘.config’ somewhere in the Makefile. This is not true. The only way to create ‘autoconf.h’ (I found so far) is to interact with the system using one of the ‘make *config’. This is bad to me, since it prevents a fully automatic build.
On the other hand it is true that the configuration changes quite seldom, so you don’t have to ‘make distclean’ a lot and the ‘.config’ file you generate will be with you for long.
Maybe I didn’t search enough, but I have to do some actual work and produce some results beside googling for answers trying to bend universe to my personal view.

Cross compiling

Have you ever tried to build a cross compiler under cygwin? Today I tried to do exactly this. Well I quite underestimate the complexity. After all many Unix programs can be happily compiled without much effort under cygwin, why gcc should be different?A cross-compiler is somewhat convoluted, in fact you have first to build a bootstrapping version of the compiler in order to compile the standard C library. Before compiling the compiler you need the binary tools compiled for the intended target. The library needs some information from the operating system. Since my goal was to produce a cross compiler for embedded Linux running on ARM 9, I had to do something with the Linux kernel.
When you successfully compiled the compiler and the library, you have to compile the final compiler.
Luckily today there is internet and google ready to help you. I found many pages and advices, but I haven’t yet achieved my goal. Moreover it is not clear to me whether the cross compiler supports by default all instruction mode that an ARM920 makes available – native, thumb and jazelle. More on this in the next days.

Misc fixes

Here you are some fixes to the blog. First the mail address available in the left panel is always correct. Previously some parts of the site yielded the “%MAILURL%” mail address rather than a valid one.Next comments can now be added to the book reviews even when you access the review from the review index (now renamed in “book reviews” more clear than the previous “readings”).
Aside, I’m changing job, I’ll write soon about the new experience.