❯~/pixelastic

Debugging a Squirrel webmail

This is a quick blogpost, essentially as a reminder for myself:

A client of mine is using the Squirrel mail webmail. Once in a while, I have a call from him telling me that he can't access its account. The cause is always the same: there is way too much mails saved in his account and Squirrel mail choke on this, refusing to display the page.

The solution is simple, I just have to remove all the mails (except maybe the 100 or so last ones) and save them in a another directory, for archiving. The directory to save is /home/mailusers/c/contact/cur

But, thinking I was clever, instead of copying all the files to a new cur- save-2009 directory I thought it would be faster to rename the current directory to cur-save-2009 and create a new empty cur dir. Except that I forgot that I was loggued in as root and the directory must have a user/group set as postfix...

That's it, I just had to not forgot to set the owner/group of the cur/ directory as postfix once cleared.

Database in UTF8 with Coldfusion

When setting up a Coldfusion application, do not forget to add to your datasource the following connection string:

characterEncoding=UTF8&characterSetResults=UTF8

It will ensure that your data is correctly saved and fetched using UTF8. This is the coldfusion equivalent of the more commonly known SET NAMES 'utf8';

Never use alert() for debugging

One thing I learned today is to never use alert() for debugging pruposes. When the javascript alert() function is called it blocks every other action until the OK button is pressed. It means that your javascript code that is immediatly after the alert() call is delayed until you press OK.

It also means that the thread your browser gave to the javascript engine is halted during all this time.

Imagine you are binding keyboard shortcuts on your website to specific actions. Like pressing Ctrl+S will submit the current form. Of course, Ctrl+S is already defined as a shortcut in the browser, so you will take care of preventing the default behavior in your custom function (using return false, e.preventDefault(), e.stopPropagation() or any method defined in your framework to do that)

The problem is that is you call alert() in your function, the Javascript thread will be halted before you can make the call to stop the propagation and thus, the browser will take control again and firing its default shortcut.

So my advice is that you should never use alert for debugging. Use the console.debug() method shipped in firebur or directly write to the DOM but do not use alert().

Writing a class in Javascript

I always have to refer to a manual or a webpage to remember the correct syntax for creating a new class in Javascript. Here it is:

myClass = function() {
    // Here I can define private variables and methods
    var myPrivateVar = "foo";
    var myPrivateMethod = function() {
    };
    // And now I will return an object, so it is the place
    // to put public variables and methods
    return {
        publicVariable: 'bar',
        publicMethod: function() {}
    };
}(); // Note that this function is executed and so the object is returned.

Learning extJs

Today, the jquery 1.4 version was released, and today is the day where I start to learn extJs (don't ask me why).

EXTJs seems to be promising, it seems really easy to make powerful and professional-looking interfaces for handling data with it.

When learning Coldfusion I was often horrified by the [really poor html example code](http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77 859461172e0811cbec22c24-79f9.html) shipped with the Coldfusion example: , , multiple nested tables.

With EXTJs, it seems to be the same, the basic page setup tell me not to put a Doctype to my page to "avoid IE problems", as well as putting my javascript in the head of the page...

That is simply horrible advices. I hope the rest of the framewok is not of the same kind or learning it will be painful.

One thing that is quite frustrating with their documentation is that it is absolutly not up to date. It is refering to 1.0 or 2.0 version even if the current one is 3.0.

I resort to reading the "Learning EXTJs" book (if you know how to properly use google, you should find a full PDF online). It told me a lot of things about the approach of the framework, I sincerely recommend that you read it if you want to learn ExtJs. Too bad the book was released before the 3.0 version, but by refering to the API whenever you need to use a new class, you should be ok