Gr8Conf – Copenaghen

Gr8Conf is a conference headed in Copenaghen about gr8 technologies: groovy, grails, griffon, gradle and so on. The conference is organized by Javagruppen, the Danish Java User Group.

Nothing particular to say about the conference, everything was prepared very well and the overall quality was high. Behind the scene a lot of VIP and Stars in the Groovy panorama.

I was there because interested to this technologies but in particular because the Keynote presented a success story on Groovy and the enterprise, basically Philippe Delebarre and Raffaele Cigni gave a talk about wat was done at the European Patent Office.
Summarizing, after two failing tentatives: the first using an existing proprietary product and the second with opensource ESB, the project found in Groovy a very good candidate for the success; in addition, the keys were: strong separation between businnes and development, adopting of agile methodologies (SCRUM and XP), contributed for the success.

The conference at the end went very well, it was nice to meet a lot of people interested in this cool technologies and we had also the opportunity to have 4 hours of hacking in order to contribute to one of this projects.

At the end I went home with some new ideas and new starting point, where I can start working on :) see you next year

About these ads

Road to FOSDEM 2010

As most of you already know (if you don’t, never mind, I will forgive you :D), I’m going to give a lightning talk in the Free Java Dev room at FOSDEM about Groovy. The title will be “Groovy: the cool side of java” and basically it will be an hand-on speech. No slide, just code. I will start from a simple Java code and I will rewrite it in Groovy. During the demo/live I will give some basics explanation about how is groovy working and we will see the power and the value that Groovy add at the top of JVM compared with a static language like Java.

Here the code that I wrote:

import java.util.ArrayList;
import java.util.List;
import java.util.Collections;

class TestJava{
   public static void main(String[] args) {
      new DoStuffs().doIt();
   }
}

class DoStuffs{

   public void doIt(){

   List al = new ArrayList();

   System.out.println("* Initial size of"+al.getClass()+" :  " + al.size() + " with elements "+al);

   al.add("this");
   al.add("is");
   al.add("just");
   al.add("test");

   System.out.println("* Final size of"+al.getClass()+" :  " + al.size() + " with elements "+al);
   System.out.println("* Let's add some stuffs");

   al.add(2,"a");
   al.add(3,"cool");

   System.out.println("* Done "+al);
   System.out.println("");

   System.out.println("- Before ordering"+al);
   Collections.sort(al);
   System.out.println("- After ordering "+al);
   System.out.println("");

   List al2 = al.subList(2,4);

   System.out.println("- Sublisting "+al2);
   System.out.println("");

   if(al.size() > 0){
      for (int i=0; i< al.size(); i++) {
         al.set(i, al.get(i)+" \\o/ ");
      }

      System.out.println("Let's show the element in the reverse order: ");
      for (int i=al.size()-1; i>=0; i--){
         System.out.println("<"+i+"> "+al.get(i));
      }
   }

   if(al != null){
      List sub = new ArrayList();

      for (int i=0; i< al.size(); i++) {
         String el = (String) al.get(i);
         if(el.contains("t")) {
            sub.add(al.get(i));
         }
      }
      System.out.println("- After grep "+ sub);
    }
  }
}

copying, zipping selecting files with Groovy

Today I had to select some files from different directories copy in another. Despite it seemed a simple task, it wasn’t. The files were a lot, so I had to pack it.

Basically the structure of the directories was something like:


/A/US/file1
/A/
US/file2
/A/
US/file3
/A/UK/file1
/A/UK/file2
/A/UK/file3
...
/B/US/file1
/B/US/file2
/B/US/file3
/B/UK/file1
/B/UK/file2
/B/UK/file3

and I had to select the N% of the files from each of the second level directories (AA,AB, AC…and so on).

I wrote this short script that select only N% (parameter inside the script) of the files from the directory, pack it (without any structure information), and copy on the destination directory:

import java.util.zip.*

def createZip(destination, fileList) {
    try{
        byte[] buffer = new byte[1024];

        ZipOutputStream out = new ZipOutputStream(new
            FileOutputStream(destination));
        out.setLevel(Deflater.DEFAULT_COMPRESSION);
        fileList.each { selected -&gt;
            FileInputStream in_ = new FileInputStream(selected);
            //the new File(selected).getName() return just the name of the file,
            //in order to remove the directory structure inside.
            out.putNextEntry(new ZipEntry(new File(selected).getName()));

            int len;
            while ((len = in_.read(buffer)) &gt; 0) {
                out.write(buffer, 0, len);
            }
            out.closeEntry();
            in_.close();
        }
        out.close();
    }
    catch (IllegalArgumentException iae)
    {
        iae.printStackTrace();
    }
    catch (FileNotFoundException fnfe)
    {
        fnfe.printStackTrace();
    }
    catch (IOException ioe)
    {
        ioe.printStackTrace();
    }

    null
}

/**
  * Script
 **/
def rootDirectory = /C:\inputDirectory/
def outputDirectory = /C:\outputDirectory/

if ((!new File(rootDirectory).list()) || (! new File(outputDirectory).list())){
    println "Error. Input or Output directory are not valid."
    throw new RuntimeException() //TODO: understand how to exit without raising an exception
}

def directories = ['A', 'B', 'C', 'D']
def percentageRules = 5    //5 = 5% of the rules for each country

directories.each{ subDirectory -&gt;
    println "listing ${rootDirectory}\\${subDirectory}"
    def directoryList = new File("${rootDirectory}\\${subDirectory}").list()
    if( directoryList ){
        directoryList.each{ elem -&gt;
            def fileList = new File("${rootDirectory}\\${subDirectory}\\${elem}").list().grep{ !it.contains('out') }
            def numberFiles = (fileList.size() * 5 / 100) as Integer
            if ((numberFiles == 0) &amp;&amp; (fileList.size() &gt; 0)) {
                numberFiles = fileList.size()
            }
            println "Zipping ${numberFiles} (${percentageRules}%) of files from ${rootDirectory}\\${subDirectory}\\${elem} into ${outputDirectory}\\${subDirectory}-${elem}.zip"

            if(numberFiles){
                fileList = fileList.collect{ e -&gt;
                    "${rootDirectory}\\${subDirectory}\\${elem}\\${e}"
                }
                createZip("${outputDirectory}\\${subDirectory}-${elem}.zip", fileList[0..&lt;numberFiles])

                /* The old version copied the files instead of zipping it, using AntBuilder,
                   you can use it if you don't need to zip the files. */
                /*
                fileList[0..&lt;numberFiles].each{
                    ( new AntBuilder ( ) ).copy ( file : "${rootDirectory}\\${subDirectory}\\${elem}\\${inputF}" , tofile : "${outputDirectory}\\${inputF}" )
                }
                */
            }
        }
    }
}

I wrote it rushing, and I copied somewhere the first method (which was java), so might be errors or better ways. Anyway any suggestion are welcome.

Groovy & Grails eXchange 2009

The Groovy & Grails eXchange, organized by skillsmatter, was the first international conferences about software development I’ve attended in my career. Before I was more concentrated mostly on Linux and the Fedoraproject (FOSDEM, Linux TAG for instance).

The conference was headed in London from December 9th to 10th. The first day was focuses on Groovy and the second on Grails. I went there with Raffaele and Davide, friends and colleague of mine (we work together in Holland). As the conferences last Wednesday and Thursday, we decided to get Friday off and stay in London during the week end to visit the city (I already been there almost one year ago but London is always lovely).

At the conference there were about 150 people, mostly developers (heavy twitter users), in particular freelancers and really small companies from all over the world.

I really found all the speech really interesting. Guillaume Laforge spoke about the features of Groovy 1.7 and above (we even had a brief introduction about what are they considering to include in the 1.8 release) and Graeme Rocher introduced Grails 1.2.0 and the new plug-in development approach.

Based on my work in Holland, I really appreciated the ‘Groovy code kata’  talk from Dierk Koening and the DSL speech from Verkat Subramaniam. I had a really interesting chat with him about DSLs, in particular about what we should consider more important to balance the DSL we designed and are using in our project (I swear, I’ll post about it). I found Verkat really good to make examples in order to help you to understand better complexed concepts (DSL by examples might be a suggestion for next book ;-)).

You can find some photos about the conference itself here and here.

I’m really satisfied by this conference, I met a lot of people and exchange contact with them to keep in touch and, at the end I won Grails in Action book. :-) I also met also three guys from the NLGUG (Netherland Groovy User Group): Erik, Alex and Sebastien. They were really interested to my work with groovy and they invited me to give a speech, next year, to the Groovy User Group. I already accepted because it’s cool to meet new people on topics I like and I’ll get the opportunity to get more integrated into the local groups.

I met also Alberto Brandolini (ZioBrando for most of the people), who is a trainer for skillsmatter and a expert software architect in Italy. Before, he saw only a name and a photo but fortunately I had the opportunity to spoke with him to exchange some ideas and suggestion.

After the conferences we enjoy London for three days. I can say that I love London, and it’s strange because London is chaotic and I’m not use to it, but it has a fashion and a people integration level that is difficult(may be impossible) to find in any other cities (maybe in New York, but I’ve never been there, yet).

Maybe after my project in Holland will be finished, I’ll move there for a while, who knows. But we’ll see.

From London I can say that English people are really crazy, or they drink like sponges. I really would like to know how many drink they drink: I saw people with t-shirt in the middle of the night with around 0° or below, is it possible to survive? I would like to know how can they drink English beers: for me are too warm and they have a strange bitter after-taste.

Anyway London is fantastic and beautiful.  Period.

I took some photos, you can find here.