Skip to main content

Ralsina.Me — Roberto Alsina's website

2006 resolution

I will make some of my work pub­lic.

The best can­di­date is one that will prob­a­bly not ap­peal to any­one: my per­son­al lin­ux dis­tro.

I have it, I use it all the time. It's not pub­lished yet, though, since it con­sists of a base Cen­tOS + a lot of work.

So, I will try to make it sys­tem­at­ic, call it an in­staller, and drop it on the un­sus­pect­ing au­di­ence.

Don't hold your breath, though.

Here are some of the fea­tures:

  • Serv­er ori­en­t­ed. I use it for my clients' server­s.

  • Qmail+­­couri­er+vpop­­mail+round­cube+s­­pa­­mas­sas­s­in+­­cla­­mav mail sys­tem.

  • Squid prox­­y+fw­builder fire­wall

  • Smart for pack­­age man­age­­ment

  • runit-based boot/ser­vices.

  • KDE as a GUI. Ac­c­s­si­ble via FreeNX/se­cure VNC.

  • Open­VPN for sim­­ple VPN man­age­­men­t.

  • Cus­­tom cher­rypy-based ad­min tools

  • No SeLin­ux (sor­ry, it's a pain in the but­t. Se­cure, but a pain).

  • Bac­u­la for back­­ups

  • Cus­­tom tool to back the whole disk to a bootable DVD (Sys­tem Res­cue DVD)

  • /etc in SVN+­­Trac (yes, re­al­­ly, and the ad­min tools force you to use it)

  • Prob­a­bly djbdns for DNS.

All in al­l, it's a pret­ty or­di­nary Cen­tOS-based thing, ex­cept that the switch to runit makes ser­vice man­age­ment way sim­pler and reg­u­lar ( you can do things like hav­ing a non-­root us­er that can man­age some ser­vices, yay!)

On the oth­er hand, the cher­rypy-based tools would prob­a­bly need a bit of a rewrite, since some are pret­ty crud­dy.

Most­ly, I have been gath­er­ing these pieces over the last 6 years as I re­al­ly don't like the way any of the Lin­ux serv­er dis­tros are built.

I based it on Cen­tOS be­cause do­ing the whole dis­tro by hand is way too much work.

I can prob­a­bly show it around June, if I don't get too side­tracked. Hope­ful­ly, some­one will read this list and tell me "but graxzst lin­ux al­ready does all that!" ;-)


Saw Nar­nia the oth­er day.

Liked it.

Of course, the whole sto­ry makes no sense, but hey, that's how it's sup­posed to be.

If you have not seen it, and have not read the book, and in­tend to ig­nore the plot, please stop here. Ok?

There is this large li­on, Aslan.

He gives his own life to save that of a snivel­ing treach­er­ous, sil­ly kid who sells oth­ers for turk­ish de­light (a can­dy Rosario tried in Is­tan­bul, and tells me is pret­ty good, so there is some sense in him).

Ok, so the kid is ac­tu­al­ly just scared, and pet­ty, and a kid, and he's not that bad.

On the oth­er hand, the li­on...

For the whole movie, the White Witch is built up as evil, and mon­strous and a killer. But it turns out that the worse she does is freeze her vic­tim­s. Un­harmed.

She even­tu­al­ly kills some­one in a bat­tle (but so does Pe­ter, our 14-year old "hero").

The frozen guys can be re­vived at will by Aslan. Who for some rea­son had not done so.

On the oth­er hand, Aslan's big sac­ri­fice? He knew all along that he would be un­harmed. Even his mane re­grows af­ter a few hours.

At least he could have told the two poor girls who thought had seen him die. And skipped the whole heavy-­heart­ed "o­h, I am so sac­ri­fic­ing my­self" walk through the wood­s.

Oh, you may say, but the war is fought so that the true rulers of Nar­nia will as­cend to their thrones!

Well, how in hell are those four eng­lish kids the true ruler­s? They had nev­er been there, they have no con­nec­tion to any­one there!

Hell they are the on­ly four bloody hu­mans in the world!

It looks amaz­ing­ly racist to me. Species-ist?

So, hun­dreds of Nar­nia in­hab­i­tants die (and I mean re­al­ly die, not fake-die like that Aslan kit­ten) so some car­pet­bag­gers get to lord as kings over the ple­beian mass­es, in­stead of an­oth­er high­-born chick.

My sug­ges­tion to the hordes of gryphon­s, sphinx­es, po­lar bears, faun­s, cen­taurs and dwarves:

Kill them al­l, and start liv­ing a de­cent life, with­out sup­port­ing use­less par­a­sites.

Free Phillip!

PS: Yeah, I did like it ;-)

My first time

I just found here the an­nounce­ment of the first free soft­ware I pub­lished (at least, that I re­cal­l), from may 13, 1996. So, It's go­ing to be 10 years in 5 month­s!

Killer quote:

Python 1.3 (Maybe 1.2 would work too)
XForms 0.80 (NOT 0.75)

Ok, here is how you write the shortest one

About­con­ here's how it's done.

Sad­ly, it's pret­ty much im­pos­si­ble to put the code on the web be­cause it has some re­al­ly non-ascii stuff in it ;-)

Here's the key tricks (thanks to Re­mi and the oth­er­s):

One of the key tricks is writ­ing a short ver­sion of a very long oc­tal num­ber (or three­).

I tried us­ing base36 and in­t('­gob­ledy­gook',36).

You could use 0x­hex­a­code­here.

But here's the most space-­ef­fi­cient one: use base 256!

For each byte you wan­t, cre­ate a char us­ing chr(byte). Then paste them all to­geth­er. Then put it in your code as a string. If you are lucky you will have no quotes or new­lines in it, and the python in­ter­preter will eat it.

You can lat­er get the byte num­ber x us­ing or­d('h!als­d­f'[x]), and each byte by some di­vid­ing and mod­u­lo op­er­a­tion.

An­oth­er im­por­tant piece is en­cod­ing 7 3-char­ac­ter strings as com­pact­ly as pos­si­ble, and split­ting them by off­sets (which are en­cod­ed in the pre­vio­su­ly men­tioned big num­ber in base 8 ;-)

One ex­tra squeeze is find­ing the short­est way to con­cate­nate strings.

It's ''.join(), but if you are us­ing it twice (or more), you save space by do­ing j=''.join and us­ing j lat­er.

Last one: In­stead of defin­ing a func­tion, do a lamb­da:

def sev­en_seg(x): re­turn .....

sev­en_seg=lamb­da x:

6 chars less!

And here is the short­est code I got so far (121 char­ac­ter­s, re­quires python 2.4. On 2.2, it has to be 124).

In the con­test, some guys are at 120. I don't know how. I can't even guess how ;-)

Up­date: it turns out I did know how to do it check it out I think it's the first pub­lic 120 :-)

BTW: you can't write that us­ing kwrite. Vim work­s, though.

Python Contest

There is a python con­test at­con­

The task is writ­ing the short­est pro­gram to drive a sev­en-seg­ment LCD thingy.

I have no hope of win­ning, but here's a help­ful hin­t:

If your code is any longer than this (191 chars), it will not win ;-)

a=' _ '
c='   '
d='  |'
e=' _|'
f='|_ '
g='| |'
def seven_seg(x):
        return '\n'.join([eval('+'.join([v[int(l)*3+i]for l in x]))for i in 0,1,2])+'\n'

Note: I edit­ed this item way too many times al­ready ;-)

And yes, I can save two char­ac­ters mov­ing the re­turn up.

A much uglier, yet much short­er (151) ver­sion:

def seven_seg(x):return''.join([''.join(['|    ||__  __ || |  |'[int('a302ho6nqyp9vxvpeow',36)/10**(int(l)*3+u)%10::7]for l in x])+'\n'for u in 0,1,2])

And yes, that pret­ty much proves you can write ug­ly python. And I am giv­ing up. A short­er ver­sion prob­a­bly in­volves a dif­fer­ent al­go­rith­m, and I can't find any.

I am par­tic­u­lar­ly proud of sav­ing one char­ac­ter by writ­ing 104004334054154302114514332064 as in­t('a302ho6n­qyp9vxvpe­ow',36).

Al­so in­ter­est­ing is that the num­ber I was us­ing there orig­i­nal­ly start­ed with 4 and was ex­act­ly the same length writ­ten both ways ;-)

Since that num­ber is pret­ty ar­bi­trary (it's an in­dex ta­ble in­to the "graph­ic­s" ar­ray), I just shuf­fled the 1 and the 4. The 0 would have been bet­ter but then it did­n't work, of course :-)

Contents © 2000-2023 Roberto Alsina