M.CG

Matthew Caruana Galizia

In a nutshell: Erasmus Mundus in London, Amsterdam and Aarhus, News21 fellow at UC Berkeley.
Now at La Nación, previously at FT Labs.

Sync your hosts file to the Android emulator with aemu

The Android emulator has become a lot more usable since the use of HAXM, but there are still a few annoyances, like the fact that the host OS’s ‘hosts’ file isn’t used during name resolution.

Editing the hosts file on the emulator itself is very difficult, time-consuming and error-prone. I really don’t want to have to do that every time I need to use the emulator to test a local host.

So I’ve written a bunch of tools for the emulator called aemu and one of the packaged tools is called aemu-hosts. It allows you to launch a virtual device and sync your hosts file to it in one command.

Also included is aemu-sms, which I’m using as a hacky way to ‘paste’ things into the running virtual device, as there’s no normal copy/paste functionality.

Resource groups in REST

Quoted from Programmers.

A URL that doesn’t end in a slash names a resource, while one that does is a resource group.

A GET of a URL with a slash on the end is supposed to list the resources available.

GET http://example.com/dogs/ /* List all the dogs resources */

A PUT on a URL with a slash is supposed to replace all the resources.

PUT http://example.com/dogs/ /* Replace all the dogs resources */

A DELETE on a URL with a slash is supposed to delete all the resources.

DELETE http://example.com/dogs/ /* Deletes all the dogs resources */

A POST on a URL with a slash is supposed to create a new resource that can then be subsequently accessed.

POST http://example.com/dogs/ /* Creates a new dogs resource (notice singular) */

To be conformant the new resource should be in this directory and the server should respond with 201 Created and a Location: /dogs/1 header field (or just 202 Accepted if the resource can’t be created before the response and you want to show a progress page).

Get the Android emulator running mega fast

This works on Mac, Windows and Linux.

Run android in the terminal to open the SDK application. Make sure Intel x86 Emulator Accelerator (HAXM) underneath Extras is installed. If not, install it. Then go to Tools → Manage AVDS….

Make sure the CPU/ABI field of your virtual device is set to Intel Atom (x86). You can even tick Use Host GPU in the settings for even more acceleration. Select it from the list and click Start….

If you see HAX is not working in the log output then you need to install the Intel Hardware Acceleration Execution Manager.

Once you’ve done that, try starting the virtual device again. You should now see HAX is working and emulator runs in fast virt mode in the log output.

A bunch of things Meteor does right at first glance

Here’s what I think after reading the docs, with most bits liberally paraphrased from there.

Not just the same language, but the same API on both client and server

Remember the days when you thought you were so awesome because you were using JavaScript on both the client and the server? Hah!

Meteor wraps things up nicely for you so you get the same API and don’t waste time, for example, choosing separate routers for the client and the server. Meteor Router provides the same API everywhere.

Granted, we’re not all the way there yet. Templating doesn’t yet work on the server side, for example. But at least the goal is there:

A future version of Meteor will also send HTML to web browsers on inital page load. The Meteor templating system was designed specifically to support this use case.

Automatic resource bundling

Meteor gathers all JavaScript files in your tree with the exception of the server and public subdirectories for the client. It minifies this bundle and serves it to each new client.

CSS files are gathered together as well: the client will get a bundle with all the CSS in your tree (again, excluding the server and public subdirectories).

Templates are converted into JavaScript functions, available under the Template namespace in your code.

Eventual consistency

Every Meteor client includes an in-memory database cache. The server publishes sets of JSON documents, and the client subscribes to those sets. As documents in a set change, the server patches each client’s cache.

When a client issues a write to the server, it also updates its local cache immediately, without waiting for the server’s response. This means the screen will redraw right away. If the server accepts the update then the client got a head start on the change and didn’t have to wait for the round trip to update its own screen. If the server rejects the change, Meteor patches up the client’s cache with the server’s result.

Yes, patches. It sends a fragment of the dataset containing the correct data rather than the whole thing.

Reactive programming

When there’s a change to data used by a template rendering function, it’s re-run. DOM nodes are then updated in-place, no matter where they were inserted on the page. It’s completely automatic.

Meteor normally batches up any needed updates and executes them only when your code isn’t running. That way, you can be sure that the DOM won’t change out from underneath you.

Fun vs Effective

I am beginning to recognize this as a trade-off. I’ve traded working on things that are fun, for things that (I hope) are effective towards a specific goal. Sometimes effectiveness and fun align, often they do not. Doing good work is hard, and it pushes you out of your comfort zone, and sometimes that experience sucks.

Fun Vs Effective, Tony Chu

Cuba

I just got back from the anti-holiday.

Cuba is a total and utter disaster. It’s people lead miserable, craven lives, begging, stealing and working multiple jobs every day just to earn enough to subsist. They clearly prefer the dead guy, Che, over Fidel, let alone his brother Raul.

Yet there is no serious opposition. That’s because when things get really bad, all the state has to do is stop the music, play the “great satan’s” historical record and a population with minds dulled by endless pro-Fidel propaganda knows where to direct its hate.

I drove for hours every day listening to state radio. There was nothing else except salsa and son CDs and I was sick of listening to anything with a trumpet in it after two days in the country. So you know what one of the most frustrating things about the constant barrage of state propaganda on the radio and everywhere else was? Not that it was constant and that there was nothing else to listen to, but that it contained not one single factual error.

So this is the problem. The fact that “yes, but look how fucked up your own country is” is not a defence cuts both ways.

You say that there are 500,000 homeless people in the US, I say that a few years ago the Cuban government fired 500,000 state employees in a country of 11 million. You say the Cuban government jails journalists, I say the US is responsible for torture and extrajudicial killings all over the whole damn world.

Where does that leave us? You have democracy in your own country, Cubans don’t. Use it to improve what your government does, get your country to clean up its act, then we can move on from there.

We’ve ruined the Dutch civil service’s holiday plans

Offshore leaks

Some collected press about my involvement in the offshore leaks project.

From DW español:

La mayor parte del trabajo técnico fue asumido por los informáticos Sebastian Mondial, de Alemania; Duncan Campbell y Matthew Fowler, de Gran Bretaña y Rigoberto Carvajal y Matthew Caruana, de Costa Rica, según informó hoy el diario alemán Süddeutscher Zeitung, uno de los medios alemanes que recibieron una copia del disco rígido.

From the South Africa Mail & Guardian:

Computer programmers in Germany, the UK and Costa Rica designed sophisticated data mining and cleaning software for ICIJ to support data research. Before it was used, though, manual analysis had established much country-by-country identification of clients and thus provided an initial look at the scope and range of clients. This painstaking work was done in New Zealand and it proved crucial in early decisions on what countries ICIJ needed reporters to work in.

From Süddeutsche Zeitung:

Den größten Teil der technischen Arbeit übernahmen die Datenspezialisten Sebastian Mondial aus Deutschland, Duncan Campbell und Matthew Fowler aus Großbritannien sowie Rigoberto Carvajal aus Costa Rica und Matthew Caruana Galizia aus Malta. Das ICIJ entschloss sich nach dieser Basisarbeit, die Recherche auf viele Medienorganisationen in aller Welt zu verteilen - weil die schiere Menge der Daten sonst nicht zu bewältigen gewesen wäre.

From Romania’s Revista Presei:

Programatorii Sebastian Mondial (Germania), Matthew Fowler (Marea Britanie), Rigoberto Carvajal și Matthew Caruana (Costa Rica) au participat la scrierea de coduri și au ajutat la analizarea datelor.

More stories from the FT, The Guardian, DW English and 2, Spiegel Online, Terra Colombia, The Washington Post and 2, HuffPost Live, Reporters Without Borders, The New York Times and 2, UPI, Philippine Center for Investigative Journalism, Euronews and 2, CNBC, Fox News, Eurasianet, Radio Free Europe, The Irish Times and 2 and 3 and 4, South China Morning Post, BBC World Service, CNN Money, Russia Today, CBC, der Standard, Hurriyet Daily News, Le Figaro, Forbes and 2 and 3, Philippines Star, Le Monde and 2 and 3, Handelsblatt, Tages Anzeiger, Sunday Times Sri Lanka, Tribuna do Norte, Libération, The Economist, Japan Times, Ottawa Citizen, Malaysia Kini, Radio France International, The Australian, Lenta.

CommonJS JavaScript modules, Assetic and Symfony

I’ve been playing around with Symfony lately and I decided I wanted JavaScript module compilation for my project. So I built an Assetic filter for cjsDelivery and packaged it into a bundle for Symfony, unimaginatively called cjsDeliveryBundle.

If you haven’t heard of the CommonJS modules specification yet, it defines a way of writing interoperable JavaScript modules.

My email to Jim Franklin, CEO of SendGrid

Matthew Caruana Galizia <m@m.cg>
To: ceo@sendgrid.com

Your decision to fire Adria Richards was the wrong one. It’s not Adria’s fault that the “developer community” you mention in your blog post is divided. The division between misogynists and non-misogynists has always existed and the events of the past few days served to expose the former part in all its ugliness.

You are wrong to use the word community in your post. The community you mention exists only in your imagination. The thousands of developers calling for the rape of Adria Richards, those saying she brought this on herself, and those participating in the DDoS attack of your company’s servers cannot be considered to be part of the same community of developers like me by any stretch of the imagination.

You are wrong to say that Adria’s job is to unite two groups of people, even when one is threatening and misogynistic. The message you’re sending out is that you’ll only hire someone who’ll remain timid when faced with misogyny for the sake of holding this imagined community together, at the cost of their dignity.

And you are wrong to say that the DDoS attacks are “consequences that resulted” from Adria’s actions, rather than the actions of some very immature and vindictive people who have nothing better to do than attack your business. It seems that you are kowtowing to them, that all people have to do is apply enough pressure and they’ll get their way, no matter how immoral or unjust their intentions are. The terrorists have won.