fucking the white bunny rabbit

this blog is a feature

Archive for the ‘Uncategorized’ Category

copying, zipping selecting files with Groovy

without comments

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 ->
            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)) > 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 ->
    println "listing ${rootDirectory}\\${subDirectory}"
    def directoryList = new File("${rootDirectory}\\${subDirectory}").list()
    if( directoryList ){
        directoryList.each{ elem ->
            def fileList = new File("${rootDirectory}\\${subDirectory}\\${elem}").list().grep{ !it.contains('out') }
            def numberFiles = (fileList.size() * 5 / 100) as Integer
            if ((numberFiles == 0) && (fileList.size() > 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 ->
                    "${rootDirectory}\\${subDirectory}\\${elem}\\${e}"
                }
                createZip("${outputDirectory}\\${subDirectory}-${elem}.zip", fileList[0..<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..<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.

Written by whitenoise

December 21, 2009 at 11:41 am

Posted in groovy, know-how, programming

Tagged with , , , , , ,

Moving Fedora-it on rails

without comments

I’m 2 month late to write this post, but on the other hand, I adjusted my thought with last three months experience and give you a better perspective.

When I think about Fedora-IT community origin, I start smiling. I remember clearly when on #fedora-it IRC channel were only two (me and Matteo), and two Fedora Ambassador (Francesco & Francesco). Today we are officially a community. We are about 10/15 people on IRC and 5/7 active Fedora Ambassadors. This is nothing respect to French and German communities but for now is enough.

Since 2009 I have been decided to enhance the community by add short regular activities:

  • We have to do at least one meeting for month (no matter who is the owner or who ask for it, it’s important to keep in touch regularly, have brainstorming, discussions and involving all interested people.
  • We have few localized pages on fedora wiki to keep and track internal informations:
    1. Event page with a list of Italian events where we my participate (for example LinuxDay, Document Freedom Day, Software Freedom Day ,etc). This page has multiple goals: track every event may be interesting for us, give to Ambassador people the possibility to choose which event they want to attend,  Today this page is incomplete but next year we will have a really valuable event list.
    2. Inventory page collects gadget location and owner, this page exist because gadget are distributed all around Italy. This list give you the possibility to know what is available and who ask to.
    3. Meeting page with transcript and summary meeting.

I think we are on the right way.Stay tuned!

Written by whitenoise

March 15, 2009 at 8:14 am

It’s really a mess

with one comment

Disclaimer: this is a rant.
Disclaimer²: Although I included fedora mailing list guidelines, this message is not only for fedora people (most of them should read).

Premise: Bad quoting is one of the reason I skip messages.

I’m paladin of “good quoting” (and, if I’m bothering you I don’t care :) ), and I’m getting sick reading long threaded discussion where email is continuously raped by “I need to reply fast” or “this si more simple” stupid philosophy.

Please…..Please read and apply these few rules. I assure the world will be better, the entropy will increase less. But please, read it.

The most important rule you must apply is this:

Make sure we can tell what you are replying to. Place each part of your reply after the text it addresses (i.e., NO Top-Posting, please see “Wikipedia – Top Posting” and links therein for more on this). Most mail readers automatically put a ‘>’ character in front of each replied-to line. It gives a conversational flow to the text, and people know what you’re replying to. Trim irrelevant material. It makes it easier to read your reply and helps the reader to stay on subject.

You may change the world…remember ;-)

Written by whitenoise

March 1, 2009 at 10:19 am

Posted in fedora, software

Tagged with , , ,

IT’s an hard world….

without comments

I was looking for new information about Evolution planning and I found a IRC chat meeting of evolution team here.

The good news is that we will be a 2.24.5 release on February 25th, the bad (or sad, as you prefer) news is that Novell team will be reduced (about an half).

This is not encouraging me to continue to use it because the quality may be reduced without so many full-time developers. I’ll stay tuned and you too. ;-)

Written by whitenoise

February 21, 2009 at 1:51 pm

what?

with 4 comments

I’m trying to figure out what can I do with my life, what goals, what scope…

…I don’t know yet…

I want to run away.

Written by whitenoise

February 2, 2009 at 12:45 pm

Posted in Uncategorized

Tagged with , , ,

Linux Tag {4/4}

with 2 comments

My last day, my plane hour was scheduled to 12:15am, I leave the fedora ambassadors group around 8:00am and I take two hours to have a short trip in the city.

I went with underground to Postdamme Platz, then I went by walking in the city towards Alexander Platz.

I saw the Brandenburg door, the parliament and some other nice and famous buildings.

When I reached Alexander platx, I caught train to go to airport :)

Written by whitenoise

June 8, 2008 at 4:12 pm

Linux Tag {3/4}

with 2 comments

FUDCon, FUDCon, FUDCon…yep, Fedora Users and Developers Conference ;-) For us was the most important day within Linux Tag.

Max Spevak opened the FUDCon with a short introduction, after Tribalth North spoke about Fedora Electronic Lab project which aim to packages and provide some electronic application into fedora distribution. This project is interesting especially for schools and universities.

After him, the speech about FreeIPA was unfortunately suspended, so, to cover the hole in the FUDCon program Yakoov Nemroy did a short talk about Smolt.

You can read to the background of this phtos…what Smolt is ;-)


Smolt is a software which permit to users to send to central server configuration details about your computer, this software allow to understand and simplify information about linux compatiliblity.

Max Spevak spoke about fedora community and some interesting point of view about this project.
This is the best photo i never take in Linux Tag, is focused, impressive and expressive :)

Afternoon started at 15:00 with Paul Frields about “Fedora state of union”, continued with Francesco Crippa speech about Func, cobbler and puppet as huge network management solutions and ended with Jeroen van Meeuwen with a talk about revisor, a fedora tool used to make spins and custom fedora distributions.

In the evening we went to an Argentinian restaurant near hotel; we had three new people with us: Dag Wieers and Tim Verhoeven from CentOS, Lennart Poettering and another guy (my memory is a “groviera”, I don’t remember his name) from RH.

After dinner, we went to drink and had a lot of fun.

Paul tried Berlininen Waiss in both available colors: red and green (the red is the empty glass ;-) ).

Paul Frields

Me with Dag and Tim

and in the end of the night we make somestrange pictures :)

I don’t know what we are doing :P

Written by whitenoise

June 8, 2008 at 4:00 pm

fedora 9 upgrade

with 4 comments

Yesterday I tried to upgrade from fedora 8 to fedora 9 using anaconda and DVD…As usually something went wrong: anaconda crashed during installation..fortunatly during post-install process…

Right now I have a mixed system:

[root@sboing ~]# yum list installed | grep fc8 | wc -l
254
[root@sboing ~]#

…and I try to use a bash powered script to clean and fix it:

[root@sboing ~]# for x in `yum list installed | grep fc8 | awk '{print $1}' `; do yum remove "${x%.*}*fc8" ; echo "yum remove " ${x%.*}*fc8; done

and after :)


[root@sboing ~]# yum list installed | grep fc8 | wc -l
26
[root@sboing ~]#

Now all seems working, except for the Nvidia video card :-/ I’m waiting next nvidia closed drivers….
Update 29/05/2008@13:26 Today official NVidia driver are on livna fedora repository… \o/

Written by whitenoise

May 23, 2008 at 12:50 pm

PyCon 2 Live #2

without comments

Oggi la qualità dei talk è aumentata di molto. Devo ammettere che Google ha dimostrato un’ottima qualità e cura nella gestione dei talks: Brian Fitzpatrick ha tenuto un talk su come l’utente spesso non viene considerato durante lo sviluppo software, Alex Matelli ha parlato di Google Apps Engine. A differenza di Skype, che ha effettuato un investimento puramente monetario (senza curare molto la qualità dei talk), devo ammettere che da Google c’è veramente da imparare.

Il mio talk è filato via liscio, peccato che fosse in un orario un po’ sfigato (domenica pomeriggio dopo il coffee break) che ha contribuito in negativo ad una bassa affluenza. Per inciso, ho parlato di Func – Fedora Unified Network Controller (sul quale pubblicherò a breve un articolo), che è un sistema di API python, che permette il controllo agile di host su reti di larga scala.

Written by whitenoise

May 12, 2008 at 9:54 am

liberaMENTE: two days after

with 2 comments

Circa un mesetto fa, quando iniziammo ad organizzare quest’evento, ricordo di aver avuto molte perplessità, non tanto per l’evento in se, quanto per l’assenza sistematica di buona parte delle persone del LOLUG.

Ad essere sincero mi sono ricreduto.

LiberaMENTE è stata una ottima iniziativa, complessa e di notevole importante. Oggi come oggi se ripenso a quella giornata, caratterizzata da un mix esplosivo di esperienze (partecipazione del LOLUG, Evento Fedora, Meeting dei Fedora Ambassadors), sono felice di aver partecipato, di aver organizzato e di aver impiegato energie e tempo affinchè il LOLUG partecipasse.

La mia esperienza è stata caratterizzata (positivamente) dal contatto diretto con diverse persone, che finora avevo conosciuto solo per via telematica: liberaMENTE è stata anche luogo della prima riunione italiana di Ambassador fedora con la partecipazione di ben cinque elementi: Francesco Ugolini, Francesco Crippa, Andrea Modesto Rossi, Gianluca Varisco e Me.

Per quanto riguarda l’evento fedora, abbiamo allestito la prima stazione che permettesse la creazione completamente automatica di chiavette USB bootabili con Fedora 8: data una chiavetta da almeno un 1Gb ed inserita nell’apposita porta fino allo squillo di trombe. Il software è stato scritto da Matteo.

Tornando alla manifestazione, l’unica nota dolente è stato il poco afflusso di persone, ma se vogliamo esser positivi, ha permesso di confrontarsi maggiormente con gli altri espositori/partecipanti alla manifestazione.

Ah dimenticavo, al banchetto erano anche presente l’eeePC di Asus e l’OLPC. :)

Written by whitenoise

April 22, 2008 at 10:09 pm