Javascript String.split() function behaviour

In one of my recent projects I had the following line of Javascript to split up a string based on opening "(" and closing ")" brackets.

"Hello(World)".split(/(\(|\))/)
I found that in Firefox 3, the split command would return the array: [Hello,(,World,),]
However in IE7 I would get this: [Hello,World,]

For interest sake I also tried it in Chrome and it does what Firefox does. This is one time that IE did what I expected while FF and Chrome seemed to stumble.

I eventually changed the regex to the following to get all the browsers to produce the same result (i.e. the one IE7 originally produced).
"Hello(World)".split(/\(|\)/)

Posted at at 12:16 AM on Tuesday, December 23, 2008 by Posted by Vince | 0 comments   | Filed under: , , ,

Making Compiz and SQLDeveloper Play Nicely Together

If you are running a recent version of Ubuntu and you need to use SQLDeveloper you will likely run into a problem where SQLDeveloper will load up as a blank window. This is due to the recent iterations of Ubuntu enabling Compiz in the default installation. There is a known problem with Swing applications not displaying properly with Compiz enabled.

There are two options. If you can live without the extra visual effects then you can simply disable Compiz as follows:

  1. Navigate to System -> Preferences -> Appearance
  2. Go to the Visual Effects tab
  3. Select "None"
If you would rather keep Compiz enabled because you like the wobbly windows then you can try the following:
  1. Open up sqldeveloper/sqldeveloper.sh in a text editor
  2. Add the following line before the last line in the script.
export AWT_TOOLKIT="MToolkit"
You may have to use "MToolKit" with a capital K, but the lowercase was what worked on my machine running Ubuntu 8.10.

Posted at at 11:21 AM on Thursday, November 13, 2008 by Posted by Vince | 0 comments   | Filed under: , , , , ,

Configuring Gnome Panel Applets to have Relative Positioning

Gnome applets are set up so that there are a few applets with absolute position on the left side of the panel and a few applets with relative position on the right side of the panel. It is set up this way so that when the panel resizes the right-side applets will move relative to the right edge. The problem arises when you try to move any of the right-side applets. Once you try to move an applet it assumes you want it to have absolute positioning.

Instead of moving it visually on the panel follow the following steps.

  1. In a shell run the command: gconf-editor
  2. In the dialog navigate to apps/panel/applets
  3. Going by the names you should be able to tell which applets are on the right side of the panel. For each one make sure that panel_right_stick is checked.
The position value is a 0-based index of the position from the right of the screen. So the right-most applet will have 0 position, second right-most will have 1 position, and so on.

Posted at at 8:58 AM on by Posted by Vince | 0 comments   | Filed under: , ,

JUnit and Maven

Occasionally I will have a problem with a JUnit test running in Eclipse but not in Maven. Any relatively large project will have hundreds of unit tests and simply doing 'mvn test' runs all of the unit tests in the project. When you want to run a single test use the "-Dtest" parameter:

mvn -Dtest=MyTest test
In the above command "MyTest" is the name of the test class you want to run.

Skipping your unit tests is generally a bad idea but sometimes necessary. If you are running a mvn target that internally calls the test target but you want to skip the tests you can add the "-Dmaven.test.skip" parameter to your command.
mvn -Dmaven.test.skip install
For more information about Maven go here

source: Maven FAQ



Posted at at 11:23 AM on Wednesday, September 24, 2008 by Posted by Vince | 0 comments   | Filed under: , , ,

Interactive jQuery Selector Tester

jQuery is a very powerful JavaScript library. In particular, the jQuery selector mechanism allows developers to select DOM objects by a variety of criteria. For more complex selector strings it is often useful to have a way to test what exactly the jQuery selector will return and if it matches what you expect.

Recently I found this great tool online that does exactly that.

Posted at at 3:09 PM on Monday, September 22, 2008 by Posted by Vince | 0 comments   | Filed under: , ,

Installing Third-party Libraries into Maven2 Repo

To install a third-party jar into your local Maven repository perform the following command:

mvn install:install-file \
-Dfile=[path_to_jar] \
-DgroupId=[group_id] \
-DartifactId=[artifact_id] \
-Dversion=[version_number] \
-Dpackaging=jar

More information about the maven install-file plugin can be found here.

Posted at at 2:30 PM on by Posted by Vince | 0 comments   | Filed under: , ,