Older blog entries for ralsina (starting at number 676)

Nikola Can Parse That

Just for completeness' sake I have gone over Wikipedia's list of lightweight markup languages and added support in Nikola (a static site and blog generator) for a couple of them: BBCode and txt2tags, which brings the number of supported markup formats to 7 (the others are reStructured text, markdown, HTML, textile and Wiki).

Of the list of markup languages, the only missing ones with a Python implementation are AsciiDoc and Markdown Extra.

Why bother with this? It's not as if there was someone asking for BBCode support. However, one of the uses I want to support is archiving sites. Suppose you have a forum you want to shut down? I want you to be able to archive it (even if it's some work) and keep the data out there. A wiki? Same thing.

This is a first step in that direction.

Syndicated 2013-01-22 17:05:04 from Lateral Opinion

Make Me Talk

One of the things that have helped me be less shy and thus have helped me move forward in life is speaking in public. However, I have been speaking in public very little these last couple of years.

So, make me do it more. I am looking forward to speaking in places I haven't been. If it's not horribly far from Buenos Aires, I may not even ask you to pay for my trip and/or hotel, I will pay for it myself if the event is interesting or the place looks like a fun place to travel to.

I can speak about python, free software in general or other things you may suggest, and I can do it in spanish or in english.

Syndicated 2013-01-21 10:13:49 from Lateral Opinion

Mardel->Retiro->San Isidro->Ezeiza->Dallas->San Francisco

I am at a Canonical thing in San Mateo (right next to San Francisco). Arrived yesterday, and have my last free day today, so I need to get some sightseeing done.

For starters, here's the trip gallery, not very full yet but going to post the as I get them.

But the trip...

I was in Mar del Plata visiting family on thursday, and had tickets for Buenos Aires at midnight. At 9 PM... long distance drivers strike. All buses suspended. Ran to the train station to see if there was a chance of getting one: no tickets for a week. Seriously considering a 500KM taxi ride.

At 11PM... strike suspended! So, get the family, get the bags, get on the bus... no, sorry, you can't get on the bus because you are an idiot and you bought them for the wrong day. Really, I bought tickets for thursday 00:05 not friday 00:05.

In a busy vacation town, at midnight, without tickets... ok, so we bought new tickets for 15 minutes later. If it's a problem you can fix with a given amount of oney, at least that puts a certain value on how uch of a moron yours truly is. I am about 120 dollars worth of moron.

So, new tickets. but they are not (of course) tickets to where I live, they are tickets for BUenos Aires Retiro bus station, which is about 25KM away from home.

So, at 00:30 we get on the bus, at 5:45 we are at retiro, at 6:00 we are on a car, at 6:45 we are at home. At 7:00 I am asleep. At 9:00 I am awake and ready for work!

I work intermittently while packing bags and such, at 5:30PM am on a car to Ezeiza (35km ride). When we are entering the airport, smoke starts coming out of the AC (did I mention that the AC was broken and it's roughly 1.5 hours in bad traffic in 30C, under the sun, to get to the airport? I should have!).

So, apparently the car is on fire, but just a little bit, the smoke goes away, I get off the car, meet Lucio, we do our checkin, I have a cup of coffee, at 10:00 PM I am on the plane.

But we have to wait 30 minutes in the runway because of traffic. Also, the captain mentions that this is the plane's last flight because it's too old and is being sold for scrap. So we are flying in scrap. Also, half the screens don't work, it has a whooping 6 movies you can watch, and ... they have specific starting times. Yes, you say "hey, I feel like atching Taken 2!" and you are presented with a nice sign giving you the option of "want to start watching it even though it started 45 minutes ago, or would you rather wtch it in 63 minutes?".

This was my first trip in American Airlines, is it always like this?

We arrive in Dallas, go through what it feels like twelve security checks, customs checks, dental checks, and we get to the actual USofA. Then Lucio says "OMFG we don't have the same plane to SF!", but it's just that he's looking at the wrong boarding pass.

So, to get to our plane, we get on the monorail, and go to the exact opposite end of the airport, and we get in the plane with 5 minutes to spare. Since I missed dinner in the previous flight being asleep, and breakfast was absolutely pathetic, and the new flight (a 3:50 hours one) includes no meals, I get an apple fritter from Dunkin Donuts.

Oh, apple fritter. I don't know if you really are this delicious, or I am just so hungry, but I loved you. You were so sweet and smooth, so sugary and apple-y, your texture so nice and your size so huge. I did love you, apple fritter. Even if I suspect you gave me food poisoning, it was all worth it. I'll always remember you.

So, we get on a 757 which is completely filthy. I suspect the reason it doesn't fall apart is the willpower of the bazillion dust mites that make a living in the ratty seats. It has 14" CRT screens every few rows, and the view out the window is amazing, so I decide to look out instead.

We get to the airport and we took the monorail, and got to pick our rental car. Given the choice, of course I picked a Blue Nissan Versa! Good Car!


I know noone remembers, but Heroes 1st season was kinda cool.

We have to get to our Segway tour in 2.5 hours. So we skip the hotel, put the suitcases in the trunk, and head to Fisherman's Wharf. We park, have a meal, walk there, are early, get a cup of coffee, get on the segways, and had a ton of fun.


That's Alcatraz in the back, that's two nerds having un in the front.

After we were done, we saw the sea lions at Pier 39, got a cup of coffee and a cheese sandwich, and got back on the car, with the idea of going back. Of course we didn't actually have GPS, or a phone that worked in the US, but we had cached maps! And a vague idea of where the hotel was! So we eventually got there, got into the room, got into the internet, called the family, and I passed out of exhaustion at rough;y midnight Argentine time, two days after I got on the bus in Mar del Plata.

And then I woke up, and wrote this.

Syndicated 2013-01-13 12:35:33 from Lateral Opinion

Adding Support for a Markup to Nikola

One of the goals for Nikola, my static site/blog generator is that it should be easy to extend. For example, today I added support for two markups: textile and CreoleWiki.

Since Nikola already supported HTML, reStructuredText and Markdown, adding a couple more is not very difficult. Here's how:

  1. Create a .plugin file like this one:
Name = textile
Module = compile_textile

Author = Roberto Alsina
Version = 0.1
Website = http://nikola.ralsina.com.ar
Description = Compile Textile into HTML

Then you need to create a python module called (in this case) compile_textile.py

That file is boilerplate plus two methods, compile_html and create_post

The compile_html method takes two arguments, one file from which it reads the markup, and one to write HTML. Example:

def compile_html(self, source, dest):
    if textile is None:
        raise Exception('To build this site, you need to install the "textile" package.')
    with codecs.open(dest, "w+", "utf8") as out_file:
        with codecs.open(source, "r", "utf8") as in_file:
            data = in_file.read()
        output = textile(data, head_offset=1)

Make sure to use utf8 everyhere.

The create_post function is used to create a new, empty, post with some metadata in it. Example:

def create_post(self, path, onefile=False, title="", slug="", date="", tags=""):
    with codecs.open(path, "wb+", "utf8") as fd:
        if onefile:
            fd.write('<notextile>  <!--\n')
            fd.write('.. title: %s\n' % title)
            fd.write('.. slug: %s\n' % slug)
            fd.write('.. date: %s\n' % date)
            fd.write('.. tags: %s\n' % tags)
            fd.write('.. link: \n')
            fd.write('.. description: \n')
        fd.write("\nWrite your post here.")

The metadata has to be in the form ".. fieldname: fieldvalue" and usually needs to be wrapped in a comment so that it's not shown in the output.

The onefile parameter means you have to write that metadata in the post. If it's False, you don't.

In some rare cases (Creole, I am looking at you) comments are not supported and you should raise an exception if onefile is True.

And that's it, markup support is fairly easy to add as long as there is a python implementation of a function to convert markup into html.

Syndicated 2013-01-10 17:24:21 from Lateral Opinion

Mama Don't Let Your Baby Grow Up To Be a Cowboy^W Lisper

Forget about it, cowboys are fine. Let them grow up to be cowboys, I don't care. But Lispers... nah. Ok, no, there isn't anything wrong about Lisp, or about using Lisp, or about people that use Lisp.

There is, however, something wrong about being a Lisper, the kind of person that takes advantage of any moment to look down on any code and say "oh, this in Lisp would be cleaner/easier/shorter/faster/trivial/whatever".

And I must confess I have become that person, but with Python instead of Lisp. So I will be doing some non-python coding projects this year. Because closeness means bad perspective, and because I don't want to be that person.

So, C++ here I come (back). I see you've changed. So have I. Let's give us a chance.

Syndicated 2013-01-08 08:41:28 from Lateral Opinion

The Golden Ring

When I was in Paris, it happened to me ten times or more. Walking on a public place, a man or a woman would pop out of nowhere, golden ring in hand, and say "hey, mister, is this yours?"

It's a well known scam. You get to keep the ring, and the ring bearer will ask you for some compensation. It will turn out the ring is worthless, so you will be out a couple of euros or so.

It's interesting in some ways, though.

  • It relies on the victim being dishonest, since the ring is not theirs.
  • The amount of money gained by the scammer is at the victim's discretion.
  • If you don't give the scammer anything, he will, at most, yell at you for being a cheap bastard, and it's done in very public places, so the danger of violence is negligible.
  • Since the victim is also doing something morally reprehensive, and lying, the risk of the scammer being charged with anything is negligible.

It's almost like some sort of weird sale:

"Here's something of no value that looks valuable! Is it yours? (I know it isn't)" "I will bet on it being valuable and pretend it's mine!" "So, how much is appeasing your remorse about scamming me out of a probably worthless ring worth?" "I'd say 3 euros, my good man!" "Deal!"

How can it be worth their while to do this? I would guess their success rate at perhaps 5% and they probably don't make more than 5 euros on a successful transaction

All in all, it seems fairly harmless, just annoying, and french people have actually chased me down the street to return me something I forgot in a bar. Then again, I also was peed on a foot by a badly burn-disfigured guy in a wheelchair, on Champs Elysees, so YMMV.

Syndicated 2013-01-03 12:08:58 from Lateral Opinion


So, this is 2013. Could have fooled me if you claimed it was 2012. I did a resolutions post a year ago. How did it go?

  • I aimed to write a post a day. That was 366 posts, and I failed miserably. I did post 215 times, though, which is a heck of a lot.
  • I aimed at improving at my work. I think I did do better for a while, and dipped a little near year's end because of tiredness. I will give myself a pass there.
  • My health got better. I did lose some weight (although I recovered some of it) and my blood pressure is looking good. My energy levels have improved.
  • My marriage is doing much better. Probably happiest since 2008.
  • I did not get my teeth fixed because of insurance issues. That should be ok after march.

As bonuses:

  • Took my mom to Paris.
  • Made some moves to achieve financial security in the far future.
  • I gave the closing conference at PyconAr
  • I revived my free software projects

So, not horrible!

As for 2013:

  • Again, will try to get my mouth fixed.
  • Will try to lose much more weight.
  • I will aim for 200 posts.
  • I will try to finally write a whole book.
  • I will have eye surgery to get rid of the glasses.

We'll see how that goes.

Syndicated 2013-01-01 20:55:09 from Lateral Opinion

Client-rendered, one-URL, dynamic, static site.

My vacations end tomorrow. So, the time to spend hacking fun, personal, free stuff is going to be limited because of the time spent coding fun, free stuff for money. So, I decided to finish with a bit of whimsy.

I implemented a completely client-rendered, one-URL, dynamic blog. Which is actually totally static.

In fact, that blog is this blog, just with a twist. If you go to this URL you will see what's basically this very site, with comments and everything as usual. But if you click on "Previous Post" ... well, it stays in the same page, even though it displays a different post :-)

The magic is the new, experimental, dynamic task_mustache plugin for my static site generator, Nikola. which does the following:

  1. Renders post data as JSON files instead of HTML
  2. Creates a HTML file that is really a mustache.js template
  3. Creates a HTML file with some bits of Javascript that loads the template and the newest post's data.
  4. If you access that mustache.html with a fragment, it uses that to fetch JSON data and rewrite itself.

And that's it. It actually loads fast, and regenerates very fast, since it does much less than the real site. There are a bunch of things that will dump you out of the "dynamic" site, like tag links, and whatever, but it works surprisingly well (and if you want to theme it, it's just one template).

This is the first of a new kind of thing for Nikola, the "extra plugins". Basically, stuff that is too weird, specific or useless for the general distro, will go there, and to use those plugins, you have to create a plugins/ folder in your site and add it there manually.


Syndicated 2013-01-01 19:03:43 from Lateral Opinion

Nikola 5.1 released.

Nikola , my static blog/site generator. Details, changelog, etc, at Nikola's site

Syndicated 2012-12-31 20:48:33 from Lateral Opinion

Creating a Theme for Nikola From Scratch (almost)

There is some documentation about creating themes for Nikola, but maybe a tutorial is also a useful way to explain it. So, here it is. I'll explain how to create a theme (almost) from scratch. Alternatively, you can take an existing theme and modify only parts of it via inheritance, but that's for another document.

I will try to create a theme that looks like Vinicius Massuchetto's Monospace Theme.


Syndicated 2012-12-28 21:12:38 from Lateral Opinion

667 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!