Older blog entries for ralsina (starting at number 574)

BA Chili Cookoff

Last saturday I attended the 2nd Buenos Aires Chili Cookoff. Lots of people, lots of great food. I was with my kid and he can't eat anything that spicy, but hey, there were cookies :-)

http://lateral.netmanagers.com.ar/galleries/random/chili.thumbnail.jpg

How crowded was it? About three times this crowd was there.

I had little experience with Chili, becuase it's not exactly a common dish around here, so, surprised by the variety, and most were quite nice, and despite exhaustive warnings by the cooks, none was unedibly spicy (the dreaded Zombie Chili which promised to melt my mouth? Kinda sweet and bland.)

Favourite? Lafitte's revenge, which really was a sort of bean-free bourguignon. Also, the smoked veggie chili was quite awesome. And the cookies were killers!

Next year, my wife is talking about cooking for it. I have had her chili, and I trust she can do better than 80% of the contestants this year. Plus I get to beta test her recipes, so win/win for me.


Syndicated 2012-07-05 16:41:00 from Lateral Opinion

Nikola Ideas for PyCamp

This friday is the beginning of PyCamp, four days of python hacking without distraction or pause. And I want to code a lot. My main target is features for Nikola my static blog generator.

If you are attending PyCamp (or even if you are not), you are welcome to join me in implementing these in a marathon of kickass coding starting this friday and lasting all weekend.

I have a few ideas in my head, but I want more. These are the ones I have, please add more in the comments if you have any:

Code Gallery
Like image galleries but for code. Put code in a folder and it will be beautifully displayed. With the addition of a "listings" docutils directive, it will make showing code in detail and in context easy and powerful, and make Nikola more attractive to programmer-bloggers.
Gallery Polishing
Image galleries are implemented and work, but they could use a lot of polish. From making them more network-efficient, to image RSS feeds, recursive galleries, gallery metadata, image texts, and much more.
File Pipelines

Want to minimize your CSS? Tidy your HTML? pngcrush your images? apply HTML transformations? Other things I can't imagine?

File pipelines would bring the power of the unix shell to a site generator, letting you connect lego-like filters, some provided, some from the community, into a powerful machinery.

Online Editing (Alva)
While static site generators have lots of benefits, they have one significant downside: you edit the files in your own device. A online editor for Nikola lets you edit them through a web interface for blogging-from-aywhere goodness.
Nikola Hosting (Shoreham)
Why not create a service where the user feeds posts to a server and then the server publishes them? The feeding can be via a DVCS, or a file sync service, or via online editors, and the output is published automatically or at the push of a button.
Drafts
I don't do drafts. I type and that's it. But others prefer more cautious and sane approaches. So, how should drafts work? While the feature may be easy to implement, it's a good beginner programmer's task, where you have to think more about what you want to achieve and providing a good user experience than about just banging code.

So, is there something you saw in another static blog generator and Nikola lacks? Any cool ideas and want a friendly codebase to hack them on? Do you have any crazy ideas noone would touch with a ten-foot-pole but you think would be awesome to have?

Well, now's a good time to talk about it!


Syndicated 2012-07-04 22:28:00 from Lateral Opinion

Python is Not a Configuration File Format

There is a large thread in reddit about using Python as configuration file format. I want to be clear about that:

DON'T DO THAT, UNLESS YOU HAVE A VERY GOOD REASON.

If you need to ask if it's a good idea, then you don't have a good reason. If you are sure that you have a good reason, then maybe you have a good reason.

There are many reasons for it, but I will explore just two, then offer a suggestion.

Python is read-only, and configuring is not programming.

Sure, it's easy to use python as a config file. You just import the thing, and there you go, all the data is there. But now your configuration syntax is a general purpose language that can do things like pop up dialogs when you parse it.

Your config can now depend on the whole internet, the hardware, the weather, and interactive input. Powerful? Sure. Good idea? Maybe, sometimes. But your application is now not able to configure itself.

If your application wants to store any kind of setting, it won't be able to. So most interactive, desktop apps, just should not use python for this, ever.

But what about non-interactive tools? Well, using python means that other tools can't write to the config file, either, which makes the tool less powerful. The power to have tools use tools is one of the cornerstones of modern computing, and you just cut your app off that ecosystem. Depending on what language the tool uses it may not even be able to parse your config file.

And what happens when someone is told "use this config fragment to achieve X"? Well, odds are, if the recipient has done anything that takes advantage of using python as a config format, then the fragment will not work. It would be like doing copy/paste from random code in github into your own program and expecting it to work.

So, you can't write to it from the app, you can't get configuration tips from the internet, you can't use other tools to modify config files, and other tools have a hard time parsing your files.

Also, it means that to handle the general case of configuring your app, you need a programmer. That is almost certainly overkill. Very few apps need that kind of thing. If your app can only be configured by programmers, you may have failed at making a good app (exceptions exist).

And what's the advice? Well, the advice is "don't do that" and the corollary is "configure using data, not code". use INIs, or XML, or YAML, or JSON, or plain text files, or whatever. But not code.

PS: My latest project, Nikola uses python as a configuration language. I thought I had a good reason. I didn't.


Syndicated 2012-07-03 21:46:00 from Lateral Opinion

The Future of PyQt by Example

Three years ago, I started a series of long posts called "PyQt by Example". It reached five posts before I abandoned for a series of reasons that don't matter anymore. That series is coming back starting next week, rewritten, improved and extended.

It will do so in a new site, and the "old" posts will be retired to an archive page. Why? Well, the technologies used in some of them are obsolete or don't quite work nowadays. So, the new versions will be the preferred ones.

And while I am not promising anything, I have enough written to make this something quite longer, more nicely layouted, more interesting and make it cover more ground. BUT, while doing some checks on the traffic statistics for the old posts, some things popped out.

This was very popular
About 60% of my site's traffic goes to those five posts. Out of about 1200 posts over 12 years, 60% of the viewers go to the 0.4% of the pages. That is a lot.
It's a long tail
The traffic has not decreased in three years. If anything, it has increased
https://p.twimg.com/Aw0MHhoCAAAXmro.png:large

A long and tall tail.

So, all this means there is a desire for PyQt documentation that is not satisfied. I am not surprised: PyQt is great, and the recommended book is not free, so there is bound to be a lot of demand.

And, here's the not-so-rosy bit: I had unobtrusive, relevant, out-of-the-way-but-visible ads in those pages for more than two years. Of the 70000 unique visitors, not even one clicked on an ad. Don't worry, I was not expecting to get money out of them (although I would love to some day collect a $100 check instead of having google hold my money for me ad eternum).

But really? Not even one ad click? In more than two years, thousands of people? I have to wonder if I just attract cheap people ;-)


Syndicated 2012-07-02 22:17:00 from Lateral Opinion

PyCamp Starts This Week

This friday marks the beginning of the 2012 PyCamp. What's PyCamp? It's a lot of python programmers (this year, about 50) gathering in an isolated place for a long weekend, with nothing to do except code. We will have our meals catered, there are no TVs, there is hardly anything within walking distance, and it's going to be very cold.

So, it's going to be awesome. It's a rare chance for me to spend a few days hacking at my own personal projects, uninterrupted by more important things like family, work, cooking, or socializing except between nerds.

Sure, there is the occasional monocycle riding, or juggling lesson, or shooting practice, but really, three or four solid days of hacking.

I intend to work on projects related to Nikola my static site generator, so if you are interested in that and going to pycamp, I want to talk with you.

And if you are interested but not going to pycamp, there is no reason not to join in a virtual sprint. We'll have internet. There is IRC. I will have time. It's a weekend! Please share any interesting ideas you have about static site generators in the nikola-discuss group and we'll see how much can get implemented or at least started.


Syndicated 2012-07-02 20:49:00 from Lateral Opinion

A Simple Nikola Link Checker

One of the most important things when you are building a static site generator like Nikola is that your site should not be broken. So, I really should have done this earlier ;-)

This is a very simple link checker that ensures the pages Nikola generates have no broken links. I will make it part of Nikola proper once it's more polished and doit supports getting a list of targets

To try it, get it and run it from the same place where you have your conf.py, right after you run doit.

import os
import urllib
from urlparse import urlparse

import lxml.html

def analize(filename):
    try:
        # Use LXML to parse the HTML
        d = lxml.html.fromstring(open(filename).read())
        for l in d.iterlinks():
            # Get the target link
            target = l[0].attrib[l[1]]
            if target == "#":  # These are always valid
                continue
            parsed = urlparse(target)
            # We only handle relative links.
            # TODO: check if the URL points to inside the generated
            # site and check it anyway
            if parsed.scheme:
                continue
            # Ignore the fragment, since the link will still work
            # TODO: check that the fragment is valid
            if parsed.fragment:
                target = target.split('#')[0]
            # Calculate what file or folder this points to
            target_filename = os.path.abspath(
                os.path.join(os.path.dirname(filename), urllib.unquote(target)))
            # Check if it exists, or report it
            if not os.path.exists(target_filename):
                print "In %s broken link: " % filename, target
    except Exception as exc:
        # Something bad happened, report
        print "Error with:", filename, exc

# This is hackish: we use doit to get a list of all
# generated files. Minor modifications would let you check
# the non-generated files as well.

for task in os.popen('doit list --all', 'r').readlines():
    task = task.strip()
    if task.split(':')[0] in (
        'render_tags',
        'render_archive',
        'render_galleries',
        'render_indexes',
        'render_pages',
        'render_site') and '.html' in task:
            # It looks like a generated HTML file
            analize(task.split(":")[-1])


Syndicated 2012-06-29 22:01:00 from Lateral Opinion

Confessions of a Troll

And then he told me "Roberto's a known troll" and I was like "really?" he seems like a nice guy!

—Not saying who said it

So, that happened a while ago in a dinner. And I am that troll. I must confess it, so here it is. I have a long, long, long history of trolling. Perhaps I could rationalize it into just being argumentative, or just enjoying a good argument, but no, really, I derive pleasure from seeing people react to what I say.

That could maybe be in some way constructive, I could just do it to make people see things from a different angle, and in my good moments I do that. But in others I just find someone I dislike, or someone who says something that rubs me the wrong way, and I ... well, it's not pretty.

What I usually do is up the ante. I escalate. I say outrageous things. Usually just slightly more outrageous than what the other guy says, so I can still rationalize it as "he started it", or "he deserves it" but honestly, deep inside, I know it's not true. I know I am being nasty because I like it. And that sucks. It sucks that I have this mean streak in me, and I can't get rid of it. It sucks that I have fun insulting the other poor bastard.

I could even say that most of the people I troll are trolls themselves. But that's not really an excuse. If they deserved contempt for their trolling, then I am just as deserving for mine. I am sure they, also, have their reasons and those reasons sound perfectly rational to themselves.

I could say that I often troll those who spread poisonous speech. That I troll those who are spreading misinformation and evil ideas. And yes, that is true, but again, I could reply without trolling. I could reply rationally, and just point out where they are saying nonsense, where they are spreading stupidity, and avoid the flair, avoid the gratuitous insult.

I could say that I troll those who bother me personally out of their own free will. So yes, telling a Jehovah's Witness that I will be at the door as soon as I wash my hands of the blood sacrifice I make to Satan is funny, but why is it any better than just telling them I am not interested.

Oh, sure, I could say that telling someone who insulted me "opinions are like assholes, and so are you" is somewhat clever, but I could just say "you are wrong, rude, and undeserving of my attention".

I sure could say that trolling someone who is rude, insulting, obnoxious and disruptive may teach him (it's always a he, isn't he?) a lesson, but it's just not true. They just see those responses as challenges.

I could say that feeding the other troll is just harmless fun, but it's not true because I know it hurts people, and creates an obnoxious environment. I could say that trolling those who deserve to be trolled is fair. But it's not true because I am noone's judge.

So, if I have trolled you, accept this post as an apology. Not a "sorry if I offended you" apology, but a straight apology. I am sorry I trolled you. I will try to stop.

I will not stop saying and writing what I think, and I will not abstain from replying to other people's opinions, but I will do a honest try to do it in a not-trolling manner, of offering my opinion as it is, instead of as a performace to make the other one feel humiliated or hurt or undeserving.

Because, and here is my only piece of excuse: I hate bullies. I was sent to school two years too early. So that you have an idea how that can affect someone, I am of average height, but until I was 13 I was convinced I was very short. I managed to become a decent swimmer, but until I was 12 or so, I was convinced I sucked at all sports and games. I was inceasingly bullied since I first ever met my "peers" until I was able to kick the crap out of them. I became a tough kid. I could take a beating like you can't imagine, because I was too small to hit back, and the only way not to be a total loser was to keep getting up and going to be beaten again, while making sarcastic comments.

And it turned out that those sarcastic comments worked. I got my ass kicked, but the next day that kid remembered how I was getting back on my feet and joking about his mother. And that, of course, lead to further bullying. When I was about 12, I was so extreme, I scared everyone so much, they stopped. I was scary. I talked like a freaking psycho. I probably was close to being one.

And the lesson I learned was that if you make fun of people, they got hurt enough to want to avoid it later. So, I was, in fact, a bully myself. And thus, I became that which I hated. I have had better times and worst times, I have been more in control and not so much. And it has taken me a long time to figure this out. I don't like what I became. So I will stop. And I am sorry.

Just gentle ribbing and self-deprecation from now on. Promise.


Syndicated 2012-06-28 22:35:00 from Lateral Opinion

This is Not Math

My niece goes to school. She has homework. Every now and then, her mom and greatmom will not be able to help her. I am sort of the math helper of last resort in the family. So, the other day I got this question:

What is the next number on this series:

2, 12, 16, 17, 18, 19

I just could not come up with an answer at the time. I have been told the answer is 200. Why? Because it's a list of numbers starting with "d".

Oh, you may say two doesn't start with "d" but hey, this was in spanish, so it does. The problem is, this is just not mathematics, at all.

It's about a completely incidental feature of the representation of a number in spanish, which is a completely unmathematical thing. Makes me wonder why they are making students think about this. Anyone knows?


Syndicated 2012-06-27 15:35:00 from Lateral Opinion

Lo que pasa cuando mi hijo ve MythBusters

Sorry, spanish Only, because it's my son speaking ;-)