Tuesday, 16 August 2011

Alfresco setup

Alfresco is AMAZING - it does not follow the Unix way, or even the Java way, but rather the bloatware way. This is a very bad smell (as is their constant pimping of the paid version).

Alfresco comes with ITS OWN COPY of Java, MySQL and Tomcat.
As I have copies of all these systems on my own box I have chosen to insulate my system and to play fair with Alfreco, and install on a fresh Ubuntu VirtualBox VM, with nothing other than OpenSSH installed.

VM Setup: I also enabled the VirtualBox Guest Additions, on my MacBookPro host, and found that the default bidirectional Copy/Paste functionality did not work.
Stop the VM and change Settings>>Advanced Shared Clipboards to Host To Guest

This vm (called alfresco) is on a virtual network, setup with help from Mr Sysadmin:

Add a Host only network in virtualbox >> preferences >> network

Add an adapter2 to vm >> settings >> network
attached to Host-only adapter

Add to /etc/hosts on host machine
192.168.56.10 alfresco

On vm add to /etc/network/interfaces
auto eth1
iface eth1 inet static
        address 192.168.56.10
        netmask 255.255.255.0
/etc/init.d/networking restart

Install alfresco (NOTE The x32 versions also works)
wget http://dl.alfresco.com/release/community/build-3370/alfresco-community-3.4.d-installer-linux-x64.bin
sudo su
chmod u+x alfresco-community-3.4.d-installer-linux-x64.bin
./alfresco-community-3.4.d-installer-linux-x64.bin 

Take defaults, specify a password for mysql root and Alfresco admin.
/etc/init.d/alfresco start


Now the url http://alfresco:8080/alfresco/ should work.

Monday, 15 August 2011

Dual repositories: Subversion and Git

Git and SVN

I have not got a completely pain free git/svn integration,
this seems to be because casutils started life as a git project.

Install git svn integration
sudo apt-get install git-core git-svn

I have two checkouts: local/casutils and workspace/casutils
workspace/casutils was created in the normal way with
git init casutils
local/casutils was created with
git svn clone https://tim.pizey@dsn-chassis.googlecode.com/svn/trunk/casutils
I work in workspace/casutils, when all is committed and pushed to master I switch to local/casutils
git pull -s recursive -Xtheirs ../../workspace/casutils
git svn dcommit

this pushes the changes, with their git commit messages, to svn.

Tuesday, 21 June 2011

Cretan Opinel

On our holiday to Paleochora, Crete we spent a day on the East Beach. The sun was pretty hot, so we spent a lot of time under a tamarisk tree. I built a little wall.
On the way back I found an Opinel knife
which has cleaned up quite well. Note the change in the branding: no France and the Main Coroné has moved. This would indicate that it is quite a few years old. (I could not discover when this change occurred).

[Thanks to Laurent in the comments: it was made between 1986 and 1990.]

A button from Tom's Farm

Really quite a long time ago, maybe sixteen years ago, I went to Tom's Farm, on Black Alder Road and walking up the Green Lane found this button. I rediscovered it recently and put it in some silvo, which seemed to show up a bit of silver, now black.
Will give it back to Tom, can't think why I ever took it away, except perhaps I was younger.

Thursday, 9 June 2011

My first functional java class

I have known about this particular hammer for ten years. It is a technique widely used in Melati, as William was mostly 'translating on the fly from OCAML' at the time, however I have never recognised a situation where it was the correct approach.

To a commercial programmer on the long journey from BASIC to lisp, via perl and java, even when you know of the functional hammer the world does not appear to have any functional nails in it.

Last night I did recognise such a situation. I wanted to reuse a bit of code:
if (lock()) {
  try {
    body();
  } catch (Exception e) {
    throw new RuntimeException(e); 
  } finally {
    unlock();
  }
} else {
  throw new RuntimeException("Lock file " + LOCK_FILE_NAME + " exists.");
}

The only way to reuse this, for a body2() function, would have been to cut'n'paste, which I will go to some lengths to avoid.

I extracted this to its own abstract class ExclusiveFunction
import java.io.File;
import java.io.IOException;

/**
 * @author timp
 * @since 2011/06/07 22:00:01
 *
 */
public abstract class ExclusiveFunction {
  final static String LOCK_FILE_NAME = "/tmp/EXCLUSIVE_LOCK";

  abstract void body() throws Exception;
  
  public void invoke() { 
    if (lock()) {
      try {
        body();
      } catch (Exception e) {
        throw new RuntimeException(e); 
      } finally {
        unlock();
      }
    } else {
      throw new RuntimeException("Lock file " + LOCK_FILE_NAME + " exists.");
    }
  }
  
  private boolean lock() {
    File lockFile = new File(LOCK_FILE_NAME);
    if (!lockFile.exists()) {
      try {
        lockFile.createNewFile();
      } catch (IOException e) {
        throw new RuntimeException(e);
      }
      return true;
    }
    return false;
  }

  private void unlock() {
    new File(LOCK_FILE_NAME).delete();
  }

}


which is then invoked with:

new ExclusiveFunction() {

      @Override
      void body() throws IOException {
        body2();
      }
    }.invoke();


I think the world is soon going to appear to have a lot more nails in it.

Thursday, 14 April 2011

Scala and Java

HelloWorldScala.scala
package net.pizey.scala.toy

class HelloWorldScala {
  def m(message: String) {
    println(message + " - from scala")
  }
}

object HellowWorld {
  def main(args: Array[String]) {
    val s = new HelloWorldScala()
    val j = new HelloWorldJava()
    s.m("Hello world")
    j.m("Hello world")
  }
}

HelloWorldJava.java
package net.pizey.scala.toy;

public class HelloWorldJava {

  public void m(String message) {
    System.out.println(message + " - from java");
  }

  public static void main(String[] args) {
    HelloWorldScala s = new HelloWorldScala();
    HelloWorldJava j = new HelloWorldJava();
    s.m("Hello world");
    j.m("Hello World");
  }
}

Both output
Hello world - from scala
Hello World - from java

Monday, 14 March 2011

Ubuntu setup


apt-get install emacs23-nox
apt-get install cvs
apt-get install git-base

#setup apt-get 

deb http://switch.dl.sourceforge.net/project/jedit /

apt-get install jedit


wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add -

emacs /etc/apt/sources.list

# Google software repository
deb http://dl.google.com/linux/deb/ stable non-free main

apt-get install google-chrome-unstable



cvs -d :ext:timp@paneris.net:/usr/cvsroot co timp
mv timp/.* .