I fell in love with my new flatmate

When I moved to my new apartment I decided to live alone, but sometimes it’s a bit boring. However I didn’t expect to create a space for her, until I met her some days ago while shopping. And now I have a new reason to live!

She is Spaniard, from Salamanca. She is dancer, with strong legs. She has an exquisite taste. She is tender and hard at the same time. There is real content inside of her beautiful body. And she has a happy salty mood. She is so pretty, that sometimes I can’t keep my eyes out of her. I run to the kitchen and when I see her my mouth starts to salivate. Her image is always bouncing in my brain… isn’t that love? Unluckily she will stay here for one month, maybe two months… a pity. I love touching her, smelling her, tasting her all the time, non-stop.

I’ve just taken a picture. But you have to be Spaniard to understand me. Isn’t she hot?

A poet who invented the game of Hex

“NAIVE.
Naive you are
if you believe
life favours those
who aren’t naive.”
– Piet Hein

It’s curious to see that some very logical people are poets and abstract creators (maths, music, games, etc) at the same time.

Peeking at Piet Hein’s biography, inventor of the game of Hex (also independently invented by John Nash), I discovered his poet side. He created a lot of games, including Hex, Tangloids and Soma cube. But he also wrote thousands of marvelous “grooks” (short aphoristic poems). It’s a pity that his books are out of print… anyway I found a page with a collection of them. Enjoy!

P.S: It reminds me “Proverbios y Cantares” by Antonio Machado (in Spanish) and “Stray Birds” by Tagore.

Half the people you know are below average

Intriguing sentence!

But I should add: if you (like me) are in the 10% of the people with more than 120 IQ, 90% of the people are “worse” than you… really? Could you visualize the faces of 10 friends and say 9 of them are “idiots”? Ok, now I see what you’re thinking: “but I only have clever friends, because I usually befriend with smart people”… really? How many of your friends come from clever social events, and how many you met in just normal places (like school, university, workplace)?

Anyway, why people love comparing himself among others?

A galactic empire of data

Speaking with a friend, an old game came to my mind. 15 years ago I started playing “Elite II“, a space trade game, probably one of the firsts where there is no final objective, just interaction with the world. You could trade items between star systems, do all kind of jobs, improve your ship getting more space cargo and weapons, and travel throught the galaxy, literally. You could fight in battles as well, but this part bothered me. Trading throught the galaxy was the best part. It was full of star systems, with planets and space stations to visit. This was one of the most impressive feature, specially if you take in mind the game came in one 3.5 disk (720Kb), but actually all stars positions were fake, programatically generated, so the only true thing of them were their names. A small pity.

I downloaded it (now it counts as abandonware), and using Wine on Linux I saw again its generated maps. Moreover I’d like to explore its open source “mirror”, Oolite.

Our galaxyI thought it would be nice to create some kind of space trading game using real star data. Of course programing a game takes ages, but maybe I can create a small trading web-game just with some features. So I started to look for some stars catalogs ready to download, with some real data. Finally I found one quite small but with useful data, like the galactic coordinates of every star, and bright magnitude and spectral type. Just playing with gnuplot I got this image of our galaxy (biasing longitude, click to show it bigger). As you can see most of the stars are in the plane of the galaxy, with a dense cluster between -20 and 20 degrees of latitude… so keep your ship in that range!

Testing (during winter solstice)

What was I doing during the shortest day (in Northern Hemisphere) of the year?
Enjoying the “code coverage” used in testing, while traveling to my hometown by train for Xmas.
Testing, code coverage… what’s that? you ask. Let me explain.

A really important part of developing code is testing the code you write. It’s the way to verify your code really works. The easiest way to do so is inserting some “prints” here and there, to verify that variables store expected values. Or you can write an external program to stress your code with some inputs and verify expected outputs. But the best way is to use a testing tool for creating automated tests. Then you normally do some unit tests (that stress modules/objects) and test suites (that aggregates unit tests).

Until recently I didn’t use automated tests. But some months ago I discovered PHPUnit, and now I’m “safe”. Automated tests helps you and your team against careless modifications (made by this new internal, or by yourself in a bad day).

And what’s code coverage? Well, when you write tests, there is a way to see if your tests stress all the code lines: code coverage. But let me show you a really small example of this useful tool.

Imagine this function/method:

function isChristmas($day,$month)
{
    if($day==25 && $month==12){
        return "Merry Christmas";
    }else{
        return "Have a good day";
    }
}

And this (obviously uncompleted) test:

public function testChristmas()
{
    $this->assertEquals("Have a good day",isChristmas(12,12));
    $this->assertEquals("Have a good day",isChristmas(28,02));
}

When you launch PHPUnit and ask for a code coverage analysis in HTML, you get something like this (click to see it fullsize):
Code coverage with PHPUnit
Isn’t this wonderful? You get a lot of information! You quickly discover ways to improve your tests and sometimes your source code… how could’ve lived without this?

Merry Christmas, by the way!

Professional PHP: A difficult task, and even worse in Spain

PHP ElephantThis is a post about tech books. Sometime ago I discovered that Internet is not, and should be not, the only information source for an IT professional. It’s a good place to search for technical reference, to scan for chunks of information, but definitively it isn’t a place to read long texts. Books are the alternative. We get used to scan text on Internet (Nielsen dixit), but we read books in other way, in a more relaxed way. And books authors write books in a different way from writing on Internet. We need books (or big and comfortable e-books) in order to understand “the big picture”.

PHP is a flexible language, and thanks to its version #5 it’s a modern object-oriented language. It’s also an easy language to learn, which leads to help newbies. But, just because this, most of the PHP programmers’ population have a low programming level. This could be a reason to explain why almost every PHP book seems written for newbies. PHP5 is object-oriented so, as an example: how many books explain Design Patterns using Java? More than 30 (according to an Amazon search). How many with PHP5? Just 4. Another example… let’s speak about unit testing: how many books are out there on jUnit? Around a dozen. And on PHPUnit (something like jUnit, but in PHP)? Just ONE!

And things get worse if we speak about trying to buy advanced PHP books in Spain. Libraries in Spain avoid books written in other languages but Spanish, and of course none of the “advanced level” PHP books get a Spanish translation. So the reality is that it’s almost impossible to get a decent book. Last year I was surprised when I went to London, entered in a just normal library and found a lot of hi-tech PHP and AJAX books. I tried to found a good library here in Barcelona, but it’s impossible: so finally I ordered some books to Amazon UK!

Advanced Beauty

This title is a bit pretentious, but “Advanced Beauty is an ongoing exploration of digital artworks born and influenced by sound, an ever-growing collaboration between programmers, artists, musicians, animators and architects”. Concretely it’s a collection of 18 abstract videos where the image plays with the music (or probably just the inverse). Let’s see one of my favourites:

This reminds me the satisfaction you get when you program something visual. You normally program to get data, or process data or whatever; data which is in the shape of numbers or strings… sometimes this is so boring. But if you directly program and tweak curves, colors and motion, you can never get bored doing this visual stuff.

Cause first human sense is vision.

Moral discusions on using foreign WiFis

A friend of mine moved to a new house recently and wanted an Internet connection. He realized there were lots of WiFi nets around his house, so he asked me about a system to discover WiFi passwords. I told him I read somewhere about statistical attacks, and after some googling I find the tool suite “Aircrack”. He thanked me and in 1 hour of sniffing and some seconds trying passwords, his machine answer with a valid password. So now he is using a neighbour cracked WiFi, but “only for email and web-surfing… nothing about P2P”. Is that a crime?

Quite interesting thing to discuss. I commented it to some friends and there are some moral “differences” most people agree:

– If the WiFi is open, most people don’t think it’s a bad thing to connect his laptop (for awhile), but if you crack a WiFi password, you are a ganster at least. Actually in both ways you are stealing bandwidth to an inexpert neighbour. However everybody I know has used sometimes open WiFis… so, is cracking the “bad thing”? Both ways you are stealing his car, it doesn’t matter if he left the door open or if you used a master key. Curiously in Spanish Law there is a difference.

– If you use that cracked WiFi connection just for email, it’s fine. If you use to download porn, it’s a savage action. Does the content of the information moved make the difference? If you steal the car for going to the office is not as bad as stealing for going to kill somebody… really?

New house

Terrace in the evening Having a new job it’s not enough change!

Last monday I finished my moving, with the help of 3 strong friends (Alga, Enric and Jordi), to my new house. A 2-room penthouse with a nice terrace, in front of Montjuic mountain. A really calm place, with a lot of vegetation, where you can’t smell city pollution, almost.

At the moment I’m cleaning the house and unpacking my stuff… so tiring. It will take weeks. But the place’s worth the effort!