lunes, 23 de febrero de 2009

Vectorlinux 6.0 is out!

After much efford, vl 6.0 is now a reality. Here is the release announcement. Usual Vl goodies: java,flash,mp3. everything out of the box. It's great to install and go hacking away instantly.

We've put perl 5.10 with some common modules preinstaled.

Give it a try and see how fast is your hardware :D .

martes, 10 de febrero de 2009

Better dumps with Data::Dumper::Perltidy

I recently discovered a new module that subclasses Data::Dumper . It outputs the same as D::D but more compressed to fit more data in a screen, and followng perltidy recommendations.

great for my huge debug dumps of arrays of hashes of arrays...
Here's a sample of what it outputs with a not-so-trivial structure.

$VAR1 = [
[ '183', '8', [ '0', '0', '0', '0', '0', '0', '0', '0', '0', '0' ] ],
[ '184', '7', [ '0', '1', '0', '0', '0', '0', '0', '0', '0', '0' ] ],
[ '185', '7', [ '0', '0', '0', '1', '0', '0', '0', '0', '0', '0' ] ]
];
Here's the cpan page

It's usage is as simple as including it and use Dumper as if you were using Data::Dumper, but instead it will use Data::Dumper::Perltidy.

Byez!

viernes, 6 de febrero de 2009

php, el lenguaje freelance?

Rebuscando en la web ofertas de trabajos puntuales, para llenar mis fines de semana, y tardes-noches, y ganarme cuatro perras extras, encuentro que sólo se piden freelances de php.

¿Por qué será? Php es el lenguaje de todos, el que es fácil de manejar, y el que muchas veces lo aprenden no-profesionales , para compaginarlo con su trabajo oficial. Por qué razón no se encuentran trabajos de c++, perl, smalltalk (vale, vale, se me ha ido un poco ahí) no lo sé, pero estoy seguro que hay un mercado para ello.

Proyectos relativamente pequeños, que pueda empezar y acabar una sola persona, los que en java no los puede abarcar una sola persona pero en perl sí. En españa vamos retrasados? Seguramente, pero tampoco no encuentro la forma de entrar en el trapo, haciendo lo que me gusta (que no es php).

Programadoraratos .com sería una buena iniciativa? no lo sé. pero más informaticos de los que os creéis trabajarían más barato y más eficientemente en casa (siempre en caso de no estar en un equipo interdisciplinario, donde la sinergia es importante).

Lo dicho, alguien necesita un programador_a_ratos? aquí estoy.

lunes, 2 de febrero de 2009

configurations hosted @ github

After some years carrying my configs everywhere, or sending them to myself on the email, I decided to put all them in a git repo at my github.

I'll place there last versions of my usual configurations (vim, emacs, zsh, xpdf, urxvt,vimperator...)

Little background on git on http://es.youtube.com/watch?v=8dhZ9BXQgc4 explained by the perl & smallalk guru Randal L. Schwartz.

Have fun!

miércoles, 28 de enero de 2009

Net simulator toy problem in Io

Another little test in Io language.

Packets are generated in a node with a content and a destination. Nodes are linked in a ring and passOn packages unless the package is for themselves.

Next versions to come, with subclassed nodes and more tests.

Syntax highlighted version in http://pastie.org/373095

Packet := Object clone do(
content := nil
destinatary := nil
)

Node := Object clone do (
id ::= nil
next ::= nil
generate := method(content, dest,
a := Packet clone
a content = content
a destinatary = dest
#a destinatary println
passOn(a)
)

receive := method(packet,
("I'm ".. self id .. ". The packet goes to".. packet destinatary .. "") println
if(packet destinatary == self id,
("I've received a package with the message:".. packet content .. "") println ,
#if (packet content asString containsSeq("sleep") and self id == 4, wait(2)) #nonblocking? anyone?
passOn(packet)))

passOn := method(packet,
#self id asString println
if(self next != nil, r:= self next receive(packet), "WTF?! I've no next node!" println))
)

lista := List clone
lista append (Node clone do (setId(0)))

for(i,100,1,-1,
lista append(Node clone do(setId(i) setNext(lista at(lista size -1)))))

lista at(0) next = lista at(lista size-1)
l1 := lista at(0) generate("matat1",45)
#l2 := lista at(0) generate("matatsleep",65)
#l3 := lista at(0) generate("matat3",20)
Future Work is Handling packages in a thread (and learning how to use futures), to be able to block some packages in certain nodes but be able to continue passing nodes along while processing (blocking) a given package.

That would allow having many packages navigating the 'net'.

miércoles, 21 de enero de 2009

a couple of perl gotchas

Yesterday I spent long time trying to catch 2 bugs in my code. It's not that perl is bad documented but me keeping forgetting things, so I'll put how did I solve them.

First one: perlvar are GLOBAL

Being used to use $_, you always find it has the correct value, so rarely localize it (only in nested loops for me). But I was setting $/ line separator to paragraph mode ($/="";) in a function, and though when I exited that block it would be set to the $/ value of returning blog.

FALSE: you should localize $/ in order not to interfere other parts of the module, nor other modules using $/.

local $/="";


Other one is looks_like_number from Scalar::Util.

I was using the flip-flop operator in scalar constant, and somewhat remembered something of returning an 'E' on the last line that matched. I used looks_like_number to check that, but.. omg! "23E0" looks like a number! It makes sense, but I didn't thought of it at first.

while(<>){
  $range = /foo/ .. /bar/;
  if(looks_like_number($range) && $range !~ /E/ && $range>2 ){
   #do things
   }
}

jueves, 25 de diciembre de 2008

Io language, a consistent scripting language

Some days ago I discovered a new language called Io (that's capital 'i' and 'o'). It's inspired by smalltalk, but with few features of other languages like self, lisp or lua. FYI, I discovered it among other cool languages. There are even more esoteric languages here.

First thing to say about Io is it's minimalist. Really minimalist. Only look at it's site to see it. As a minimalist language, its doc is also minimalist, so you have to understand the little doc fully, and I mean *really* understand. Io is a Prototype-based language with a syntax similar to smalltalk, but more minimal (assignation is a message too). Its introspection is astonishing aswell, and it introduces a concept of context which I'm still not very confortable with.

Anyway, I've already written my first program (a typical guessing number game) for Io. Here's the code.

guesser := Object clone
guesser toGuess := Random value(100) ceil
file := File standardInput
guess := file readLine asNumber
while(guess != guesser toGuess,
   if(guess < guesser toGuess,
     "higher" println,
     "lower" println)
   guess = file readLine asNumber
)
"ok, el numero es " print
guesser toGuess println


Ah! comunity is very friendly and willing to help (you can find them at #io @freenode