Category Archives: Nerd

Generating all combinations of n elements taken t at a time

I don’t usually share the code I write for my research projects, unless someone asks for it. Anyway, today I had fun writing some C code, and I think it may turn out to be useful for other people. It’s written almost well enough to be acceptable, so here you are.

I implemented Chase’s sequence algorithm to generate the bit-strings corresponding to each combination of n elements taken t at a time. The algorithm is described in Donald E. Knuth’s “The Art Of Computer Programming”, Vol. 4, Fasc. 3, page 13. I implemented it in C and added very few comments, so refer to TAOCP if you have any doubts.

The code is distributed under the BSD 2-clauses License.

Download chaseseqcombgen.c

Posted from Providence, Rhode Island, United States.

Code tools

This is mostly a follow-up from yesterday post: ATM, to write code for my little project, I’m using Eclipse+PyDev+Subclipse+SVN on my MacBook Late 2008. These tools seem to help improving my productivity.

Writing code when you are a theorist

Despite my involvement in the FreeBSD and FreeSBIE projects, I do not think of myself as a coder, nor a “system” guy in general. I’ve always been more attracted by theory and I followed a mainly theoretic courses path during my M.Sc. . My thesis is about theory in data mining but involves some experiments and I have to write the code for them. The day I had to write the first of these experiments, I decided Python would have been my language of choice, mostly because I wanted a language which allows fast and easy write-test-run cycles. Python gave me that.

In the last few weeks I thought about improving the way I write code: I felt I was lacking discipline and order. One of my advisors said my writing style is really formal when I write about computer theory. My code was quite the opposite. It was ugly, with no underlying design, with a lot of semantic errors, fragile and so on. I had to steer away from that development style.

I am now a little bit slower in writing code, but my code is better. It is easier to test. Easier to debug. Easier to be reused. More formally correct but easier to read. It will improve even more, I hope, now that I have a (small) project to work on every day.

On the naming of computers and its evolution

Like many geeks, I have my own style in naming the machines I have access to. This may sound strange to people not used to live between a chair and a monitor but, according to many, you may really want to give a name to the non-animated thinking being (please note the double absurd of calling something non-animated as a being and describing it as thinking) you spend much of your time with.

My naming convention has always been the same since the very beginning of my “serious” (like in UNIX) involvement in computers: using different translation of the word “emperor”. “Emperor” is one of the countless nicknames my friends gave to me in these 22 years. Since the computers were/are mine and/or administered by me, I chose to give them one of my names. Yes, a bit selfish.

My main desktop machine has always been called kaiser (German): it is a strong word with a powerful pronunciation which resembles the meaning of the word. Other machines’ names I used are czar (Russian) and empereur (French). Starting from this use of royalty names, I began using others: kadett (German for `cadet’) (my old HP Jornada 680), margravio (an old Italian word for `marquess’) (a very very old IBM PS/2 N33SX, actually one of the first computers I used and which I resurrected using FreeDOS), ambassador (not really royalty, but it fitted because it was the name of my wireless network), siniscalco (Italian for `seneschal’) (another wireless network). There is another convention which I use on my *nix machines: the following line is always present in the /etc/motd file

Welcome to Rionda's $OSNAME (with $OSNAME being usually FreeBSD, or Darwin for my laptop)

The names of my laptops don’t follow the royalty naming convention, but my first Apple iBook Firewire (named scudiero, Italian for `squire’). The second, the immortal beautiful (not really) powerful (not really) IBM Thinkpad R50e was named krapfengeist, a German word which approximately means “the spirit of donuts” =). Third, and last one, my current Apple MacBook Aluminium, whose name is no less than abulafia.

Now, let me explain this last one. One of my favourite books, together with “The Name of the Rose” and “Goedel, Escher, Bach: an Eternal Golden Braid”, is Umberto Eco’s “Foucault’s Pendulum”. I read it at least once every year, often twice a year. One of the main characters uses a computer to develop a Plan (why the capital “P”? Go read the book!) and to write personal memories. Or, as Wikipedia says, it was used “not only for word processing, but also to attempt to extract meaningful snippets from random permutations of text in a fashion reminiscent of Abraham Abulafia’s methods”. Yes, the computer’s name in the book is abulafia. I like the book and the way the computer is used in the book so much that I chose to name my own laptop after it.

There is an additional feature of the book I like to mention. It is a bit of a spoiler, so don’t read this paragraph if you want to read the book. At the very start of the book, another main character has to break into abulafia but he doesn’t know the password. When the machine is started, the following message is printed on the screen:

Do you have the password?

After having tried many times using numbers, names, permutations of the name of God (ihaveh) (the book even describes a program to generate the 720 permutations), the hacker is tired and lost:

Do you have the password?   no

He types “no”. And he is logged in. “no” was the password. I find this brilliant. It makes sense with everything. I cannot explain why here: I would spoil the whole plot.
Read the book.

And give a name to your computer. It deserves it.

As bonus, you get the /etc/motd from my laptop:

Welcome to Rionda's Darwin

Do you have the password? no
Umberto Eco - "Foucault's Pendulum"

P.S. Nice geekish post, isn’t it?

Magnis Itineribus (going on by huge steps)

Lighthouse? In little more than one month at Brown University, under the supervision of Prof. Upfal and Prof. Pietracaprina, I think I learned a lot, both in terms of new concepts, ideas, tools and in terms of how to do research.

Yes, I’m really proud of myself and of the work I’ve been doing since I came here. =)

As a side note, I got a new MacBook and I’m testing VMware Fusion with FreeBSD as guest OS ATM. If I’m satisfied with it, I may even buy Fusion, since the student price is reaaaalllly convenient. This also leads to the consideration that I’m back with a FreeBSD machine, although virtual, and ready to start contributing to FBSD again. Yay!

Three days in Milan

This morning I had to go to the US Consulate in Milan to get the visa. I’m in Milan since Wednesday, hosted by Max Stucchi.

On Wednesday night, GUFIPizza took place: it’s the monthly meeting of the GUFI (FreeBSD Italian Users Group) members who live near Milan. Since I was there, other members who don’t usually show up showed up ( ;) ), Cris, _Oity_ and satu among the others. It was fun because I didn’t see some of them since 2 or even 4 years. We proved that geeks cannot speak about anything but computers when they meet, even when they don’t want to. That night, the main topic was Facebook. Anyway.

Yesterday I went to NewOldCamera and bought two Voigtlander-Cosina rings to mount my Leica screwmount lenses on my Leica M (actually CL) body and I even bought a Billingham L2 bag. It’s soooo well made. =)

Today is a raining day in Milan and I have neither an umbrella nor a jacket… :|