Monthly Archives: November 2007

A clock with pictures

NOTICE: Find more in my tech blog:

Last night I had a look at the public Flickr API, just to have some fun. I discovered it’s really complete, with a lot of possibilities, covering different search approaches. You can easily ask the API for info about pictures, and use the results with imagination.

On the other hand, I was also interested in javascript frameworks. I used to use Prototype, but I wanted to have a look at jQuery.

So I took the opportunity to do something funny using both things:

A clock that uses Flickr pictures containing digits.

Every time the page is loaded, it searches in Flickr for pictures containing a digit, and chooses one picture randomly to represent that digit (most of the time those pictures are neat). Then it exchanges the font digits for images, including the link to the original image (click on a digit to see it). Just this. Isn’t it beautiful?

Book zapping

ReadingThe other day I was speaking with Jordi, while looking for a firewood heater in Encants flea market, when I realized I’m reading a lot of books at the same time. I knew I was reading more than 1 book, but I didn’t notice the exact amount of reading threads.

Let’s enumerate them:

· La Costa de los Mosquitos (The Mosquito Coast), in Spanish, page 304 of 382: A deep novel about ecology, with different approaches to the search of balance between human activities, technology development and the nature. It’s far deeper than the film. It’s lent by my cousin, but I also want to buy it in English.

· Manual de UML (UML Demystified), Spanish, 84 of 224: You’ve guessed it, a book about UML, that I bought a couple of weeks ago, just to refresh my mind and help me drawing ideas of a personal project I want to develop. Easy to follow, but sometimes too boring.

· Fundamentos de Algoritmia (Fundamentals of Algorithmics), Spanish, chapter 1: A technical book that I read jumping randomly from one chapter to another. But I should read it from beginning to end.

· Ajax in Action, English, 226/560: I have it on the night table, and its really deep, plenty of ideas to apply. Unluckily it’s not comfortable to hold, so I read it from time to time.

· Moreover I have “STL Pocket Reference” in my coat’s pocket, just to peek methods and algorithms while I’m on the bus or underground. And “Dive into Python” (PDF version) in my PDA, to read in darkness.

The other day I received “Accelerated C++“, and I’m eager to start reading it, cause it looks like a real C++ book, more focused in the C++ own capabilities than the classical “from C to C++” approach. And next week another parcel will arrive with Efficient C++, The Cathedral & the Bazaar and Joel on Software.

I need more eyes!!

Looking at the stars, again

When I was a teenager, I liked astronomy. I used to go outside the city, with some friends, to see the night sky. We carried some stuff (small telescopes, cameras, binoculars, etc) in the car’s trunk, we wore a lot of clothes to avoid the cold in the winter nights, and we enjoyed focusing the planets and the deep sky. Now I remember those times with some melancholy.

Last weekend, being in Novelda (my hometown), and armed with my new SRL camera, I decided to go again outside the city, to a darken place, among the mountains, to enjoy the night sky again. I was alone (none of my old friends still live in Novelda), but all the winter sky was there, the same friendly sky. M42, Orion Nebula was there, so was the tiny Pleiades. I did a trip with just my binoculars, enjoying again the galaxy of Andromeda, the double cluster, and a newcomer: Comet 17P/Holmes.

Comet Holmes, with trackingActually comet Holmes is not a new object. It was discovered in the 19th century, but some weeks ago it blew up, raising its brightness to a really high magnitude, making it visible to the naked eye. I decided to try to capture it with my camera, among other deep sky objects. Here you have one of the successful pictures. Unluckily I had an unperceived problem (now solved) with the focus, and most of the pictures were slightly out of focus. Also I had problems with the cold… my camera was freezing and I had to take out and heat the batteries!

Anyway, the experience was great! Seeing this giant ball with binoculars is incredible.

I’m planning another observation, but unluckily it’s impossible to do it in Barcelona (due to the light pollution), and during Christmas (when I expected to be in Novelda again) there will be full moon (horrible to take pictures)… so I have to find a good slot of time and place to repeat the experience. I’ll share the pictures!

The essence of the strategy

Hex The other day I met up with some friends to play a lot of different games, except Go (because we are all Go players and one of them wanted to do something different). Here you can see myself, teaching how to play Hex to César (the strongest Go player in Spain).

Hex is a board game invented in 20th century by Piet Hein, and also independently by John Nash. It’s played on an hexagonal grid, like a rhombus, and the idea is to connect one side to the opposite side (one player from left to right, the other player from top to bottom). The rules are deadly easy: in your turn you just put a stone in a empty hexagon, and that’s all. The first player who create a connected path between his sides, win. You can play on-line on Kurnik (real-time) or on Littlegolem (turn-based).

Having simple rules, the game is based in general strategic concepts, like Go. I mean, you can touch these strategic tips, you can apply them easily. So, for a strong Go player it wouldn’t be difficult to play quite decently. For example, I tried to use these general ideas, and I won several games against medium Hex players. The other day I taught César the rules of Hex, and in the second game he was playing good moves. Just applying things like: look for dual (or multiple) purpose moves, steal enemy strategy, search for moves with alternative paths of success (this is called “miai” in Go), and read out the sequences!

Back lights for my bike

A few moths ago Barcelona’s city council signed a new law for (against) the bicycles. In the last years a lot of people has started to use the bike here, despite the lack of bike paths. Therefore the city council decided to write laws to maintain the order. But Barcelona is not like most of the cities of Europe, regarding the respect for the bikes… I mean: pedestrians walk on the bike paths (I’ve had 2 accidents against them already), cars (and specially courier’s vans) use the bike path as a parking place, and if you try to cycle on a car or bus lane (as the new law recommends) you get a lot of horns sounding.

Home made back lights for my bikeAnyway, following the new law, you must have lights on your bike. So here I am to make some DIY. I bought some LEDs (two 3.5v ones), a resistor (330 Ohm), a battery holder and a 9v battery. Using an Ikea catalogue as worktable, and a soldering iron, I built an easy circuit. As you can see in the picture, the final result is quite nice and neat 🙂

I’ll test it tonight (if it’s not too cold).


In the last few months I’ve played some games of Diplomacy on an online server called phpDiplomacy. You can reach me out there as “liopic“.

Diplomacy boardDiplomacy is a strategic board game that represent the position of European powers before the World War I. You start leading one of the seven powers, moving a really small amount of armies (3 or 4, actually), and the goal is to conquer most of Europe. With 6 more players on the board, and everyone owning only 3 units, it’s quite difficult to accomplish much expansion on your own. So, the only option is to start speaking with the other players, to form pacts, alliances, common objectives, etc… for getting support of your moves, or give it to theirs. Actually the game is strongly focused in the diplomatic part; the board is just a excuse to hold the conversations.

As I played more games, I discovered a lot of diplomatic rules, like “search the common benefit”, “be polite but firm”, etc. On the other hand, I also discovered new vocabulary like “stab”, “backstabber” and such. But in my opinion it’s a good game, specially to develop some social skills and try to improve the negotiations habilities. In my personal case, this is a must: my social skills are totally underdeveloped. Let’s see if this helps me. At the moment, I’ve only won a game, from 12 played :-/


NOTICE: Find more in my tech blog:

KISS : Keep It Simple and Stupid

Sometimes I forget this principle. The other day was one of such days. I was trying to solve a problem at TopCoder (a website that runs computer programming contests)…

The statement was something like “given n males and m females, sit them down in a circular table, in a way that if you start removing every K persons, after m steps there will be only males”. It looks like a trivial problem (and it is), but the difficulties arrive when you consider a big K, starting to do loops with a different number of people each time.

I started using a lot of modulus operations and trying to get an elegant solution as well. But the modulus is quite expensive (in computational terms), and the code was getting confused (and of course it was really difficult to trace). I made a lot of examples with pen and paper, trying to abstract something useful. Suddenly I realized: why don’t I program just what I am doing with pen and paper? Just letting the computer iterates every step, counting and setting females at the K step. I programmed it, and later I verified (peeking other’s code) that it was the correct solution: simple, stupid, but effective. [Well, actually the complexity in this way is O(m*K), and using only modulus is O(m), but in a short domain (as they said, K<=1000) the first solution is faster.] This reminds me a classical quote:

“Everyone knows that debugging is twice as hard as writing a program in the first place. So if you’re as clever as you can be when you write it, how will you ever debug it?” – Brian Kernighan