Weekend DIY

This weekend is longer, due to the national day of Catalonia festivity. I wanted to compose some music, but I had an ergonomic problem: one of my synthesizers was in an uncomfortable place. This was an excellent excuse to some DIY!

Shelf for my synth-module (DIY step 1)Step 1: The ingredients
I bought some handles and some “L” supports from Carrefour, and I had a walk in the neighbourhood to find a good piece of wood. I used a tape measure, a pencil, a drill and a screwdriver to make the holes and spin the screws.


Shelf for my synth-module (DIY step 2)Step 2: The cooking
Firstly, I discovered that the 2 “L” weren’t strong enough to hold the weight (the shelf folded down). So I had to buy a “capital L”, and put it in the center. With this extra, it has no problem supporting the synth’s weight.


SynthesizersThe final result
As you can see, now I have everything at hand. Time to make some noises!!

I’m a Humanist!

I don’t really like these kind of silly quizzes, but sometimes are funny…

“You fit in with: Humanism”
Your ideals mostly resemble that of a Humanist. Although you do not have a lot of faith, you are devoted to making this world better, in the short time that you have to live. Humanists do not generally believe in an afterlife, and therefore, are committed to making the world a better place for themselves and future generations.

20% scientific.
80% reason-oriented.

Take this quiz

Philosophical thought of the week

A morning office conversation:

Tony (a workmate): Is there a PHP function to stop for a moment the execution of a page?
Me: Yes, it is “sleep()”.
Tony: Just what I need, to sleep a little bit. Does it work with microseconds?
Me: No, it works with seconds. For example, if you write sleep(1), it is going to stop for 1 second.
Tony: Ok, thanks, you are a crack.
Me: And, even more, if you write sleep(2), it’ll stop for 2 seconds.
Tony: Why don’t we use it with a negative value? Probably we will speed up our websites!

Productive weekend

This is the last weekend before my birthday (on Tuesday I’ll be 29). I wanted to make the most of these days doing some things…

some DIY in blueFor example, on Saturday I was doing some DIY, painting a small table in blue which I found some days ago. It was not really clean, so I followed my father’s saying “dirt + paint = clean”. The final result is quite nice, because it fills an empty corner of the living-room, as you can observe in the picture. And I’m thinking about putting a plant pot on it… it could be perfect.

Also this weekend I’m starting to use my bike again, after I’ve done some improvements on it. I’ve discovered it is a really fast (and healthy) option for travelling inside the city. In fact, I’m seriously thinking about going by bike to the office. Today I’ve made a trial-run, riding the complete route. The final time was only 25 minutes, with a quite relaxed riding, although it’s uphill. If I compare it with the bus (my usual election, 35min) or the metro (around 20min, but in the morning it is like a tin of sardines), there is not possible discussion. In Barcelona there aren’t a lot of bike paths (here is a PDF map), but luckily most of my route is covered with them, so I must give a chance to the bike!

Beware of the Python on the Window (XP)

Two years ago, I arrived to Barcelona to continue my Ph.D studies. Two years, how long!, who could imagine all the things that were going to happen? In those days I was looking for a programming language to “fast-prototype” my ideas. The final match was between Python and Ruby, and I finally started to learn “the snake”. But due to a lack of research funds, I had to stop it and start working in a private company, and I didn’t really make a lot of use of Python.

Now I’m rediscovering this programming language, because I feel I’m using PHP too much (among other causes). So I started using Python again, and to start with, I tried to solve a problem/need I had:
– I had 42000 files, containing Go games (*.sgf)
– I wanted rename those files from ugly numbers to something like year-player1Name-player2Name.sgf.
– Some files had the header information coded in UTF-8, with player’s names written in Japanese characters.

I love Unicode’s UTF-8, with these lovely Japanese ideographs (and, of course, my favorite one is code “7881“). I’m using WinXP (yes, I’m a masochist), and I’ve read it natively supports UTF-8, so I thought it was a nice idea to have file’s names with Japanese calligraphy. Finally the result was beautiful… but 2 problems appeared:
1- Most of the Go-game programs on Windows are not prepared to read UTF-8 files, and crash. So I had to make a version without ideographs 🙁
2- Windows throws an error after renaming 10000 files… maybe renaming 42000 files is too hard a job for it 🙁

The code itself:
——————————

import glob,re,os,sys

pats = [re.compile(r'DT\[(\d{2,4})'),    #year
        re.compile(r'PW\[([^\]]*)'),    #player White
        re.compile(r'PB\[([^\]]*)')]    #player Black

files=glob.glob('*.sgf')
for file in files:
    fp=open(file,'r')
    content=fp.read()
    fp.close()
    info=[]    #were I'm going to save header info
    for pat in pats:
        try:
            detail=pat.search(content).group(1)
            detail=detail.decode('utf-8')
            try:
                detail=str(detail)    
                info.append(detail)
            except:
                info.append('kanjis') # replace ideographs
        except:
            info.append('unknown')

        info.append(file)
        newName = reduce(lambda x,y:x+'-'+y,info)
        try:
            os.rename(file,newName)
        except:
            print "Unexpected error:", sys.exc_info()[1]

print("Done!")

——————————
I know I can group exceptions, but I prefer to write in this way for an easy understanding. By the way, exceptions are one of the strange things of Python… IMO they are too “hardware” for this kind of language.

Nature is the answer

Twisted columns in Park GüellI live in Barcelona, a city marked with Gaudí’s spirit. Gaudí was a wise architect who studied shapes from nature, as a form of inspiration, and he used them to create new buildings. These shapes, like spiral, helix or hyperboloid, are not only beautiful but also interesting ways to sustain a building’s weight. Both beauty and engineering, a really good research.

This morning I was thinking about it: how can nature help us to discover new solutions? It spent millions of years fixing and optimizing common and uncommon problems, so it’s obvious that we should look at it to try to get some inspiration, some tips or clues, while trying to solve a problem. Also with Computer Science problems!

What does nature do to sort things? Maybe a new sorting algorithm is waiting to be discovered. How can DNA replicate itself with an incredible error-tolerance method, and making mutations a way to evolve? It has lots of examples to study. And you needn’t be a biologist to understand its behaviour. For example: look at the way you walk, moving your arms and legs in a curious synchronization, i.e. 4 elements moving “at the same time”. It’s probably an excellent method to save energy. Now imagine you have 4 arrays in your program, and you need to make a complex operation with them. Maybe the easiest way is to implement 4 nested loops to do this process (with a complexity of O(n^4)). But it might be a way to implement this process operating with these 4 arrays at the same time, with only a loop (O(n)!). It might be hard to find, although the result is worth the effort.

Now we are using some behaviours from nature, like neural networks and genetic algorithms, but I think we need to go further.

“Computer science is no more about computers than astronomy is about telescopes.” – Edsger Dijkstra

Holidays off

I came back to Barcelona. Holiday time was over. Again to work, to take the metro, to cross among dozens of people in the street. When I arrived I felt like empty, but in a few hours Barcelona filled me with this magic it has.

To start with, I had 3 laundries, lots of housework, a web almost finished and some meetings with friends. I spent some days doing this, and now I’m pretty free. Maybe today I can start with one of the “projects” I have in my list, from learning how to use programs (Inkscape, Gimp, Blender) to learning new programming languages (Python, Ruby).

Chair repaired and blue paintedYesterday I was cleaning my room when I looked at an old chair I have, and I thought it needs some restoration. So I started to improve its stability, holding the legs with new long screws. Later I painted the legs in blue, so the result is quite curious, as you can see in the picture. The blue paint adds more visual force to the legs, in a way that they are brighter than the rest of the parts. Funny!

The land of the fireworks

I’m spending the last week of my holidays in my hometown, Novelda. Like every summer, I got fascinated with different demonstrations of fireworks in Elche’s festivals (a neighbour city, where some of my cousins live). I can assert without doubts “this is the land of unbeatable fireworks”. I went 2 nights to watch these fireworks, and it’s quite impossible to explain. I’ll try to do it, although:

-“La nit de l’Albà” (the night of the dawn)- Imagine a city with a population of 200,000 hab. Imagine every person buying a lot of fireworks and firing them the same night, between 21:00 and 00:00. Also imagine the city council paying for more than 350 palm tree shaped fireworks, 9,000 dozens of rockets, 1,800 thunder-sounding fireworks, 500 whistle rockets, and more… and firing them in only 1 hour (between 23 and 00). The result is an astounding explosion of the senses, the whole sky full of light (and smoke from the rockets), thunder-like sounds everywhere. Next, at midnight, everything stops, the city goes dark, and from the Basilica’s tower, they launch the “imperial palm tree”, 900 rockets which fill the sky with light, covering the center of the city. Unbeatable! Every year I promise myself to come back, again, next summer. And I should record it on video!

-“Castillo final” (end fireworks’ castle)- The end event is also a demostration of fireworks, fired from a bridge. But in this case, it’s not so important the quantity, but the quality and innovation. Normally the city council hires a famous fireworks-builder family, who put the strongest effort in creating the most surprising fireworks. This year the result was amazing! Comets like fireworks, which slowly move in the sky, showing their big tail. Classical golden palm tree fireworks. A waterfall made with light sparks. Delicious to see!

Also on my holidays, I’ve had the pleasure to read some interesting texts. For example “Sock Sorting“, which explains some different sorting algorithms applied to this mundane task. Or a new idea to obtain “Power From the People“, which speaks about the way to get energy from usual actions made by the people, like crossing the subway gate.

Come back to Spain

Beach-line and pierFinally, after staying for 2 weeks in Bournemouth (UK), I came back to Spain last Saturday. This stay was like a fire-drill (or a trial-run), a way to verify my skills with English language. I was travelling alone, I met some gentlemen Go players, I studied some English, etc. The result, as you can see, is quite satisfactory. And my laptop and I overcame the horrible restrictions in British airports without problems!

The pictures!

So now I think I’m ready to work in a foreign country, outside of Spain. Beware of me! 😉

I was two weeks in UK and it never rained (but neither sunny)… and I arrived to Barcelona and it was heavily raining! Anyway I carried on travelling, to Alicante, to stay some days with my family. And the best way to start with is watching the “Nit de l’Albà” in Elche. An unbelievable demostration of fireworks; thousand of them fill in the sky 🙂 The real thing!

The curse of the men’s underwear

One of the most impossible things to find in this life is decent men’s underwear. With “decent” I mean slips or boxers which are neither flat white, nor “gay” multicoloured. Where can I find a nice green or orange slips, please?

In Barcelona I go shopping sometimes, but fashion shops don’t have a lot of options to choose from. Normally the shop space is mostly filled with ladies’ clothes, and “the rest” with men’s. In fact you usually have to go upstairs to the tiny men’s section, and look for the incredible small underwear section… where you don’t usually find anything interesting.

Today I tried to look for some underwear in UK. It was a surprise to find a shop with a big underwear section (upstairs, of course), with a 4×2 metres wall only filled with these things. Sadly, there weren’t “different” colors, but only white and black. Five shops later I didn’t find anything, still. Finally I came back without new underwear (only with a couple of egg-yellow socks).

Women, do you understand now why men don’t like to go shopping? 🙁