Javier Tordable

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

Excel Reports

July 12, 2014

Everybody who has spent some time working in a business of any size knows that Excel is ubiquitous. It's surprising that there are so few companies out there working in the spreadsheet world.

Recently I had to create a bunch of Excel reports, and I took some time to explore ideas on how to structure a library for easy report creation. I took the excellent XlsxWriter library and built a few conveniences on top of it. Check out the first iteration of XlsxReports in my Github page.

The code to create a report looks like this:


"""Example XLS report."""

__author__ = 'jt@javiertordable.com'

from XlsxReports.layout import (
from XlsxReports.style import (
from XlsxReports.table import Table
from XlsxReports.xls import new_workbook


def main():
  workbook = new_workbook('my_file.xlsx')
  sheet = workbook.add_worksheet('TableData')

  table = Table('Data', ['Name', 'Id', 'Data'])
  table.add_row(['John', '1', 'First'])
  table.add_row(['Jane', '2', 'Second'])

  table_style = TableStyle(workbook, table)
  table_layout = TableLayout(table_style, table)

  padding_style = FixedStyle(workbook, '', LIGHT_GREY)
  padding_layout = PaddingLayout(padding_style, table_layout,
                                 1, 1, 1, 1)

  overall_style = EmptyStyle(workbook)
  overall_layout = HideOutsideLayout(overall_style,

  start_position = (0, 0)
  overall_layout.draw(sheet, start_position)

if __name__ == '__main__':

and generates an Excel spreadsheet like the following:

A spreadsheet generated with Python

Please, let me know if you find it useful!

A Simulation of the Universe

May 10, 2014

A new detailed simulation of the universe:

Simulation of the universe

The Illustris project is a large cosmological simulation of galaxy formation, completed in late 2013, using a state of the art numerical code and a comprehensive physical model. Building on several years of effort by members of the collaboration, the Illustris simulation represents an unprecedented combination of high resolution, total volume, and physical fidelity.

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.