Monday, 7 November 2011

Specify InnoDb as default table type in JDBC

One of the recurrent gotchas with MySQL is that the default table type is MyISAM, whereas you almost definitely need InnoDB, if you want transactions, indexing or anything else that would make MySQL a useful database.

Set default table type for all databases

In /etc/mysql/my.cnf add: [mysqld]
default-storage-engine=InnoDB
But this requires that you have root access to the server and that you want all tables to use InnoDB.

Specify default on JDBC url

database.url=jdbc\:mysql\://localhost\:3306/chassis_studies?autoReconnect=true&sessionVariables=storage_engine=InnoDB You could of course use a real database!

Friday, 14 October 2011

cvs to github

Following How to export revision history from mercurial or git to cvs?

On hanuman

I created an id file git_authors mapping cvs ids to github name, email format for all contributors:
timp=Tim Pizey<timp@paneris.org>
then create a repository on github (melati in this example, I already have uploaded my ssh public key for this machine)
git cvsimport -d /usr/cvsroot -C melati -r cvs -k -A ../../git_authors melati
cd melati
echo A jdbc to java object relational mapping system. 1999-2011 > README.txt
git add README.txt
git commit -m "Initial" README.txt
git remote add origin git@github.com:timp21337/melati.git
git push -u origin master
See https://github.com/timp21337/melati.

Sunday, 9 October 2011

Installing lhs2TeX on Ubuntu

lhs2TeX is a processor for literate Haskell code whose output is laTeX. The following worked for me on Unbuntu 11.04, though this was not the path I travelled, that is I discovered that, for example, libghc6-zlib-dev was a prerequisite the hard way.
sudo apt-get install ghc
sudo apt-get install libghc6-zlib-dev
sudo apt-get install cabal-install
cabal update
cabal install cabal-install
sudo apt-get install texlive
cabal install lhs2tex
logout  or 
export PATH=$PATH:~/.cabal/bin
lhs2TeX -o t.tex t.lhs 
pdflatex t.tex

Wednesday, 5 October 2011

Haskell - parse error in pattern: n + 1

Should you get the following error from Haskell
Parse error in pattern: n + 1
this maybe because you are using the n+1 pattern, which is no longer included by default eg
> power :: Double -> Int -> Double
> power x 0         = 1
> power x (n + 1)   = x * power x n
the fix is to include
> {-# LANGUAGE NPlusKPatterns #-}
Hope this helps.

Wednesday, 17 August 2011

Proxying from apache2 to application server (eg tomcat, jetty)

It is often convenient to proxy an application server, such as Jetty or Tomcat, as these tend to be mounted on ports other than port 80. The following steps worked in an Ubuntu setup.

Enable mod_proxy
a2enmod proxy
a2enmod proxy_http

Edit sites-enabled/default to add your proxying rule, eg:
ProxyPass /alfresco http://localhost:8080/alfresco
ProxyPassReverse /alfresco http://localhost:8080/alfresco
<Proxy http://localhost:8080/alfresco*>
Order deny,allow
Allow from all
</Proxy>

/etc/init.d/apache2 restart

You should now see your application server content on your default url ie http://localhost/alfresco will contain the same content as
http://localhost:8080/alfresco.

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.