October 7th, 2008
Lately I had a problem with a page which was including two JSON scripts, one encoded in UTF-8 and the other encoded in ISO-8859-1.
In some circumstances (and in some browsers) the strings where not showed correctly.
Hunting down the problem required a good dose of my favourite tool wget -S where the -S option causes the http response headers to be printed on stderr.
My conclusions are that:
- if a page uses a certain encoding (as specified by the charset on the page and/or the Content-Type http header) the included javascript will be handled with the same type of encoding if nothing else is specified
- In Firefox, if the http response of the javascript contains the “Content-Type” header with a charset value, the file will be treated as using this encoding
- In Internet Explorer 6 (and 7?) the http headers are ignored and you must explicitly use the charsets attribute of the script tag to force the correct encoding
In other words, to make a script inclusion cross-browser and independent of the encoding of the page you are including the script, always use the following if your page is using iso-8859-1
or
if your page is utf-8.
And of corse, make sure your http headers match the content!
October 3rd, 2008
I was mavenizing a java project (I was using ant earlier) on my macbook and I realized that since I was using UTF-8 on my macbook the files were compiled using UTF-8 instead of ISO-8859-1 (some strings where corrupted).
The solution is to add the encoding parameter to the maven-compiler-plugin
October 2nd, 2008
This is just a list of things I think you should master if you want to be a good web programmer (and not only)
* Unit testing
* Refactoring, you must have a copy of Refactoring: Improving the Design of Existing Code
* Design Patterns, read Design Patterns: Elements of Reusable Object-Oriented Software
* Dependency injection and why you should use it (and if you use java what is Spring)
September 28th, 2008
Fastest ever! It just flowed.
As I present I bought me an iPhone.
September 22nd, 2008
I erroneously ordered som ram for a friend which did not work. I then tried it on my MacBook and now I’m running 3 GB instead of the officially “max 2″ supported.
The module I installed is named: VS2GSDS667D2 / Corsair Value Select VS2GSDS667D2 2048MB SO-DIMM DDR2 PC2-5300 667MHz. It works like a charm. More RAM to the people!
September 19th, 2008
When using the ant-run plugin you can get references to the maven classpaths in the ant fragment
Those are the ones available:
- maven.compile.classpath
- maven.runtime.classpath
- maven.test.classpath
- maven.plugin.classpat
I tried to build an ant plugin for maven as explained in http://maven.apache.org/guides/plugin/guide-ant-plugin-development.html to refactor out the ant fragment and all went smooth until I needed a reference to the maven classpath.
I just assumed I could use the classpath references in the maven-script-ant plugin.
I took me a while to realize that the 2.0.9 version of the maven-script-ant has no support for it and that support is currently available on trunk.
I had to download the source code and build 2.1-SNAPSHOT.jar by my self.
September 2nd, 2008
If you need a compact way to use prototype and listen to on onresize event in a cross-browser manner, this is the way to go:
As you can see, the event to listen is resize but depending on the browser, it may be fired on either the window or the document object.
Quirksmode has as usual an explanation of which browser support the one or the other
Of course, you should never use the apparently simpler
if you want a robust solution since you will overwrite any other event listeners that can have been
add by other libraries (Bobobobo has a bad example)
September 2nd, 2008
Updated: my previous attempt to simulate inheritance in javascript using Prototype.extend did not work as I expected so I removed the example I had written.
Inheritance can be defined in several ways. The definition of inheritance I will use in the following example is: A child class inherits from a parent class if all methods of parent are available to the child and the child methods override the parent’s ones. The child methods which are not defined on the parent must of course be available on the child object.
And now let’s define a simple class which will act as a child:
To use our subclass, we will run:
Please observe that the parent constructor is totally ignored by this inheritance simulation
August 29th, 2008
I love iPhoto. It just bugged me that I could not zoom to “100%” to compare my pictures at their original resolution. I just found out that if you select one or more photos, right click and “edit in a separate window” you can choose the zooming level from a scroll down menu! Great!

August 29th, 2008
I had never noticed a behavior which left me astonished
If you have two nested divs and are listening for the onmousover event on the parent div, you will get a onmouseout event when entering the nested div!
As I see it, since the mouse has not left the area covered by the red div, I would not expected a mouseout event. How do I now know when the mouse leaves the red box and when it only mouse on a nested element?
Move the mouse into the blue box passing through the red one to see the fired events:
If you wan to know when you exit the parent container (and not when you are on the red box), you can listen for mouse over events on the body and detect if the element triggering the event is an contained in the parent. Just think the other way around!
« Previous Page — Next Page »