Wednesday, November 30, 2011

scala and instanceOf -

I'm for some reason a fan of instanceOf in java and just love to be able to check at runtime of what kind a class is and do some action depending on this outcome.

But sometimes it's a bit tedios. For example

Object a = new String("tada");
Object result = null;

if(a instanceOf Number){
result = "its a number";
else if(a instanceOf String){
result = "its a string";


ok it's a silly example, now the pretty scala approach using match

var a:Any = "tada..."

val result = a match {
case n:Number => "it's a number"
case s:String => "it's a string"

oh so pretty and easy to read.

Monday, November 28, 2011

casting and scala

since a couple of month's I work more and more with scala and really start to like this language. But some of the concepts are really confusing and make me wounder if this really is necceasary.

A prime example would be the whole casting of variables.

In java you simple do:

String value = (String)object;

now in scala

val value:String = object.asInstanceOf[String]

now I admit it looks very clean, but sure took a while to find this one little details.

Otherwise it's always better to use matchers.

Friday, November 4, 2011

rocks linux - virtual hosts with apache

currently I have a cluster setup in the office with about 5 nodes and a bit over 50 cpus, so this morning I decided to rebuild some of the nodes, since I needed to make some changes to the cluster.

20 minutes into this procedure, I keep getting odd error messages, like file 'update.img' not found and so.

So while backtracking the latest changes I did to the server. I realized that I setup 20 virtual hosts in the apache configuration, which ended up screwing with the kickstart configuration. It turns out that the order of the virtual host seems to quite important and that the kickstart configuration always needs to be first, and than you have to define the other virtual hosts.

Example of a virtual host configuration, which allows the kickstart configuration to work,

vim /etc/httpd/conf.d/rocks.conf

actual file:

<IfModule mod_mime.c>
AddHandler cgi-script .cgi

UseCanonicalName Off

DirectoryIndex index.cgi

<Directory "/var/www/html">
Options FollowSymLinks Indexes ExecCGI
AllowOverride None
Order allow,deny
Allow from all

<Directory "/var/www/html/proc">
Options FollowSymLinks Indexes ExecCGI
AllowOverride None
Order deny,allow
Allow from
Allow from
Deny from all

<Directory "/var/www/html/pxelinux">
Options FollowSymLinks Indexes ExecCGI
AllowOverride None
Order deny,allow
Allow from
Allow from
Deny from all

<VirtualHost *:80>
DocumentRoot "/var/www/html"

<VirtualHost *:80>
DocumentRoot "/var/www/cts/html"

Wednesday, November 2, 2011

grails quartz plugin - don't repeat jobs

well it might be obvious, but sometimes you just want to execute a simple job once during the startup and than let them be.

For an example I needed this to synchronize a database and run statistics over it. So the simples trigger I could come up with, was

static triggers = {
simple name: 'synchronize', startDelay: 60000, repeatCount: 0

An alternative way could had been todo schedule the job during the startup phase

SynchronizeExperimentJob.triggerNow([experimentId: id, database: database])

this line should be put into your bootstrapping file.

Personally I feel the trigger is more elegant.

Tuesday, November 1, 2011

kinesis avantage pro - day one

so the keyboard got finally delivered and now Im in the progress of learning typing again and to say i'm inefficient is quite and understatement. I mean the layout is so weird and my hands feel way to big for this keyboard and i'm constantly hunting for the letters.

most frustrating things so far:

- only one space button instead of two
- i'm using muscles in my hand I never used before, I'm actually getting sore from typing after just a minute or two
- the enter button is in the most awkward spot ever, why cant the keyboard be a bit wider, so that there can be a dedicated enter button to be hit with my right pinky and a dedicated backspace button for the left pinky
- the right side of the keyboard if way more confusing than the left side
- the buttons are just a touch to large
- no dedicated number block, only a funky food pedal to switch some buttons around