Skip to main content

Posts about Writing

My Git tutorial for people who don't know Git

As part of a book project aimed at almost-beginning programmers I have written what may as well pass as the first part of a Git tutorial. It's totally standalone, so it may be interesting outside the context of the book.

It's aimed at people who, of course, don't know Git and could use it as a local version control system. In the next chapter (being written) I cover things like remotes and push/pull.

So, if you want to read it: Git tutorial for people who don't know git (part I)

PS: If the diagrams are all black and white, reload the page. Yes, it's a JS issue. Yes, I know how to fix it.

I have written half a book

LIke mentioned before I am trying to write a book and ... well, I may be actually making progress? At least the generated PDF is about 170 pages long, which means I have written a bunch in this past month.

I have finished the second of four planned parts, which means I have done about half of it. Since I expect the next two parts to be shorter, it's actually more than that.

The target audience are people who have finished the python tutorial but are not exactly programmers yet. They have the syntax more or less in their heads, but how do you turn that into an actual piece of code?

  • Part 1 is about "prototyping", the process of dumping an idea into rough code.

  • Part 2 is about polishing that rough code into ... not so rough code. Includes a gentle introduction to testing, for example.

  • Part 3 (to be written) is about things that are not code:

    • Git / Gitlab

    • Issues

    • Packaging

    • Setting up a website

    • CI

    • Lots more

  • Part 4 is still to be thought but basically it will cover implementing a large feature from the ground up.

I much appreciate comments about it.

PD: Si, va a haber una traducciń al castellano. O mas bien al argentino. Una vez que lo termine.


While walking along the river before dawn I laid down on a bench and looked up, and saw the tree, clear and green against the orange clouds in the night sky, and thought, hey, that looks cool, and tried to take a picture.

The screen in my camera stayed obstinately black. I changed settings, moved ISOs, touched on different places trying to convince it to focus and set aperture for the darkest or the lightest areas of what I knew to be there.

And it remained black. And suddenly, I had a dissenting opinion, that there was not a clear green tree there, and that the sky was not full of orange clouds, but that it was all black, starless and empty, empty of tree, of cloud.

I placed my hand above the camera, hoping to catch a glimmer of it, and still, the display was a square of darkness separating my fingers from my arm, as empty as before, mocking me featureless.

Why was it so black, if I could see clearly. If there were lampposts giving light, and I could see clearly, and there was a tree. I knew the camera worked. What was I doing, by the river, at 4AM, on a tuesday, laying on a bench, looking up, with a camera?

You expect your senses to work. You expect to perceive what is there, and not perceive what is not. You expect to see reality, to not see irreality, to listen to things, to not listen to unthings, to touch truth, to smell shit.

What would happen if you had two sets of senses, two visions, and they disagreed, and you were not sure which one to trust, which one is right, which one is true? What would happen if the camera was right and my eyes were wrong, and I was actually not seeing, but imagining, and the truth was empty, and the tree was not there, and the sky was black.

Then I enabled flash, and the ugly picture convinced me to, someday, get a better camera, and never forget to take my gastritis medicine when going for trips on isolated locations.

Smoking 40 cigarettes a day decreases risk of lightning strikes, say statistics!

This title came to mind when I saw in the news references to an article in The Lancet about how in 2030 7 out of 10 deaths would be due to cardiovascular, diabetes, cancer, and chronic obstructive respiratory diseases.

The lesson most newspapers get out of this is "whoa, we are a bunch of lazy, salt and fat eating morons and we are all gonna die".

Sure, we are all gonna die, and yes, more people will die of those chronic illnesses in 2030. But that's mostly because we are not going to die of many other things that used to kill us earlier.

So, eat more veggies, stop smoking and don't worry too much.

Oh, and about cigarettes and lightning? I must confess I don't have the numbers to prove it, but I would be very surprised if that was not the case. After all, smoking 40 cigarettes a day should reduce your life expectation, and the less you live, the less likely are you to be hit by lightning. It's even a direct causal connection!

We live in the future.


Neal Stephenson wrote:

There is something new: A globe about the size of a grapefruit, a perfectly detailed rendition of Planet Earth, hanging in space at arm's length in front of his eyes. Hiro has heard about this but never seen it. It is a piece of CIC software called, simply, Earth. It is the user interface that CIC uses to keep track of every bit of spatial information that it owns - all the maps, weather data, architectural plans, and satellite surveillance stuff.

Hiro has been thinking that in a few years, if he does really well in the intel biz, maybe he will make enough money to subscribe to Earth and get this thing in his office. Now it is suddenly here, free of charge...

And of course, I have just that very thing installed in my desktop. Not all the mentioned data is hooked into it, but hey, it is free of charge.

Heinlein wrote about private citizens and companies going into space. He thought it was not any government's job. And that is going to happen in my lifetime. I know a guy who knows a guy who knows a guy who went to space paying for it with his own money.

Of course there are no flying cars or rocket backpacks (those were good ideas... not!)

What's the difference between Gibson's Idoru and Gorillaz, except that it's cheaper to pay musicians than it is to build Artificial Intelligences? Can you tell me what's the point in building an AI, anyway? Aren't mechanical turks cheaper and better?

Asimov wrote about a foundation of scholars writing an encyclopedia to be constantly updated, containing the whole of humanity's knowledge (we got wikipedia instead. Good enough!)

Our phones are much nicer than Star Trek's communicators (for example, the loudspeaker is optional)

It's as if most of the ideas of scifi got filtered through a purifier and what made sense came out on the other side. I like living in the future. I want to see the next one.

Yes, I know I'm wrong, but listen to me...

I have a strong tendency to be argumentative. That's because I really enjoy a good argument, if you'll pardon the obviousness.

The best thing about a good argument is that you get the most amazing insights from the wrong side of it. For example, Lamarckian vs. Darwinian evolution: Lamarck was wrong. But Lamarckism is a heck of an idea, and once you get lamarckism, you can pass it on! (ha!).

Or, the chicken and the egg? I actually got into an argument (and I did not start it myself) about this a couple of weeks ago.

If you start with something that's wrong, you can backtrack and see why it's wrong. What was the implicit mistaken assumption, the incoming garbage that created the outgoing crap. And then you can tweak it. And see what new garbage comes out. Wrong stuff, but new stuff.

And that's one of the great things about being a nerd: nerds are the awesome at this. Oh, you may think people in politics would be better? Nah, they never change their minds. Lawyers? Well, they argue for money!

But nerds? We do it for fun. And most of us don't give a damn about looking weird to others because we already know we look weird to others.

Spending 4 hours locked in a car with average humans is mostly a chore. Someone will play music, maybe people will talk intermittently about stuff that happened in the last few days, whatever.

But lock 4 nerds in a car for 4 hours and you're going to listen to stuff. This happened to me twice in the last few weeks. And in between, we had a dinner with a very high nerd factor (with alcohol assist)... great fun.

IMG14266.JPG Warning, nerds and alcohol mix a bit too well.

Now, I know many experience this when they are with people that have a certain thing in common. I've seen something similar happen betwen, for example, communists and former communists. They would talk for hours, and it was lots of fun (even for me ;-) but what they talked about was their common thing: communism.

IMG14268.JPG Yes, the tiramisu has penguins in it.

Nerds apparently don't have such inclination. Nerds will argue about anything. Nerds will argue about everything. And that makes me think... why are nerds seen as shy and introverted? Hell, why are nerds shy and introverted? How can I reconcile what I see when I'm among fellow nerds and how others see us?

IMG14262.JPG Yes, penguin cookies

And it's not easy. I am by all standard measures painfully shy. I had great difficulty making friends when I was a kid. I didn't like the things other kids liked. I didn't know many things they knew all along. I continuously was the butt of jokes for being naïve on things I had never heard about. I was always afraid to speak when I was in a group because I thought I would make a fool of myself.

Shy doesn't mean boring. Shy doesn't mean someone who doesn't have anything interesting to say. Shy means someone that has problems starting.

On the other hand, I have spoken in front of hundreds and I've been told I look relaxed (I am not, I am faking, guys). I write under my real name and I never felt something was "too weird" so I shouldn't write it (coming soon: an economic explanation of why men like to see women kissing), so I am not really afraid of people thinking I'm weird. What the hell, I know I'm weird. Ask me if you see me: Am I weird? Yes!

But I still have trouble when I am in a party with people I don't know (I am lucky my wife is like social WD-40). I still have trouble making small talk. I don't know what happened in the TV show everyone watches. I appear shy and introverted. Until you know me.

The lottery as a rational investment.

There is a prejudice that the poor play lotteries because they are lazy, can't save and are generally stupid and are hurting themselves by chasing the fantasy of winning instead of saving pennies. You know what? It's bullshit.

When I was in high school (about 13 years old), I once had a plan to make money: I would play the lottery. Here's the mechanism I had in mind.

I would play $1 in the quiniela. Quiniela pays $700 for each $1 you bet, and you have to choose a number between 000 and 999. My idea was: I can bet the $1 my parent give me every day, and there's a chance I make $700. If I had $700 I could buy anything a 13-year old kid may want. With $1? Not so much.

Of course you are right now thinking: What a moron! He has a 0.001 chance of winning and it pays 700 to 1, so it's a losing bet! Bzzzzzt!

Let's start with some simple simulation code:

import random

n = 476

for tests in range(10000):
    for w in range(1000):
        q = random.randint(0,999)
        if n == q:


Short explanation: run 10000 simulations of this process:

  • We play each day for 1000 days.

  • If we win, we stop.

  • If we don't win in 1000 days we stop.

  • We record the number where we stop.

So, I ran it. Here's a graph of the results


So, how many never won anything? In my data set: 3699 players out of 10000 never won anything.

How many actually lost money? 5030 players.

And how many won money? 4967 players won money.

2910 players won in less than 350 plays.

3 players got exactly even money, winning in their 700th play. For them, this was exactly the same as saving their money.

So, is it a good idea to play a lottery like this? It's a coin toss. Half the time, you end with no money. Half the time, you end with more money than if you had saved.

If you are betting disposable income (a sufficiently low amount that "it doesn't hurt"), it works out. You have a fair chance (50%) of a reward at least as good as saving the money, and a decent chance (25%) of a reward twice as good.

And you have a fair chance (50%) of losing money. But you would lose it very, very slowly and painlessly. ¿How well do you think stocks compare to that? ¿And what are the barriers to entry on both games?

In short: playing the lottery is not irrational, really, it's just a savings plan. It sure was a better idea than buying candy!

The Joy of Materialism

Recently I was delighted to read in Boing Boing posts by a modern Stoic. The delight was because it put into words something I had been grappling with for years and never really grasped: people have replaced philosophy with religion.

It used to be that someone would call himself a stoic, or a cynic, or a hedonist, or whatever, and others would understand that he was telling them the principles that rule his life.

A life philosophy! You could choose, from the buffet of the last 3000 years of thought, what you thought made most sense, and try to use it as a beacon to guide you through a (hopefully) happy life.

Nowadays, society seems to have rejected that idea, and the closest thing most people have is religion, following what his sect says, or atheism, defined by rejection of religion.

The main difference (as I see it) between a life philosophy and a religion is that a religion usually implies the others are wrong. If you are not of my sect, you will not be in heaven with me.

If you don't share my philosophy... well, I expect you will take a different path through your life than I would have taken. But if it works for you and doesn't hurt others, why should I give a damn?

So here's my life philosophy as I see it today. It's not how I saw it yesterday, and surely is not the same it will be tomorrow.

From now on, when I say I "believe" something, it's shorthand for "my personal life philosophy implies that". It should be obvious why such a shorthand is needed.

I am a materialist. No, that doesn't mean what you think it does, at least not in this context. What I mean is that I am not a dualist, or a spirituallist, I am not an idealist or a vitalist, and not a phenomenalist.

What it means is that I believe that reality is material. I don't accept that immaterial things have any sort of "reality". Or at least that their reality is of a totally uninteresting kind.

This means that I don't believe in souls. I believe the Turing test is a reasonable test for consciousness. I believe if there was an entity that acted like a human, we ought to treat it like a human. I believe I am not intrinsically different from a robot that could do what I do.

I believe the purpose of life is to have a good time. I believe everyone is as entitled to a good time as I am. I believe part of having a good time is being surrounded by happy people. I believe people that hurt others are a buzzkill and shouldn't be allowed to do it.

I believe in purpose, and I believe I create my own purposes and that makes them better than if they were given to me. I believe in being kind to others because they are all I have.

I believe in learning, because we are surrounded by wonders. I believe the Egyptians piled up lots of very heavy rocks. I believe Saturn is pretty. I believe giving the merit of those things to aliens or gods is an insult to the Egyptians and adds nothing to Saturn.

I believe in making things and fighting against local entropy. I believe that a certain end makes things better and more precious. I believe in love, because I know I feel it and it's precious.

So there.

Why you shouldn't believe anything you read. Including this.

A few weeks ago I was chatting with my father in law and (since I work with computers and must therefore know everything computer related) he asked me if I had heard of the 9 year old kid that worked for Microsoft as an engineer.

I said that probably, hiring 9 year olds to work as engineers was illegal, and that in most places to become an "engineer" you need to go to college, but any way it stayed in my head, like a pea in a maraca but anyway, I decided to check it out a bit.

First: no, there is no 9 year old working for Microsoft, as far as I know.

And then, a curious pattern appeared: there is not one story about that, there are several. And about different kids. And mostly in spanish-speaking media.

Let's check Mahmud Wael first.

Here's what InfoBAE says about him:

Mahmud Wael, un egipcio de 11 años y aspecto frágil, es el nuevo técnico de Microsoft gracias a su capacidad para resolver complejos cálculos en cuestión de segundos y moverse sin problemas por las redes informáticas


Mahmud Wael, a fragile looking 11 year old egyptian, is the latest Microsoft technician thanks to his ability to solve complex calculations in seconds and to move effortlessly through information networks.

If one actually bothers reading the story there's more: apparently Mahmud joined the American University in Cairo at age 9, and is now attending Cairo University for a degree in some computer-related area.

Now, I don't want to pick on InfoBAE because the same thing is reported in many other places (the previous links are just the first few that google gave me).

In fact, a bunch of those stories even say "With 11 years, he already works at Microsoft", which is somehow not in the InfoBAE story which is taken from the EFE agency.

Now... does he work at Microsoft? I bet he doesn't (or EFE would have mentioned it). It's just that when someone writes "Microsoft Technician" or "Microsoft Engineer" in english, well, that makes no sense in spanish, so the spanish media and readers are lead astray.

A Microsoft Certified Engineer is someone who has taken some Microsoft training courses and exams.

On the other hand, in most of the spanish speaking world, you can't call yourself an engineer unless you get an engineering degree from a university. In fact in Argentina calling yourself an engineer if you don't have one is illegal.

So, "Microsoft Engineer" is taken as "an engineer that works at Microsoft", because the alternative simply makes no sense.

What is the real story about Mahmud Wael? Well, let's check some egyptian sources, which is what all those newspapers should have done in the first place.

Here's Egypt Today's take on it from when he was 9.

Did he attend the American University?

Well, he had a scholarship from them to attend the Greenland International Language School, and attended one english course.

What about the "Microsoft Engineer" thing? He was planning to take the MCSD exams. Did he succeed? Well, Reuters says he got a MCTS.

An MCTS is not an MCSD, or an MCSE. In fact, just by saying someone has an MCTS (very impressive for an 11 year old!) you have no idea of what he knows, because a MCTS is about a specific product, and there are MCTSs for almost all of MS products.

So, in short: Mahmud is a very impressive and intelligent kid, but he is not an engineer, have a college degree or work at Microsoft.

And now the second case, Marko Calasan from Macedonia, which is the one actually mentioned to me.

And it's exactly the same story, except that he got a much better cert from MS than Mahmud, and he got it earlier.

Again the "works at Microsoft" thing seems to be exclusive to the spanish speaking media, and probably for the same reason.

Now, let's think about what this says of journalism. These stories were not hard to check. All you need is passable english skills and google. And if your english sucks, google can help you with that too.

But dozens of newspapers and sites just run with it because the "Microsoft hires (small age) kid!" is just too nice and people would accept it because hey, it's in the newspapers.

And you know what? I suspect that it's the same thing with a large part of what you read in the papers. If checking a tiny piece just because I have some peripheral knowledge about it says there are dozens of articles that are just wrong, what happens in all the areas where I am clueless?

Because we are all clueless in almost everything, and journalists are probably clueless about 90% of what they write about. It's not even a conspiracy, it's just ignorance amplified by their job description.