Wednesday, February 28, 2007

Restoring PocketPc on an IPAQ H3950

I once installed Familiar Linux on an IPAQ 3950 of a friend of mine, who now decided to have PocketPc back.

Of course I had previously saved the wince_image.gz for later restoration. Thus, I went to the handhelds web page and lurked into the documentation to find some hints about the restoration. I found this document that seemed to fit my needs.

This basically says to reboot the pda, get to the boot prompt via a serial communication program (I used hyperterminal) and load the wince_image.gz.

Unfortunately, this method does not seem to work, and when the transmission of the wince_image.gz ends (it takes about half an hour!) the pda complains about the size of the image file.

Luckily, I found this other document,, which says that you need to prepare your image file first, if you have an H39xx or H5xxx with these 3 steps:

gunzip wince_image.gz
dd bs=1k count=32256 if=wince_image of=root_image
gzip -9 root_image
Then, you must upload root_image.gz.

With this solution, the image loads successfully, and after that I could issue a boot wince at the boot prompt (in the serial communication program). After that, resetting the pda brings back PocketPc.

Saturday, February 24, 2007

KLcdDimmer 0.3

I've just released the new version of KLcdDimmer, a KDE applet to adjust LCD brightness (see also this post). The main novelty is the new graphical layout of the applet, which now fits better in the panel (takes less space, and works also both when the panel is vertical and horizontal).

Friday, February 23, 2007

Grab the content of the html body in Php

It's quite usual to use the include function of php to include html files into another html or php file. In order for the resulting output to be a correct html output, the html header should appear only once (and outside the body). Thus, the included html files should not contain the header, but only the body contents. If, however, you write all these html pieces using a WYSIWYG editor, these html will end up having their own header.

Thus, when including these html pieces from a php file, you should strip header (and closing html tags), and get only the contents included in the body tag. By using regular expressions it's pretty easy to do that.

This is my simple implementation:


* Returns the body content of the specified HTML file.
* @param string $filename
* @return string
function getbody($filename) {
$file = file_get_contents($filename);

$bodypattern = ".*<body>";
$bodyendpattern = "</body>.*";

$noheader = eregi_replace($bodypattern, "", $file);

$noheader = eregi_replace($bodyendpattern, "", $noheader);

return $noheader;


Wednesday, February 21, 2007

Debian Iceweasel (upgrade to

The update of Iceweasel (the Debian version of Firefox), version seems to be very unfortunate.

First of all, after the update, when running the new version, the import profile wizard came out and after this, a brand new profile of iceweasel came out, just like I'd lost my previous profile.

Fortunately, my previous firefox (or iceweasel) profile was not lost... simply, a new directory (called, indeed, iceweasel) was created under the .mozilla directory.

So, I only had to remove the new iceweasel directory and make a symbolic link, with the same name, to my previous firefox directory.

Some problems, however, still existed: when clicking on an URL from within Thunderbird (well... yes, OK, Icedove in Debian), if a running instance of iceweasel was present, the present error came out:

Iceweasel is already running, but it is not responding. To open a new window, you must first close the existing Iceweasel process, or restart your system.

Fortunately, the solution is illustrated in this bug report, and simply consists of changing this line in the file /usr/lib/iceweasel/iceweasel:


instead of


And then, everything worked as it used to do before...

Thursday, February 15, 2007

Eclipse, Php Ide and Gentoo

As I said yesterday, I successfully installed eclipse and phpide in my Gentoo box. I had also set up the link to mysql socket, as I had explained in my previous post.

However, as soon as I tried to run a php script that uses mysql functions I got this error:

Warning: mysql_connect() [function.mysql-connect]: Client does not support authentication protocol requested by server; consider upgrading MySQL client in /home/bettini/workspaces/php/dbtophp/share/db.php on line 23
could not connect to database

Fortunately, this is a known error in mysql documentation:

In fact, I just did what that page says, i.e., reset the password to the "old" style:

mysql> SET PASSWORD FOR 'some user'@localhost = OLD_PASSWORD('your password');

and the error went away.

Probably this was due to the fact that mysql is version 5.0, but the php engine that comes with phpide (and that I use for running and debugging scripts from within Eclipse) still uses the old mysql functions for connecting to the database.

Wednesday, February 14, 2007

Apache2, PHP, MySql (Gentoo Linux)

I've just installed Apache, Php and MySql in my Gentoo box; I've always used these programs and servers only under Debian since they looked easier to install (or probably they looked harder to install in Gentoo :-). I actually found out that it's quite easy to install them in Gentoo either!

I followed some documents found on the web, but basically the installation procedure was even faster than that found on the web:

I put these lines in /etc/make.conf:

USE="apache2 mysql php pam ssl xml xml2 berkdb innodb jpeg png"

If you want to install also phpmyadmin, then you should also add pcre session unicode:

USE="apache2 mysql php pam ssl xml xml2 berkdb innodb jpeg png pcre session unicode"

then I simply ran:

emerge dev-db/mysql apache php

after few minutes (well... half an hour would be more appropriate) the installation terminated successfully.

I then changed the file /etc/init.d/apache2, in order to enable public_html folders for users (corresponding to the ~ directory), setting -D USERDIR:


Before starting mysql, you must create (once and for all) the mysql main database, and this can be done simply by running:


then you're ready to start apache and mysql.

Wednesday, February 07, 2007

Got rid of FAM (inotify)

I finally got rid of FAM (File Alteration Monitor).

Quoting from

FAM provides an API applications can use to be notified when specific files or directories are changed. It is intended to be a more efficient and more useful replacement for alternatives such as the poll and select system calls.
FAM is most useful for tools such as graphical file managers, which should always show the current state of the system, even if another tool is used to modify a file.

The problem with this software was that it sometimes hanged and took all the CPU time.

Luckily, now this mechanism is handled by inotify in the linux kernel itself, so I could uninstall fam. :-)

Sunday, February 04, 2007

checkDate in Javascript

I know there are lots of implementations of date validation in Javascript out there, but I've just started learning Javascript and wanted to share this implementation with you, so here are my first two little javascript cents:

function checkDate(month, day, year)
var monthLength =
new Array(31,28,31,30,31,30,31,31,30,31,30,31);

if (!day || !month || !year)
return false;

// check for bisestile year
if (year/4 == parseInt(year/4))
monthLength[1] = 29;

if (month < 1 || month > 12)
return false;

if (day > monthLength[month-1])
return false;

return true;

Thursday, February 01, 2007

Enjoy Unix!

I've just come across this comic... it's so funny :-D