jueves, 11 de febrero de 2010

Hallelujah

WARNING: Este post fue escrito el mismo dia de presentar, y lo he dejado talcual, aunque con perspectiva se ve cutre-friki-quieroYNoPuedo de cojones. Pero lo dejo talcual.

Todos como uno solo, alcemos la voz al cielo, porqué $DEITY (en caso de que hayas definido esa variable) nos escucha desde $DEITY->location. Gritad conmigo: Hallelujah! Hallelujah! Hallelujah! Hallelujah!

Porqué al final del camino, la luz brilla más que a la mitad de él. Gritemos Hallelujah!

Después de estar recibiendo enseñanzas durante 8 años (y pico) en el monte FIB, hacer un viaje para aprender de otros en La Laguna, de donde volví con el espíritu cargado de fuerzas gracias a profetas y discípulos, el viaje de aprendizaje formal terminó hace 2 semana, con un resultado francamente bueno.

Aquí os dejo, amigos míos, el resultado de mis 6 meses, entregados para vosotros. Mirad, y sonreír todos, que esto es lo mejor que se hacer, hablar de frikadas, y delante de gente. Y no me juzguéis si no queréis ser juzgados, que ahí me puntuaban, y no podía ser Rai 100%. Disfrutad de los primeros 10 minutos viéndome hablar a 2x en un baile 33% funky cold medina, 33% macarena y 33% saturday night (esta os la buscáis vosotros/as).

Quiero dar las gracias a mis padres, y también a todos los que no son mis padres. A todos los que me han dejado un sofá para pasar una noche (sóis más gente de la que os pensáis), quiénes me han iluminado y gentuza en general. Ya sabéis quien soys. Os quiero, gracias por este sueño, que os den por el culo, etc...

Venga, ahora unos links y los videos
El pe de efe: genetic algorithms memoria

Las transpas: genetic algorithms slides

Los códigos fuente de la memoria estan en mi github

La presentación.

Algoritmes genètics aplicats a ciències de la vida from Raimon Grau on Vimeo.


Las preguntas (y sus respuestas (y sus coñas marineras)).

Algoritmes genètics aplicats a ciències de la vida - preguntes from Raimon Grau on Vimeo.


Ahora por fin tengo tiempo de aprender.

miércoles, 10 de febrero de 2010

Are you attending more classes? No I'm just charging my batteries

I'm fucking amazed. I mean, I'm really FUCKIN amazed.

These Advanced OOP Design classes are more meta than I ever could have thought. Stéphane is that kind of guy that charges your batteries when listening him. A great and passionate speaker.

Today's class was more like a open-your-eyes session than a hardcore technical lecture. Maybe many people does not like these kind of things, but myself, I love them. It's when you feel you're not sure you're in the right path, or don't feel motivated enough to hack on things, the right person cracks in and explains his experiences, and gives you metarules to clear your ideas. Like giving you the toolkit and materials to build your toolchain to eval on yourself, and then, make or break.

Instead of doing the explanations on "why tiny methods matter", or discussing about aggregation vs composition (luckily I did my homework yesterday anyway), he pointed us some ideas of "how stuff should work" (Note to self: buy www.howstuffshouldwork.something), or better said, "where things are going". Also, explained his opinions about some dynamic languages. And explained the beauty of uniformity (object -> class -> metaclass-> metaclass class).

Some points I got (all bullets multiplied by my vision of things):
  • Gimme a man(1) with examples, or better still: gimme access to the code that uses XYZ function.
  • Simple and small m/(systems|rules)/ make $1 powerful and extensible. Don't break the simplicity as far as you can.
  • Systems should be small, but not smaller than useful (They're trying to do that in pharo)
  • Object -> Classes -> Metaclasses -> Metaclass class is so beautiful
  • Marketing is capable of amazing things.

On the meta side (all bullets multiplied by my vision of things):
  • Do stuff you like. Be a kid. play with stuff, break things, fix them, or throw them away, but don't be passive about the world.
  • Take the time to learn things. Invest in yourself. And now it's easier than ever getting info about anything you like. No more traveling 30 km to get a book that iif you're lucky, you can take home. "OH HAI INTERNETZ".
  • Value your time. Signal / noise is low nowadays. Evaluate what you spend time on.
  • Use internet wisely. After you downloaded all the crap you won't have time to watch/listen, take a look at http://arxiv.org/ ,http://portal.acm.org , or just take a project you like, and play. You can mail your 'idols' and probably they will answer you kindly.
  • You're not obliged to do anything of that, but keep in mind we're part of our community (the REAL world), and it depends on us building the future of the culture, community and so. Choice is yours.
I want to make clear that he didn't say anything of this textually, so most of the bullets are versions of high-level-ideas-he-said strongly modified by my highly biased way of thinking.

It's difficult to express how happy I am to attend these lectures. Thanks again to JD and SD. I think I'll subscribe to pharo mail list, and try to collaborate in anything I can do. Even if I only can do little support on IRC to smalltalk newbies.

lunes, 8 de febrero de 2010

Advanced OOP design with Smalltalk and Stéphane Ducasse

I've just been in the first lecture of Dr Ducasse's course on advanced OOP design here in Barcelona.

And I've to say it's been GREAT. A guru that talks with hackers in mind, being a great one himself. And with lots of good points in the prespective one should care about when entering a new world of hacking/amusement.

He started with an introduction to smalltalk while jumping back and forth to meta-level . We already saw the boolean implementation in the first 20 minutes, and jumped to ifTrue:ifFalse: implementation.

During the talk, he spoke about some real cases he encountered in his life, talking about india, china, project costs in "Old Europe" vs eastern, and the importance of having a delta that makes you different from your co-workers (oponents?). I've always thought like that too, so this guy seems really cool to me :).

On the technical side, He talked about the importance of taking advantage of the object system, and keep in mind that the dispatcher on message sends act as case statements, so we should use them as such. Minimizing logic in our code make it faster, more solid, and prettier.

We're following these slides mixed with these others.

While doing the lecture, he mentioned some cool books, some of them I already heard about (even read them), but others not, so I'm afraid my TOREAD list is about to grow a bit.

All in all, I had a really good time, and it's been only the first class!. It seems I'll be hacking some smalltalk in near future :)

Thanks to Jordi Delgado for making this possible, and to Stéphane for coming to Barcelona and sharing his knowledge.

--EDIT--
Btw, if you don't know what is smalltalk nor who Stéphane Ducasse is, you should check pharo and you'll get a fair idea of what's smalltalk about and you'll be watching what is Stef working on.

viernes, 5 de febrero de 2010

Mysql from Perl

There's a lot of texts written about perl+sql . In fact there's a whole O'Reilly book about this.

But in perl, often the TIMTOWTDI motto fuzzies me a bit. So here's what I've chosen to use for my simple Mysql accesses (For complex and scalable things, there's DBIx::Class).

For small updates, or writting tests, you could go with plain DBD::DBI, but DBIx::Simple seems to fit better in my brain rules. There are plenty of well thought examples here.
my $dbh = DBIx::Simple->new(
$dsn,
$user,
$pwd, {RaiseError => 1}
);
#my $sql = SQL::Abstract->new;
my @fields = qw(codi A Br P S SA ZN e d);
my $result = $dbh->select('vGRID', \@fields, { idExp => $idExp, error => 0 }) ;

It's pretty confortable being able to use select, update, etc. as methods, and not bundled into strings. SQL::Abstract does a good job here too, giving the option to build hashes dinamically and passing to the select method.

domingo, 31 de enero de 2010

Higher higher order functions in Perl

I've been toying with functional programming on and off for some time now, and there are already some apps at $work that use some FP approach.

One example of this is an app I had to do some time ago that filtered a file following user given constraints. To simplify the case, let's imagine we have a textfile with names of students followed by a qualification. We'd like to do some data managing on them. For example, get the average qualification of all students that passed.

In my case, I couldn't keep everything in memory, As I had to parse multiline objects in a 2Gb file, so I had to filter them "á lá" File::Find.

Here's the basic (simplifyed) code.



What if we wanted to change the condition based on a parameter? I thought of two different approaches, one being more clear on the code side, and the other being more robust.

One option would be getting the parameter before the closure. That way, the constraint function will be able to access the $par variable. This option works, and the code does not get much affected. On the other side, The code becomes flaky in the extensibility side. Changing the location of the closure makes the program fail. Using global variables this way isn't really nice either.



Last way I tried is making a higher order function that generates the constrain function. It ressembles some kind of currying. Well, here's the code.



The'@keep' juggling isn't needed on newer perl versions, but you'll need it in perl 5.8.8 .

Dear lazyweb, do you have any preference for one or other technique? Is there another trick to use in this case that could help me?

Here's a bit of help on 'variable X will not stay shared' warning.

Bye

sábado, 23 de enero de 2010

permutations with repetition in scheme

With my exams finished and my final project at uni also finished, I had some time to spend with my already-started-but-not-finished small coding challenges.

As you may know, some time ago I started not one but two implementations of mastermind.

One in Perl, and the other in Scheme.

I wanted to finish the scheme implementation, so I started to look at Donald Knuth's paper about Mastermind. It's not so complicated, but as I've been far from complex algorithms for some time, it scared me a bit.

First thing to do is having available all possible combinations (strictly speaking they are permutations as order matters) of colours (in our case numbers). Two nested maps, a recursive call, and you're done.

As I don't have time to comment all the code, I'll just post here the permutations part, and keep the complete code private for now. When I have the time, I'll post it all, with appropiate comments. It's a minimax algorithm, so not daunting at all, but....

Here it is:



Apart from this, I've hacked with a few things (as time permitted). If you're specially interested in something, ask.

  • net sniffing
  • Image analyzing and video tracking
  • html parsing and web scraping

lunes, 18 de enero de 2010

Variaciones de una misma historia

uno

Cuando aún el negro reinaba yo ya estaba levantado.

Mecagoen la puta, hoy tendría que dormir para estar bien concentrado para el examen, y no hay quién pegue ojo.

Me pasaba por la cabeza una mezcla de medidas de eficiencia de ethernet y gifs de 5 segundos recordando momentos mágicos de la uni. Algunos chulos, algunos embarazosos, que me hacían escabullirbe debajo del edredon, escondiéndome de la luz que entraba por la ventana.

Al final me levanto. Un día lluvioso. Un mal día para acabar este período de 9 años.

Voy a por el bus, aparco el coche en un descampado, pongo el pie en el suelo, y piso un charco. MIERDA.

El trayecto duró más de lo que esperaba. Y ya empezaban los nervios. A las 10 en la uni. 100% de desconocidos, menos los camareros del bar. "Ya te toca largarte de aquí", me digo por dentro.

Tras bastantes horas de medio estudio medio crisis nerviosa llega el examen. Tengo la sensación de irme vaciando. Llevo días vaciándome de tensión porqué he entendido que realmente no hay nada a esperar después del último examen.

El examen está en Chino. Mierda. Me he vuelto a equivocar de clase... ah pues no...se ve que es el examen de redes.
Mientras lo hago, intento escribir concienzudamente, como queriendo marcar que éstas son mis últimas palabras en esta universidad. Pero al salir, comparo soluciones y veo que no lo llevaba tan bien como creía. FAIL.

Mecagondiós! Un cuatri más. Ya me lo veo. El orgullo por los suelos. El año que viene, a ver a más desconocidos, y esos pocos perennes de la uni. Los que me interesan y los que no. La gente que esperabas perder de vista, porqué no te llevaban a ningun sitio. Pues tendras que verlos más.

Y ya son las 21:30, voy a cojer el bus y...lo pierdo. Venga, perfecto, voy a llegar a casa a las 23:30.
Y al llegar al coche otra vez, me vuelvo a encontrar con (léase pisar) el charco porque ha llovido todo el día. ¿Lo véis? un mal dia para acabar

------------------------------
dos

No he podido dormir de nervios. Acabo la carrera!

Desde las 6 que estoy en danza. Joder, esque no cada día acabas la carrera. Una mierda de carrera, sí, pero no me digas que no la has disfrutado. Aún en la cama, me acuerdo de los grandes, y las.

Venga, me levanto, a ver si avanzo un poco. Aunque no por mucho madrugar, amanezca blablabla, siempre puedes empezar a currar en la oscuridad.

Oh, mierda, llueve. Seguro que el tráfico esta fatal, ya verás.
Al entrar en el bus, me encuentro un euro en 1 asiento, y decido sentarme ahí. Quizás es mi "euro de la suerte".

Nah, me lo gasto en una cocacola nada más llegar a la uni.

En mi tercera cocacola de la mañana, veo a unos colegas. Y todos: "venga tío, dale fuerte y cómetelos con patatas!". Aunque no les escucho y sólo estoy mirando de reojo a la izquierda. Joder, que guapa está....

Consciencia: Tio, no te comas la olla, y a lo tuyo, que tienes que pirarte de aquí en 2 días.
Yo: yaya, pero...
Consciencia: Shhhhsthtt!!!

El examen, pues una mierda, como todos, pero con un poco de suerte apurebo sin rodilleras.

Salgo del examen y llamo a uno: "tío, creo que me pasa algo, creo que ya soy ingeniero". He apañao unas birras para mañana y otras para el jueves. :)

Cuando voy a por el bus, lo veo pasar por delante, pero ni me afecto. Tengo la preocupación en huelga. Voy a por el tren, lo pillo, me siento, respiro hondo 3 veces, pongo FatBoySlim y me digo: "tio, intenta escribir lo que te ha pasado hoy desde esos 2 prismas que te hablan todo el tiempo".

A todo esto, ¿Os acordáis que llovía?, pues ahora ya no.