Extending JavaScript with inline unit tests

09 Nov 2013

I’ve been checking out Pyret, the new language from the same guys that made Racket. Even if it is designed to be for education, it has a syntax I love and some really cool features, like the possibility of adding in-line unit tests to your functions. This feature in particular looks like this:

fun square(n):
  n * n
  square(2) is 4
  square(4) is 16
  square(8) is 64

Neat, huh? The where clause opens up the block of unit tests for that function, which are executed at run-time.

So obviously I decided to give it a try and implement something similar for JavaScript using sweet.js. This allows me to kill two birds with one stone because I have also been meaning to catch up with the latest developments that sweet.js has made since last year (among other improvements, we can now rewrite reserved keywords in our macros!).


Add code coverage to your Node.js projects

19 Jun 2013

Note: This blog post is heavily based on Xavier Seignard's blog post. He gives a longer introduction on it, and integrates it together with Sonar. You should check it out.

Code coverage is invaluable to get an overview of how well-tested your app is, and it helps finding new bugs in your code. Unfortunately coverage reports are not ubiquitous in Node.js projects, and because of that it may seem that it is hard to set up, which is not the case at all!

I'm going to show you how to set up code coverage using Mocha, Istanbul and LCOV in two easy steps.


Virtual list in vanilla JavaScript

12 May 2013

Let's say you need to show a scrolling list with millions of rows, or even a reasonably big list with visually complex rows, each one composed by several DOM elements or CSS3 effects.

If you try to render this the naive way, for example by appending rows into a DOM container with the CSS overflow property set to scroll (or auto), you will most likely run into performance issues. This is because all the items in the list are cached, thus your memory consumption will certainly go up, and since all the DOM nodes composing the rows of the list are appended in the document, the browser is trying to properly render them all making your CPU pretty busy as you scroll. If these rows change any style say, on hover, you will trigger a reflow and the experience will be even more sluggish.


Implement cursor-swiping in half an afternoon

21 Feb 2013

If you haven't seen it yet, I suggest that you take a look at this concept video that made the rounds on the internet some months ago:

I would pay to have this in my phone. Only, money wouldn’t help since I own an iPhone, and a developer has simply no way to access an internal component like the phone keyboard.


The promise of Firefox OS

09 Feb 2013

"But how is it going to beat Android or iOS?”

That’s the reaction many people have when I tell them that I am working on Firefox OS, the new mobile operating system from Mozilla. It is a logical reaction. After all, we live in times where every major software company and its mother is releasing a mobile platform, struggling to lure developers into their new proprietary environment, APIs, libraries, etc. And indeed, many of these companies barely make it or don’t make it at all.

But Firefox OS will not be directly battling against other mobile platforms. Its main objective is to change the way the world develops mobile apps, and even in the unlikely event that Firefox OS itself disappears in the process, if web-apps become mainstream, it will have succeeded.


Moving on

29 Jan 2013

A little bit more than two years ago I was sitting on a meeting room, listening to Ruben Daniels and Rik Arends, the two founders of the company I was considering to join, Cloud9 IDE. These were two of the smartest, most inspiring people I’ve met, and they were working hard on a ground-breaking concept: a full-fledged development environment that run in the browser, and in the cloud. At the time, that sounded wildly adventurous, to say the least. But the challenges were so many, the concept so revolutionary and the people so inspiring that I joined the company two weeks after that conversation.

What followed were two exhilarating years in which we got funding, surpassed almost every technical limitation that got on our way, got a huge user base and learned (many times the hard way) about software development, startup world and companionship.


Nodejsconf in Italy

12 Nov 2012

Last weekend I was at the Node.js conference in Brescia, Italy. Like every year the organizers managed to stage a great conference with really good talks. Even if I was there only for a lightning visit (less than 24 hours between leaving Amsterdam and being back), I had tons of fun and the talks I saw were really top-notch.

As a side note, I’m continually impressed by how much hacker spirit there is in Italy. There was lots of Arduino, BeagleBone boards and the real excitement of building stuff in Node.js that nobody has built before. Check out the talks from Simone Chiaretta or Matteo Collina to see an example of what I mean, when you have some time.


My talk at DynCon 2011

04 Apr 2011

The video with my talk about Cloud9 IDE at DynCon 2011 is already out! It’s quite long, but definitely worth it if you are interested in the future of the IDE, since I had the chance to answer many questions about it during the talk. About half of the video contains demo and questions from the audience, as it was quite interactive.

Also, I want to thank Peter Svensson for creating such a wildly interesting conference and being a really great host and organizer. It is a very, very hard job that he pulled off amazingly well.

This talk was especially interesting to me because although the audience included mainly professional developers, most of them weren’t using JavaScript as their main language (as is often the case in our talks). It was fun to show them the power of JavaScript. And as always when you add people with different backgrounds to a discussion, ideas and good questions quickly started popping up. It was great. We’re also working hard at getting more languages incorporated, so hopefully we can have more of these types of discussions in the future, hang in there!


Dynamically generating MIDI in JavaScript

08 Nov 2010 Dynamically generating and playing midi using JavaScript


Writing a JavaScript interpreter for DBN using PEG.js and canvas (Part II)

20 Aug 2010 Writing an interpreter for Design By Numbers in JavaScript from the grammar generated with PEG.js in the previous article of this series.


Writing a JavaScript interpreter for DBN using PEG.js and canvas (Part I)

03 Aug 2010 In this first part of the article, I will define a grammar for DBN and generate a parser for it, so I can interpret the syntax tree it later on with JavaScript and draw it into an HTML5 Canvas.


GitHub in Catalan

28 Jul 2010

This is awesome. From now on, Catalan users of GitHub can use the website in their native language. Thanks to the Github team initiative and the brilliant approach of crowd-sourcing the translations (along with some very convenient tooling to do so), I could translate almost all the strings of the website in a record time two weeks ago.

What I found out today is that the website is already making use of it and available to everyone! Just point your browser to http://github.com/blog?locale=ca and the page will be offered to you in Catalan already. The translation is currently 87% complete, so there is still some work to be done, which I expect to finish between today and tomorrow.

Anyway, if Catalan is your native language and the lack of it in Github was stopping you from using it, now you have the chance!

GitHub en Català

Des d’ara mateix, els usuaris Catalans de Github poden utilitzar la web en el seu propi llenguatge. Gràcies a la iniciativa de l’equip GitHub i a la manera brillant d’utilitzar crowd-sourcing per a traduïr la web a multitud de llenguatges (i a unes eines de traducció molt útils), he pogut traduïr quasi totes les cadenes de la web fa dues setmanes en un temps récord.

El que no m’esperava i he descobert avui és que GitHub ja està disponible online en Català! Només cal que introduïu la següent direcció al vostre navegador: http://github.com/blog?locale=ca i la pàgina us preguntarà si voleu establir Català com a llenguatge del lloc per defecte. La traducció està 87% complerta, així que encara hi ha una mica de feina per fer, que espero finalitzar entre avui i demà.

Així doncs, si la teva llengua és el Català i el fet que GitHub estigués només en anglès t’impedia utilitzar-lo, ara ja no tens excuses!


Blog running on Jekyll now

13 Apr 2010

That’s right, I couldn’t resist switching to Jekyll. I feel so free now!

For those who don’t know, Jekyll is a static site generator. It takes a template directory, runs it through a textile or markdown parser, and outputs a complete website ready to be served with any web server, since it is simple HTML. That means no more server queries or content stored in databases. You own your content, and it is stored in plain text files. Of course, that also means that it is perfect to be maintained with a VCS like Github, where by the way, you can host your Jekyll sites for free!

Ah, simplicity…

You can see the source code for my blog and get a feeling of how it works.


ABN Amro to Wesabe script

25 Feb 2009

Wesabe is a great service. And a very big part of its greatness resides in the fact that it retrieves your bank accounts data automatically from their sources whenever you log in into the page.

That is, if you don’t have a Dutch bank account.

The reason for this is that the security of Internet banking in The Netherlands is quite strong, probably much more than the ones in the US (where most Wesabe users are from). Every bank customer owns a little device in which you have to put your bank card in, type your PIN number, type a number given to you by the bank website, and type back the code calculated by the device. Only then you can access your personal bank website. Once in the site, you will have to repeat this process for every transaction or order that you make.

I much rather prefer this increased security when it comes to Internet banking as it adds an extra layer of security that makes it much more difficult to hack illegally into people’s bank accounts, but this also means that Wesabe (obviously) won’t be able to access the data in my bank website automatically.


YQL mashup with GWT

16 Nov 2008 In this post I build a simple mashup with Google Web Toolkit that uses Yahoo Query language to retrieve pictures from flickr and render them in a small GWT component.


Solitaire Encryption Algorithm implementation in F#

13 Oct 2008 Implementation of Bruce Schneier's solitaire encryption algorithm using Microsoft's new functional programming language F-sharp.


Nth attempt

08 Oct 2008 My last blog tried to cover too many things, from my life abroad, to ramblings on software engineering and even some poor attempts to deep thinking every other post. Well, you really can't bite off more than you can chew, and that was too broad and disorganized to maintain it properly.