2006-04-07 11:38

Things that should exist.

One of my greatest frustrations as an adequate programmer is that I think of things I believe should exist, yet I am not able to implement them myself.

Today I will mention one (or two) of them.

There should be a Xen-based distro.

Xen is a very good virtualization package, which gives you multiple simultaneous virtual linux installations with very little overhead.

Sadly, to make it work, right now, you have to get a linux working, then install Xen, then install one or more extra linuxes as xen machines.

Which is not terribly hard, but could be done much easier.

I am thinking of something like this:

Installing Xen-Linux installs a very simple basic setup as the supervisor partition, sets up Xen properly, and sets you with a single Xen virtual machine.

Also, in another part of the disk, it has a gzipped file with a simple, basic linux setup which you use as a template for further virtual machine initializations.

So, whenever you want a new machine, you run a script, it sets it up, starts it, you get something like firstboot asking you the usual network/language/whatever questions.

Then, you are dropped into a nice package selection tool, where you choose what you want installed in this virtual instance.

And that's it.

This would encourage the administrator to always set up his servers as virtual machines, which except in cases of real hardcore performance requirements is a good idea (you can implement HA as full-image fallback. You can migrate to a new box in minutes!)

I could do most of this. However, that leads me to another thing that should exist...

A simple installer

Wait, you may say "Linux installers are simple already!!!" and youa re right.

I mean a simple installer for a guy trying to make his own distro!

I actually like anaconda a lot. But I would like it even better if I could just get some sort of tool that, given a list of packages, would create an anaconda-based CD with customizable install scripts.

And that is the piece I am not sure I can implement.

So, if anyone knows of any such thing, I would love to hear about it.

And as a preemptive message: No, I don't want to do it with Gentoo, or Debian, or Ubuntu, or Suse, or kickstart. I want to create a RPM-based, CentOS-based, anaconda-based installer that works just like a regular CentOS/RHEL installer CD.

2006-04-02 22:33

What I learned moving my blog

  1. PyDS is good enough to let you change how you host your site and keep it just working.

I switched from pycs.net (thanks for all the good work!) to a static site hosted at my ISP.

Since PyDS simply generates a whole lot of static HTML, this worked pretty good!

I generate the site, and then upload using lftp. No fuss, again, it just works.

  1. Static hosting sucks.
On pycs.net I had referrer logs, stats, comments. The static template from PyDS doesn't have any of that, of course.
  1. You can work around the suckage.

No comments? Haloscan can host them for you.

No stats? statcounter can do them for you.

No spam-free mail webform? I haven't looked yet, but I bet it exists someplace :-)

  1. You learn stuff.

I now understand how PyDS's macros/templates/nuggets/uploadings work. I thought I did. Now I do.

For example, I like comments for longer articles. Before, I added the links by hand. Now I just hacked the templates and it's done automatically. I could have saved a few hours of my life if I had bothered to learn it.

  1. Switching your URL sucks.
Since noone knows where the hell my page is. Luckily soon clee will switch me at planetkde.org and things will start to flow again.
  1. Depending on free hosting's tech support is not a good idea.

I love pycs.net. I loved how it worked. Until it stopped working.

I have no right to whine, though, so I offered to help (got no response yet). Then I moved out.

Since moving is annoying, I will probably not be going back, even if I start loving it again :-(

I am getting and reposting all the comments, but then gain haloscan has a 4-month limit on the comments, so I will have to implement some sort of comment-archiving and closing mechanism.

2006-04-02 01:56

BPython Lives!!!

In January, I suggested it would be trivial to write a preprocessor that would accept a version of python which delimited blocks with braces instead of indentation.

Ok, almost, I suggested #{ and #} as delimiters.

Well, I had a few minutes free today, and here it is, a functional BPython->Python compiler, so to speak.

Here's the kind of imput it takes (notice how it's not indented at all:

def factorial(n):
if n==1:
return 1
return n*factorial(n-1)

for x in range(1,10):
print x,"!=",factorial(x)

And it produces this (I am not happy with the indenting of the comments, but who cares):

def factorial(n):
  if n==1:
    return 1
    return n*factorial(n-1)

for x in range(1,10):
  print x,"!=",factorial(x)

As you can see, this is both a legal Python and a legal BPython program ;-)

It has some problems, like not working when you use a line like this:

#{ x=1

But hey, it is python with braces.

Here's the code. I predicted 30 lines. It's 34. And it's 99% a ripoff of Ka Ping Yee's regurgitate.py which you can find all around the web.

#!/usr/bin/env python
import tokenize, sys
program = []
lastrow, lastcol = 1, 0
lastline = ''
def rebuild(type, token, (startrow, startcol), (endrow, endcol), line):
    global lastrow, lastcol, lastline, program,indlevel
    if type==52 and token.startswith ("#{"):
    if type==52 and token.startswith ("#}"):
    line="  "*indlevel+line.lstrip()
    # Deal with the bits between tokens.
    if lastrow == startrow == endrow:            # ordinary token
    elif lastrow != startrow:                    # backslash continuation
        program.append(lastline[lastcol:] + line[:startcol])
    elif startrow != endrow:                     # multi-line string
    # Append the token itself.
    # Save some information for the next time around.
    if token and token[-1] == '\n':
        lastrow, lastcol = endrow+1, 0           # start on next line
        lastrow, lastcol = endrow, endcol        # remember last position
    lastline = line                              # remember last line
tokenize.tokenize(sys.stdin.readline, rebuild)
for piece in program: sys.stdout.write(piece)

So, all of you who dislike python because of the lack of braces and the significant whitespace:

BPython has no significant whitespace, and braces are mandatory.

Enjoy coding!

2006-04-01 13:19

Fighting Spam with Qmail (part III)

A new story in the "Fighting Spam with Qmail" series, after an over two year hiatus.

This one is about RBLs, qmail and a great tool called qmail-spp.

2006-03-31 15:18

New Site

Since pycs.net is broken and I cannot fix it, I decided to upload my site to a new server. And you may be there already ;-)

Sadly all the comments (and there was some good stuff there) are momentarily lost.

But I am working on it.

So, welcome, and if you want to read about whether I got married or not, do so

2006-03-27 14:06

So, I did get married

As I mentioned a while ago, I had my marriage scheduled for Feb. 18th (or 16th if you want the legal date).

Well, I did it. Rosario and I are happily married since then.

I promised to show a picture of the wedding, and specifically promised Taj it would be one where I was clearly visible.

Since a promise is a debt, you can see it. The picture is not greate because we still haven't got the photographer's. This one was taken by my sister.

At the time, I had already lost the suitcoat. Regardless of how good your air-conditioning is, you just can't wear three piece suits on February in Buenos Aires.

Everything went quite wonderfully, everyone liked the event, although I still grumble because I missed the best food because people wanted to talk to me!

All in all, a nice thing. I don't think I would do it again, though, a wedding is a hell of a lot of work!

No big honeymoon yet, we intend to go to Turkey (land of Rosario's ancestors) sometime around october.

In the meantime, we went to the Buenos Aires Beer Festival with a bunch of friends, were we saw a show by Divididos, which is probably the most incredibly awesome live rock band in the goddamn planet.

We also went on a weekend trip to Mar del Plata to see my parents, and a whole lot of other small things, including working on the very next week after the wedding. But it's all cool :-)

2006-01-27 22:04

Silly idea to make Python popular

I have an idea that can kill the most frequent complain about python.


BPython is a simple wrapper around pyhton which processes a .bpy file, produces a .py file, then compiles it into a .pyc.

What does it do? It uses braces to control flow.

Since braces are actual python syntax, you will have to use #{ and #}

As an added bonus, if you are careful, a bpython program will also be a valid python program.

Of course it has issues (like module loading) but those can be worked around.

The implementation should not be more than 30 lines of python. Or bpython ;-)

2006-01-26 12:15

Skeletons of stories that won't ever be written.

Inspired by "From Dusk Till Dawn".

Story Nr. 1: Night of the predator

Genre: Supernatural Horror.

Notes: This story should be written in Lovecraftian prose, and try to provide a sense of foreboding, and imminent doom, while seeming completely obvious.

Francis was the seventh son of a seventh son of a seventh son. As such, his fate was preordained. On every full-mooned friday, he would experiment a horrid transformation.

He runs through the woods while remembering the strange admonitions from his father, who explained to him the bloodthirst of the werewolf, the horror of his actions, the curse upon his victims.

He feels a nagging sense of things being all wrong. A hunger for strange, unnamed things. An eagerness for forward motion. A predatorial wish.

Then, while in the woods, looking at the moon, he experiences a painful elongation of his body, a constriction of his limbs.

His skin changes quickly, his teeth grow too long and sharp for his mouth.

He flops around for a minute or two and dies.

The seventh son of a werewolf is a wereshark.

The rest of the story is a CSI-style police procedural about the origin of a shark corpse 500km away from the sea, the protagonists are park rangers.

Story Nr. 2: The man with the golden brain

Genre: bondian superspy.

Notes: This should include a lot of technojargon which makes no sense, and the prose should be quite bad. Think Ian Fleming.

Our superspyprotagonist is tasked with destroying the world-destroying weapon of a thirld world dictator with a surprisingly large moustache and a beret.

This dictator's headquarters are beneath a volcano, and his weapon would destroy the world by provoking catastrophes of a very complicated nature (to be determined. ideas: drive all farm animals into a killing frenzy, make all 7up bottles explode at random times, turn cocker spaniels into evil scientists).

Our hero enters the lair through some complicated path involving sewers and airducts.

He is captured by the evil tyrant, and tied to a table with a giant laser aimed at his groin.

While the tyrant prepares to kill him in this over-complicated manner, the hero says "before I die, can I ask you one thing?".

The tyrant replies by blowing hero's head with a colt 45 then says "Hell, no!" [1].

Unimpeded in his plans because all industrialized nations relied on a single guy working alone, he blackmails all the world into surrender.

The rest of the movie is a geopolitical thriller about:

  • The difficulty of ruling the world from an underdeveloped country, with emphasis on telecommunication issues.
  • The ecological situation stemming from the forced undevelopment of Western Europe and North America in order to reduce the stress on the environment.
  • The psichological stresses on the world population when they realize their lifes depend on the whim of the guy with the bigger gun.
  • The compassionate rule of the aforementioned tyrant and benevolent dicator for life, who proceeds to disarm all armies (including his own), and never actually uses his weapon.


200 years later, the impossibility of remotely controlled explosive 7up bottles is terminantly proven.

[1] This is taken from the "Guie for the Perfect Tyrant".

2006-01-24 22:10

My first interesting hack

In the previous article, someone suggested cheating on exams as an interesting application of telepathy.

Which reminded me of my first interesting hack.

I was in college, back when computer time was allocated by the hour, and I had no computer, and I was about to take my final exam on linear programming.

For those who are not familiar with the term, linear programming is not really about programming. It's about solving a specific ind of optimization problems.

And for those who don't know that, don't swaet it, it reduced, in real 1989 life, to applying a program called LINDO to find a local or global min or max for a function.

Now, we were a poor college, so there were like 10 computers. For 5000 students. And we, in that subject, were not allowed to use it.

And it didn't have linear programming software in it anyway. And it had no compilers or interpreters (except qbasic).

So, we did LINDO by hand. On paper (the Simplex method).

And it was boring. But we did it. It is pretty simple once you get the hang of it. But you have to make hundreds of calculations, so we were allowed calculators.

And I had this baby.

I had bought it with my second paycheck as a teacher assistant. It costed me about the same as a small bike.

Or a TV.

And it had 4KB of ram, an ascii keyboard, and 116 preloaded programs for common scientific calculation.

It was the best calculator I ever had :-)

And it was programmable in BASIC.

So, the night before the exam, as I did a sample drill, I decided to implement a solver.

But since we had to solve things on paper, I had to show intermediate steps.

So, instead of a program to solve the problem, I wrote a program that solved step-by-step as done by hand. Which was about 20x harder.

And it did fit and run in the 4KB of ram, and it displayed the intermediate results on the 2x32 char screen.

Sadly, there was no way to take a program out of it, so it was lost on the next battery change.

But hey, I think that was nice :-)

Contents © 2000-2019 Roberto Alsina