Simbiosis

Communiques from the wilderness

Replacement for document.all

document.all was replaced by document.getElementsByTagName(“*”) in the W3C spec.

July 23, 2007 Posted by Nigel | programming | | No Comments Yet

Maven-Ant hybrid

Some brief background. Ant is the stock standard Java build system, much as Make is for C/C++. Maven is a newer Java build system which tried to, amongst other things, solver the Jar dependency hell problem, as well as make a standard project directory layout.

From the Maven guide:

src/main/java Application/Library sources

Maven has a central repository for almost all the Jar’s in the world, almost (see here). And within the Maven build file you can specify which jars you would like. For examples, Log4J:

    <dependency>

      <groupId>log4j</groupId>

      <artifactId>log4j</artifactId>

      <version>1.2.9</version>

    </dependency>

Now when you go to compile with maven it goes and gets all the dependencies, puts them in your local repository (~/.m2/repository) and then into your project’s build class path. This is covered in more detail at the Maven website.

What I wanted to achieve was to have both Ant and Maven build systems coexist, so someone without Maven can still use the project as before. And I also wanted to provide the option to use Maven to get the dependencies and put them in the lib directory for Ant to use. Using some pointers I got from here, I produced this ant file, invoked with ant -f ant-deps.xml.This will use your pom.xml to do the dependencies.

The final step is to host your own repository for those 3rd party jars which aren’t hosted elsewhere. Using the doco here I imported all the Jargon jars I had lying around:

mvn install:install-file -Dfile=jargon_v1.4.19.jar -DgroupId=SDSC     -DartifactId=jargon -Dversion=1.4.19 -Dpackaging=jar

SDSC is the group, and probably should have been edu.sdsc or some such thing, but no matter. This command moves the file into your local repository. If you want other to access it, then copy it to a public webserver. In my case I just took the SDSC directory from within my ~/.m2/repositories directory, and hosted it here. Then within the pom.xml file you need to specify this new repository:

  <repositories>

  <repository>

    <id>archer_repo</id>

    <url>http://dev.archer.edu.au/maven</url>

  </repository>

  </repositories>

So what does this give you?

  1. A good, reliable dependency management system.
  2. A useful repository system for Jars
  3. A consistent build layout
  4. Easier testing (see #1)

July 20, 2007 Posted by Nigel | java, programming, technology | | No Comments Yet

Grouped Plone keywords

 The keywords system is plone is ok, but it’s not great. There is a few alternative such as Portal Taxonomy, and it is quite well discussed elsewhere. However, most systems I’ve seen replace the keywords system entirely, meaning that only modified/new products can use the improved system. All I wanted was something a little better than the list box, and a 2 level hierarchy would also be nice. Using the existing keyword infrastructure was pretty much a must, so it will tie in to any future core changes to Plone.

So, I devised a widget to replace the keywords widget, which provided a simple hierarchy, and check boxes to select the keywords. It is constructed off the keywords list, with a / used as the separator. ie Group1/KeyWord1. Sooner or later I’ll put it on Plone.org, but until then it is available from SVN at https://www.hpc.jcu.edu.au/projects/plone/svn/GroupedKeywords/trunk/

July 5, 2007 Posted by Nigel | plone | | 1 Comment

Multi-node PBS script for non-mpi jobs

A PBS script I wrote to allow me to spawn across multiple nodes, much like mpirun does, except without the MPI.

#!/bin/sh
#PBS -l nodes=3:ppn=1
NODES=`sort $PBS_NODEFILE`
echo $NODES

function spawn() {
  NODE=$1
  COUNT=$2
  echo Spawning $COUNT on $NODE
  rsh $NODE -n "~/mark.sh" &
  #rsh $NODE -n "cd $PWD ; ./run.sh --agent --threads $COUNT" &

}

LAST=
COUNT=0
for N in $NODES ; do
        if [ "$N" = "$LAST" ] ; then
                COUNT=$[COUNT+1]
        else
                if [ 0 -ne $COUNT ] ; then
                        spawn $LAST $COUNT
                fi
                COUNT=1
                LAST=$N
        fi
done

if [ 0 -ne $COUNT ] ; then
        spawn $LAST $COUNT
fi

# Wait for children to exit
wait

July 5, 2007 Posted by Nigel | programming | | No Comments Yet