AnglarJS Split Pane directive

I have created a AngularJS Split Pane directive. It’s built on top of the popular jQuery Split Pane plugin.

Try resizing the browser and dragging the dividers.

It’s a bit simpler to set up than the jQuery plugin, so I hope you all enjoy it!

Simply install with bower:

bower install angular-split-pane

The easiest way to get started is to study the examples folder at github.

Here are some examples:

Here is a complete example:

<!DOCTYPE html>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title>Basic Example</title>
        <link rel="stylesheet" href="bower_components/split-pane/split-pane.css" />
        <script src="bower_components/jquery/dist/jquery.min.js"></script>
        <script src="bower_components/angular/angular.js"></script>
        <script src="bower_components/split-pane/split-pane.js"></script>
        <script src="bower_components/angular-split-pane/angular-split-pane.js"></script>
        <style type="text/css">
            html, body {
                /* The split-pane needs a container with width and height. */
                height: 100%;
                min-height: 100%;
                margin: 0;
                padding: 0;
            /* The styling below is very simple. You can style things your own way. */
            body {
                box-sizing: border-box;
                background: #aaa;
                padding: 5px;
            .split-pane-divider {
                background: #aaa;
            .split-pane-component {
                background: #fff;
    <body ng-app="example">
            <split-pane-component width="20em">
                This is the left component
            <split-pane-divider width="5px"></split-pane-divider>
                This is the right component
        angular.module('example', ['shagstrom.angular-split-pane']);

UTF-8, JSP and Spring MVC

If you are using UTF-8 with your Spring web app, then I would suggest using the following configurations.

In web.xml add:


(so that you don’t have to add <%@ page pageEncoding="utf-8" %> to every jsp file) and

    <!-- This filter has to come before other filters. -->


And if you are using ResourceBundleMessageSource you need to set defaultEncoding in you Spring Servlet config:

<bean id="messageSource" class="">
    <property name="basename" value="messages" />
    <property name="defaultEncoding" value="UTF-8" />

Note that if you are not using JDK 1.6 or above you have to use ReloadableResourceBundleMessageSource instead of ResourceBundleMessageSource to be able to set defaultEncoding.

Now, if you remember to save all files using UTF-8, you should be fine.

box-sizing: border-box and IE7

Internet Explorer 7 doesn’t support box-sizing: border-box. You can, however, achieve the same thing with nested divs.


<div class="border-box">

    ... content ...

.border-box {
    box-sizing: border-box;
    width: 50%;
    font-size: 50%;
    margin-bottom: 0.5em;
    background: green;
    padding: 5em;
    border: 5px solid red;
    overflow: hidden;


<div class="border-boxish">
    <div class="border-boxish-inner">

        ... content ...

.border-boxish {
    width: 50%;
    font-size: 50%;
    margin-bottom: 0.5em;
    background: green;

.border-boxish-inner {
    padding: 5em;
    border: 5px solid red;
    overflow: hidden;

You don’t need to use all css-rules from the example. I just included them to show what goes where.

Gradle Selenium (WebDriver) task

If you want to run your Selenium (WebDriver) tests from Gradle you can do it like this:

1. Add Jetty plugin to build.gradle:

apply plugin: 'jetty'

2. Create a src/selenium/java folder in you project root.

3. Add a SourceSet to build.gradle:

sourceSets {

4. Add Selenium dependencies to build.gradle:

seleniumCompile 'junit:junit:4.11'
seleniumCompile 'org.seleniumhq.selenium:selenium-java:2.30.0'

Add jettyDaemon and selenium tasks to build.gradle:

task jettyDaemon(type: org.gradle.api.plugins.jetty.JettyRun) {
    daemon = true

task selenium(type: Test, dependsOn: jettyDaemon) {
    testClassesDir = sourceSets.selenium.output.classesDir
    classpath = sourceSets.selenium.runtimeClasspath

5. If you are using Eclipse, add Selenium dependencies to the Eclipse classpath in build.gradle:

eclipse {
    classpath {
        plusConfigurations += configurations.seleniumCompile

You can now place you Selenium tests in src/selenium/java and run:

gradle clean selenium

JavaFX and Groovy Exception

You might have tried out the JavaFX Hello World example, from Oracle’s Getting Started with JavaFX guide, using Groovy.

You will then get the following exception:

Exception in thread "main" java.lang.RuntimeException: Error: class sun.reflect.NativeMethodAccessorImpl is not a subclass of javafx.application.Application

In order to fix this, change



launch(HelloWorld.class, args);

The example now runs fine with Groovy.

SQL and alpha-numeric sort order

Say you have this data set:


If you now do:

SELECT * FROM my_table ORDER BY some_column

you will get the following result:


which might not be what you want.

Now, if you create the following funtion:

CREATE FUNCTION pad_numbers(text) RETURNS text AS $$
  SELECT regexp_replace(regexp_replace(regexp_replace(regexp_replace($1,
    E'(^|\\D)(\\d{1,3}($|\\D))', E'\\1000\\2', 'g'),
      E'(^|\\D)(\\d{4,6}($|\\D))', E'\\1000\\2', 'g'),
        E'(^|\\D)(\\d{7}($|\\D))', E'\\100\\2', 'g'),
          E'(^|\\D)(\\d{8}($|\\D))', E'\\10\\2', 'g');

you can use this query:

SELECT * FROM my_table ORDER BY pad_numbers(some_column)

with this result:


Now you got your data sorted alpha-numerically.

Note: I have used PostgreSQL 9.0.

Split Pane jQuery plugin

I have created a jQuery plugin for adding split panes to you web site or web application.

Split panes can be nested. Component min-widths and min-heights are supported. I have not implemented support for max-width and max-height, yet.

I’ve tested the code in the latest versions of Chrome, Firefox and Safari on OS X, and in IE8 on XP.

The source code can be found at github.

It’s only version 0.3, so there will probably be some changes in the near future. Please give me you feed back!

Check out the following pages for examples on how to use it:

N.B., not all markup in the examples are needed for setting up the split panes. <div class="split-pane-frame"> and <div class="decoration"> are used for styling purposes only. Feel free to use them, but you might want to style things your own way.

JMenuBar not working for JApplet in Firefox on Mac

I’m having this issue with Firefox 12.0 on Mac OS X 10.7.4 using the following code:

import javax.swing.*;

public class AppletWithMenuBar extends JApplet {
	public void init() {
		JMenuBar menuBar = new JMenuBar();

		JMenu fileMenu = menuBar.add(new JMenu("File"));
		fileMenu.add(new JMenuItem("New"));
		fileMenu.add(new JMenuItem("Open"));
		fileMenu.add(new JMenuItem("Save"));

		JMenu editMenu = menuBar.add(new JMenu("Edit"));
		editMenu.add(new JMenuItem("Cut"));
		editMenu.add(new JMenuItem("Copy"));
		editMenu.add(new JMenuItem("Paste"));



<applet code="AppletWithMenuBar.class" width="400" height="100"></applet>

Whenever I select an item from the “Edit” menu the “File” menu gets highlighted.

Check it out for yourself here or have a look at the videos below.

This issue is also discussed here.

rApache on Debian 6.0 squeeze or Ubuntu 10.04 Lucid Lynx

This is how I installed and configured rApache on Debian 6.0 (squeeze). It should work on Ubuntu 10.04 Lucid Lynx also.

Install R and Apache MPM prefork (I assume that Apache 2 is installed already):

> sudo aptitude install r-base r-base-dev apache2-mpm-prefork apache2-prefork-dev

Download and build rApache from source:

> cd /usr/local/src
> sudo wget
> sudo tar xzf rapache-1.1.17.tar.gz
> cd rapache-1.1.17
> sudo ./configure
> sudo make
> sudo make install

Create file /etc/apache2/mods-available/R.load with content:

LoadModule R_module /usr/lib/apache2/modules/

Enable mod_R:

> sudo a2enmod R

Create folder /var/www/r-scripts .

Add the following to /etc/apache2/sites-available/default inside <VirtualHost *:80>:

<VirtualHost *:80>
	<Directory /var/www/r-scripts/>
		SetHandler r-script
		RHandler sys.source

Created file /var/www/r-scripts/hello.R with the following content:


Restart Apache:

> sudo /etc/init.d/apache2 restart

Verify that it works:

> curl -s http://localhost/r-scripts/hello.R



Apache Server, Tomcat and mod_jk on Debian 6.0 squeeze

This is how I integrated Tomcat 6 with Apache 2 on Debian 6.0 (squeeze) using mod_jk. It should also work on Ubuntu 10.04 Lucid Lynx.

Install Apache Web Server:

> aptitude install apache2

Verify that the server is running:

> curl -s http://localhost | grep "It works"
<html><body><h1>It works!</h1>

Install Tomcat (you don’t need to install tomcat6-examples, I did it only for the purpose of this How To):

> aptitude install tomcat6 tomcat6-examples

Verify that Tomcat server is running:

> curl -s http://localhost:8080 | grep "It works"
<h1>It works !</h1>

Install mod_jk:

> aptitude install libapache2-mod-jk

Create file /etc/apache2/ with the following content:


Create file /etc/apache2/mods-available/jk.conf with the following content:

JkWorkersFile	/etc/apache2/
JkShmFile	/var/log/apache2/mod_jk.shm
JkLogFile	/var/log/apache2/mod_jk.log
JkLogLevel	info

Enable jk conf:

> a2enmod jk

Add mount point to /etc/apache2/sites-available/default:

<VirtualHost *:80>
	JkMount		/examples/* worker1

Uncomment the following line in /etc/tomcat6/server.xml:

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

Restart Tomcat:

> /etc/init.d/tomcat6 restart

Restart Apache web server:

> /etc/init.d/apache2 restart

Now verify that everything works:

> curl -s http://localhost/examples/ | grep "Tomcat Examples"
<H3>Apache Tomcat Examples</H3>