Javier Tordable

I write software at Google. I also enjoy Mathematics, Technology and Design.

A github-like Activity Chart

February 28, 2014

One of my favorite features from github is the activity chart that appears in the user profile. For example, this one from user jmcnamara:

Github activity chart

However, I don't really use github except for one of my older projects. In part because I prefer Mercurial over git. So I decided to write a small tool to generate these charts for my own local repositories.

There are two interesting parts. First, reading the change list data from Mercurial:

def extract_cl_counts(repository_path, cl_counts):
    """Reads the repository changelog and extracts CL counts per day."""
    repository = hg.repository(ui.ui(), repository_path)
    changelog = repository.changelog
    for cl_index in changelog:
        cl_id = changelog.lookup(cl_index)
        cl = changelog.read(cl_id)

        # The timestamp seems to be the 3rd field in the CL.
        # It's given in a tuple. The UNIX timestap is the first field.
        timestamp = cl[2][0]
        cl_date = date.fromtimestamp(timestamp)

        if cl_date in cl_counts:
            cl_counts[cl_date] = cl_counts[cl_date] + 1
            cl_counts[cl_date] = 1

And then building the chart itself, which seems surprisingly easy using SVG:

for day_index in range(first_day_to_show, last_day_to_show):
    # Boxes are stacked first by column and then by row.
    x = MARGIN + (day_index // 7) * DISTANCE_BETWEEN_BOXES
    y = MARGIN + (day_index % 7) * DISTANCE_BETWEEN_BOXES

    # Compute the real date from the day index.
    day = start_date + timedelta(days=(day_index - first_day_to_show))
    if day in cl_counts:
        color = get_box_color(cl_counts[day])
        color = get_box_color(0)

                         size=(DAY_BOX_SIZE, DAY_BOX_SIZE),

And here is how it looks like:

Github-like activity chart

You can find the entire code of the chart script in Github (of course!)

Blog Redesign and Social Buttons

February 16, 2014

Hello, internets! I just redesigned the look & feel of the blog. The new design has bigger font sizes and less distractions. It's optimized for mobile so it should look much better than before on Android and iOS phones, and especially on iPad.

Buttons for sharing content.

Apart from the new sleek design now each post has multiple social buttons, to +1 on Google Plus, Like on Facebook, tweet on Twitter and share on LinkedIn to your heart's content. Check them out below.

Masters of Doom

February 13, 2014

A few weeks ago I had the chance to read Masters of Doom by David Kushner and found it very interesting. It tells the story of John Carmack and John Romero, the founders of id Software and authors of some the most revolutionary videogames ever.

Masters of Doom book cover

The book includes the biographies of Carmack and Romero, as well as plenty of anectodes of their wild ride in the world of videogames. But the part that I found most interesting was the story of how Carmack became such a talented (and widely acclaimed) software engineer. Highly recommended.


December 23, 2013

A while back I found a beautiful website on Mathematics and I wanted to share the link: Mathigon has a series of introductory articles and many images, figures and interactive visualizations on a variety of mathematical topics.

Mathigon screenshot

The content is quite basic, but it's presented in a great way, the website is well built, and the pictures are fantastic.

Mathigon screenshot


December 01, 2013

I haven't done any kind of 3D design in many years, but I was thinking last week that it would be fun to get back to it. And while I was looking at software available for Linux, I found Blender.

Blender logo

Blender has been around for quite some time but it seems that now it's features are up to par with some of the most popular 3D packages like 3DS Max or Alias.

Blender screenshot

Apart from the 3D design tools Blender has one very cool feature, a Python API! I will post another note after I have the chance to try it out.

Git Branching

September 22, 2013

I haven't had much time to write lately, work is keeping me busy. But today I wanted to share a site I found recently and I think is really interesting. It's essentially a git tutorial, but with a twist.

Learn Git branching screenshot

As most of you know git is a version control system. Essentially, a program to track and coordinate updates to a set of files, which is one of the most basic tasks in software engineering. Learn Git Branching helps beginners learn how to use git. But instead of simply explaining the git commands it's structured as a puzle game. The levels are git tree structures, and in order to solve the puzzles it's necessary to input the proper git commands.

Learn Git branching simple example

The puzzles go from the very simple, to the fairly complex. So even if you already know git, it may be fun to play the most advanced levels.

Learn Git branching complex exercise

Kudos to Petter Cottle for the tutorial. You can check out his Github profile here.

How Memories Look Like

June 22, 2013

A team from USC engineered microscopic markers that light up synapses in a living neuron in real time.

How memories look like - Living neuron

The fluorescent markers allow scientists to see live excitatory and inhibitory synapses for the first time and, importantly, how they change as new memories are formed.