When I Saw the Cathedral From My Bazaar

Yesterday, for some reason, I was checking the TextMatemaillist archives. I’m guessing that, as everyone else that at one point bought TextMate, I was curious about any information about TextMate 2, but my memory isn’t exactly what it used to be, specially for those small things that make you do a Google Search and start clicking link after link after link.

Anyway, it seems more and more people are interested in what’s going on with TextMate 2, which was announced about 2 years ago (the earliest blog post I could find about it dates 14 June 2009, but maybe there was something else in the maillist).

I managed to dig some posts there and there from Allan Odgaard (the TextMate author) and it seems he is working on TextMate 2 behind closed walls ’cause he 1) Thought it wasn’t ready, 2) Feared the backlash he suffered from the first TextMate alpha, 3) Things were not falling into places. I gather that from messages ranging from the early 2010 to almost the end of the same year.

When I read that, I couldn’t stop thinking about my own open source project (and now dead) Mitter. Yes, I know, it’s a twitter client vs a programmer text editor, different scales and such, but the whole development thing was completely different.

Yes, I worried about backlash and people calling me stupid (I think it happened only once, about a feature I refused to add) but, in the end, it was my application and the guy could jut chose something else; Yes, I thought it wasn’t ready, but people still came, checked it and gave me suggestions that would improve the application greatly (and I said that to them) either visually or functionally; Yes, sometimes, the pieces were not falling into the right places, but if I mentioned what I felt it was wrong, people would mention something that would either make the piece fall into place or make me realize I’d need a different piece or would completely throw me out of balance and make me rethink the whole thing.

I know Allan can’t just open source TextMate 2. It’s his money-making job (or extra-money-making activity), but still he could mention the pieces that are not falling into the right places or either get some alpha version to some users (and not, this is not me asking for an alpha version — I’m pretty bad testing things) just to keep the flame alive and people not think it’s suddenly a dead project.

Portal 2

I must admit that, at first, I wasn’t thinking about getting the new Portal version. But friends mentioned getting it and there was this co-op option that should be fun. So I got it.

The game follows the previous game about… centuries after Chell escapes the first time while killing GLaDOS. I was expecting some kind of explanation about it inside the game, but there isn’t (sorry, spoilers). The explanation is in the online comic book that you can see on the Portal 2 website (sorry, no spoilers this time).

The game mechanics start the same, but Valve added some new tricks, like (no, no spoilers, you should know this from the videos they posted around) light bridges, lasers, bouncing gel, high speed gel and a special gel that let you put portals on surfaces that couldn’t keep portals before — extending the game even further.

The first levels and mostly a recap of the classic mechanics, like portals, boxes and buttons and momentum. I thought it was quite boring, but just because I played the first version. I bet those levels are there to teach newcomers how things work. While I understand that, the levels are very small, but there is a very annoying loading screen. Due this, you’ll see a loading screen taking about 15 seconds to load a level, completing the level in about one minute and then having to wait yet another 15 seconds to load the next level.

Once you get past those training levels, the challenges start. Although not the real challenges yet, as those are obviously the last levels, they provide the exact amount of deception, frustration and satisfaction when you figure out how to complete the level. And some levels seem designed with deception in mind, with some obvious solution right in front of you, hidden by some bright, new thing just a few meters in front of the solution. Also, I must congratulate Valve for the level and teaser video design: At some point, in one of the levels, I thought “Oh, I remember seeing this on a video, I’ll do that” and then I was happily surprised when things didn’t went the way of the video — and that’s why you should watch them, they will teach some stuff about the new mechanics without spoiling you with solutions that you’ll bang your head on your desk for a while while figuring it all when trying something silly.

This time, instead of having only GLaDOS and the weird phrases written in hidden walls as companions, you have Wheatley, the robot/entity responsible for your care in the beginning of the game (not going to spoil how it begins, but you’ll find in the very first minutes of game play), some weird phrases written in hidden walls, the Aperture Science notification system and… GLaDOS. There is yet another personality that will add some explanations and a nice story arc mid-game in a very absurd location of Aperture Science HQ (oh, spoilers?)

Also, the single player campaign explains the origin of the robots you’ll play in co-op mode, although just in the end.

Speaking of end of the game, I completed it in 9 hours of played time — or so says the Steam launcher. This is a bit below 5 times the time it took to complete the first game.

Speaking of which, there is a co-op mode in Portal 2, as I mentioned right from start. I played just the first level with my cousin, but I think it gave a good idea how the game play is: The first level have two somewhat connected corridors, with each robot (player) taking a different corridor. Some obstacles in corridor 1 must be solved by the player in the corridor 2, allowing both players to keep going. Each player have their own set of portals, so you can “chain portal” on the way out. Valve also added some “flags”, allowing players to point to each other where they should go, open portals or drop boxes, without the need of typing or speaking.

The last point I’d like to add is replayability. The first portal, without the co-op and with a very short play time, didn’t offer much of it: You could finish the game 2 or 3 times in a free afternoon. Obviously, with a different game style (the co-op) and a longer story mode, replayability is a reality. Specially ’cause some levels are really fun to play, without the “how the heck I find the way out of this” feeling all the time. There are, also, more achievements this time — obviously easy to add due the longer gameplay: While the first Portal have 18 achievements, the new one have 50, some about the co-op game. All that, with the updated visuals — graphically, this game is prettier than the first version — give a lot of fun replaying the game again.

The game is really worth it, even if you haven’t played the first game.

Workaround for Broken ElementTrees

(or “Your broken XML broke my Tree!”)

Recently, I decided to parse an HTML file using ElementTree. Nothing fancy, seems most of the HTML is well-formed anyway. But (there is always a but) the source file I’m trying to parse starts with , have no and, for some reason, this makes ElementTree a very confused parser. And, by confused, all the elements, instead of keeping their original tags (e.g., table) have the prefix “{http://www.w3.org/1999/xhtml}” added to them (e.g., {http://www.w3.org/1999/xhtml}table).

Now, this isn’t purely a problem with ElementTree. If I save the file and use TextMate “tidy HTML” and run through ElementTree again, everything works perfectly.

Not only the elements themselves get weird, but ElementTree can’t use any special filters in its XPath search, like indexes (div[2]), or any attribute search ([@class="class"]).

The solution I found was convert the whole XPath (without any attribute search) to a longer form, which seems to work fine (it solves my problem), adding the “{http://www.w3.org/1999/xhtml}” to every element and doing the index search manually.

def _find_xpath(root, path):
    """Finds an XPath element "path" in the element "root", converting to the
    weird information ElementTree."""
    elements = path.split('/')
    path = []
    for el in elements:
        if not el.endswith(']'):
            # collect what we have, find the element, reset root and path
            this_element = el.split('[')
            # first part, without the 
            xpath = '/'.join(path)
            root = root.findall(xpath)

            pos = int(this_element[1][0:-1]) -1
            root = root[pos]

            path = []

    if len(path) > 0:
        xpath = '/'.join(path)
        root = root.find(xpath)

    return root

I reckon is not the cleanest solution and that I should probably use recursion somehow, but it works.

Improvement suggestions are welcomed.

(Mais Uma) Pequena Saga das Coisas Mal Explicadas do Banco Brasil

No dia 29 de Março decidi que iria ver o filme “Batalha de Los Angeles” depois de ir a minha consulta semanal ao psicolólogo. Infelizmente, não tinha dinheiro suficiente para pegar o táxi, mas como há uma agência do Banco do Brasil próximo ao consultório, não era nada grave.

Cheguei na agência, me dirigi ao caixa de auto-atendimento, passei o cartão, digitei um valor que me deixaria tranquilo para o resto da semana (e talvez ainda da próxima, já que não gasto tanto assim) e foi surpreendido pela mensagem de que não havia fundos suficientes na conta. A primeira coisa que me passou pela cabeça foi “caguei nos cálculos dos gastos”. Em outras palavras, consegui usar mais do que tinha.

Tirei um extrato para ver o que havia acontecido. O extrato mostrava que no dia 18, R$ 10.000 foram movidos da minha conta corrente para uma conta de aplicação, o que é deveras estranho por si só, já que nunca autorizei tal transferência, deixando a conta com um saldo de apenas R$ 55,00. Pior: No período entre a transferência e o dia em que descobri o rombo, bateram na conta o pagamento de fundo de previdência que tenho e mais o cartão. Assim, não só o restante do dinheiro na conta foi varrido, como também passei a utilizar o limite da conta. Fiz uma transferência de valores do fundo de volta para a conta para que, pelo menos, o fundo de previdência e o cartão pudessem ser pagos.

No dia seguinte liguei para minha agência. O gerente me informou que devido à um processo que o banco perdeu pode deixar o dinheiro parado em contas, várias contas tiveram a transferência automática para o fundo de aplicação, mas que o resgate automático deveria estar abilitado e que ele iria “ter que bater em algumas pessoas” já que isto não acontenceu com a minha conta. Ele iria verificar o que aconteceu e me retornaria a ligação em 15 minutos.

2 horas depois (nada de anormal aqui, diga-se de passagem), o gerente do banco me liga informando que o resgate automático foi devidamente ativado e que os valores cobrados no período seriam retornados a minha conta. Perguntei se o plano de previdência e o cartão haviam sido cobertos pela transferência que eu fiz no dia anterior (à noite, quando percebi o problema).

Agora começa a parte engraçada da coisa.

Aproveitando que estavamos falando da questão desta transferência, perguntei como seria a próxima: Seria num período prefixado, ou quando a conta atingisse um certo limite? Resposta: Não, a transferência não seria mais feita automaticamente, somente quando eu fizesse a aplicação eu mesmo.

Aí fica a pergunta: Se a transferência ocorreu por causa de um processo, este não teria que ser permanente? Se não é permanente, porque ele aconteceu, para início de conversa?

Ainda vou ligar pro SAC para pegar mais explicações, mas estou presentindo que há algo de podre nessa história toda.