Sigma.js Hello World

Sigma.js is a cool JavaScript library for visualising graphs. Unfortunately, the documentation doesn’t really give a complete example of the ubiquitous ‘Hello World’ so here’s one to get you started. The example is using jQuery, which isn’t strictly necessary but it provides some nice utility functions that you can take advantage of.

<!DOCTYPE html>
<html>
<head>
    <title>Sigma.js Hello World</title>

    <script src="http://code.jquery.com/jquery-2.0.2.min.js"></script>
    <script src="http://sigmajs.org/js/sigma.min.js"></script>
    <script type="text/javascript">

        // Use jquery to wait for DOM to be fully loaded
        $(document).ready(function () {

            // Use jquery to retrieve the div with id 'sig'
            var domElement = $('#sig')[0];

            // Let sigma.js populate the div
            var sigInst = sigma.init(domElement);

            // Use curved edges and make the nodes a bit bigger
            sigInst.drawingProperties({
                defaultEdgeType:'curve'
            }).graphProperties({
                        minNodeSize:1,
                        maxNodeSize:5
                    });

            // Add a simple graph
            // NOTE! addEdge needs to take three parameters,
            // the first one being the name of the edge itself
            sigInst.addNode('hello', {
                label:'Hello',
                x:Math.random(),
                y:Math.random()
            }).addNode('world', {
                        label:'World!',
                        x:Math.random(),
                        y:Math.random()
                    }).addEdge('helloworld', 'hello', 'world').draw();
        });

    </script>

    <style type="text/css">

        /* Set a height on the div or it will have zero height */
        .sigma {
            height: 200px;
        }

    </style>

</head>
<body>

<div class="sigma" id="sig"></div>

</body>
</html>

Spring, Jetty Maven plugin and java.lang.ClassNotFoundException

I was creating a web project using Spring 3.0.5, Maven2 and the Jetty Maven Plugin (jetty-maven-plugin 8.0.3). When running mvn jetty:run, I got this error:

[WARN] Could not instantiate listener org.springframework.web.context.ContextLoaderListener 
java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener

It turned out to the error was caused by the Jetty Maven plugin not working correctly with Maven2 (which I was using). The documentation states this explicitly: http://wiki.eclipse.org/Jetty/Feature/Jetty_Maven_Plugin. Changing to jetty-maven-plugin 7.3.0 solved the problem.

Thermalright Ultra 120 A and ASRock P67 Extreme4

I recently felt the need to upgrade to Intel’s Sandy Bridge architecture. Having happily been running a Core2 with 4 GB DDR2 Ram for a few years, when I started to run JBoss, Oracle XE, SQL Developer and Liferay all at once, there really wasn’t enough RAM to cope with everything. As soon as the OS starts paging large amounts of memory space from main storage everything grinds to a halt. So, upgrade RAM or buy new stuff? Well, buy new!

Now to cool that Core2, I used a Thermalright Ultra 120A. It’s a big, great cooler. However, it’s only intended to be used on platforms with Intel socket 775 (which my Core2 was using) or AMD AM2, not socket 1155 (Sandy bridge). However, in a review of the ASRock P67 Extreme4 on Anandtech it is mentioned that this Sandy Bridge motherboard supports older socket 775 coolers. Judging from the review, this is a pretty good motherboard too. Hooray! I’m going to use my Ultra 120 A with the ASRock motherboard.

Fitting the Thermalright Ultra 120 A on the ASRock P67 Extreme4

The Ultra 120 A comes with an X shaped backplate to support the weight of the cooler. Inspecting the back of the P67 Extreme4 reveals another backplate to support the 1155 socket. Hmm, a bit of a problem. One of the three screws holding the socket 1155 in place is interfering with the X shaped backplate. Fortunately, I own a drill press and by drilling a 4-5 mm hole through the X shaped backplate it will fit over the socket 1155 backplate. The X shaped backplate will be distanced a bit further from the motherboard PCB than usual, because it sits on top of the existing socket 1155 backplate, but it does work. See pictures below.