How to write unmaintainable PHP code [2009]

Originally published at in 2009. The site is no more, but I found a copy on my hard drive. I’m not sure but I do hope it’s the final version because Sean Coates (@coates) and Chris Shiflett (@shiflett) did a really nice job editing the pice. Also hope it’s still funny… With the unemployment […]

September 18th, 2015
Tags: php, Uncategorized
1 Comment »

From JSXTransformer to Babel

As announced, starting with React v0.14 (next release), the JSXTransformer.js won’t be part of the release. Also `react-tools` npm package is no more. So whatchagonnawannado is switch to Babel. Here’s how. Build-time transform Prerequisite: install Babel $ npm install –global babel Where you previously had this as part of your development/build process: $ jsx –watch […]

June 22nd, 2015
Tags: react
No Comments » is dead, long live smushing

Looks like Yahoo! stopped maintaining the image optimization service called So people have been asking questions on the mailing list. I don’t have any inside information from Yahoo about the service, or whether it will be back up again. But let me try to answer some of the questions. History: quick refresher Nicole and […]

April 6th, 2015
Tags:, Uncategorized

f8 2015

So I spoke at Facebook’s F8 in San Francisco last week. Actually my teammate Varun spoke mostly, I just interrupted a few times. Among other things we announced a new plugin – the embedded video player, so now you can embed any public FB video on your site. And, how meta!, below is a video […]

March 31st, 2015
Tags: facebook, speaking
No Comments »

Making an album sampler video on the command line

Here’s a video I made to raise awareness about Anaconda Limousine’s first album (where I play guitar and co-wrote 1 song): This is a post that explains how it was made so if anyone wants to made a similar one, they can have something to step on. Turns out videos like this are called […]

March 31st, 2015
Tags: Music, tools
No Comments »

ffmpeg: batch convert

Say, a bunch of .wav files to .mp3 $ for f in *.wav; do ffmpeg -i $f “${f%.*}.mp3″; done

March 3rd, 2015
Tags: Music
No Comments »

Downloading top X sites’ data with ZombieJS

Update: Easier way to get top X URLs:, thanks @souders Update: found and commented an offensive try{}catch(e){throw e;} in zombie.js (q.js, line 126), now the script doesn’t fatal that often Say you want to experiment or do some research with what’s out there on the web. You need data, real data from the web’s […]

June 6th, 2014
Tags: CSS, HTTP, tools
Comments Off

Jest + jQuery for testing a vanilla “app”

Jest is a new javascript testing tool announced today. I thought I’d take it out for a spin testing the UI of a simple vanilla JS app – no CommonJS modules, no fancy stuff. Just old school JavaScript. Granted, it’s probably not what the tool was optimized to do, but it totally worked. The app […]

May 15th, 2014
Tags: JavaScript, tools
1 Comment »

CSS diffs #2

Continuing from last night… First, two twitter responses pointed to even more readily-available options for comparing screenshots. One is Wraith from BBC engineers which supports Firefox/Gecko (via SlimerJS) in addition to PhantomJS. The other is the almost-ready which is based on which seems to support all the browsers! Anyway, I thought I should […]

May 9th, 2014
Tags: CSS

css diff

CSS is the worst because it blocks page rendering. The bigger it grows, the more it blocks. And bigger is what CSS becomes if left unattended, as anyone who has worked on any project for more than a few days or with more than a few people can confirm. So occasionally one must step back […]

May 9th, 2014
Tags: CSS

DIY source maps

In today’s world of always having some sort of code transformation before your JS/CSS/HTML reaches the user, e.g. minification, concatenation, es6-to-es3 transpilation, it’s nice to be able to go back to the source before the transformation. And when that happens in the comfort and the immediacy of the browser’s dev tools, even better! Enter source […]

May 8th, 2014
Tags: JavaScript

Writing ES6 today with jstransform

So there’s this recent open-source project from Facebook called jstransform. It’s also used by ReactJS. It lets you explore ES6 features and not only explore, but use them in production code. All you need to do is add the transformation to your static resource pipeline. (Of course you have one, right, for minification and so […]

April 21st, 2014
Tags: JavaScript, tools

Beacon performance

Beacons are small requests that our apps make to report some information “home”, to the server. Beacons are often used to report visitor stats, JS errors, performance metrics. Beacons often don’t return any data back to the client, but some do. Example use <div id="app">Awesome app is awesome</div> <script> // gather data somehow var data […]

February 9th, 2014
Tags: performance

Hello subpixel world

Since IE9 and Firefox(v.?) we now have subpixel rendering of fonts. This is cool and all but imagine this: you have some text you want to measure the width of the text and size another element to the same dimensions Simple. But if you use offsetWidth/offsetHeight to measure, you get a rounded integer and not […]

February 6th, 2014
Tags: browsers, CSS, JavaScript

ReActiveTable bookmarklet

Previously… React and tables. I’ve been meaning to improve a little on the table example built with React and a post by Steve was the final push. He shared his “ActiveTable” bookmarklet. So, introducing a bookmarklet to make it easier to work with random HTML tables you come across… ReActiveTable Drag this link to your […]

October 23rd, 2013
Tags: react


On my way to NYC for Edge conference and NYC Web perf meetup. Some slides and RSVP links inside.

September 22nd, 2013
Tags: JavaScript, performance, speaking
Comments Off

Server-side React with PHP – part 2

Part 1 ended with todos. The first one was to couple the server-side generated code with the client-side React, so that any updates past the initial page load will be handled by React’s client JS, which is where React shines. Let’s see how you can do just that. PHP data fetch, gluing JS for v8 […]

September 19th, 2013
Tags: JavaScript, php, react

Borrowing typography tricks from the masters

Inspect the styles in Mobile Safari’s Reader feature to learn typography

September 16th, 2013
Tags: CSS

Server-side React with PHP

Problem: Build web UIs Solution: React Problem: UI built in JS is anti-SEO (assuming search engines are still noscript) and bad for perceived performance (blank page till JS arrives) Solution: React page to render the first view Problem: Can’t host node.js apps / I have tons of PHP code Solution: Use PHP then! This post […]

September 13th, 2013
Tags: JavaScript, php, react

Installing v8js for PHP on a Mac

Motivation? Run JS code inside PHP. Just… because I struggled for a while with this installation, so leaving a trail here for anyone looking. What you need to accomplish? Goal: run JS code inside a PHP script running on a webserver. Already accomplished: Macs come with a webserver (Apache) and PHP. To get there: 1. […]

September 11th, 2013
Tags: JavaScript, mac, php

Reactive table

In the previous post I mentioned the pains, misery and suffering attached to creating and updating an HTML table in DOM land. Now let’s see how you do this simple task in React. Demo React is all about components. So let’s build one. Let’s call it Table (to avoid any confusion what the component is […]

September 10th, 2013
Tags: JavaScript, react

Remarkable React

I gave a talk about React at BrazilJS few days ago. The “slides” are here. In this post I’ll go over what I said (more or less) at the beginning of the presentation. I hope to follow up with some more code. Disclaimer: I work at Facebook. But these are my thoughts. In fact, I […]

August 26th, 2013
Tags: facebook, JavaScript, performance, react

Here’s to a faster Recommendations plugin

So I’ve been part of the quest of making all Facebook social plugins faster, even if it means rewriting them from scratch. After the Send plugin, Like button (perf optimizations described here), Follow plugin, Facepile and Likebox (perf details here), now you have a faster Recommendations plugin. The techniques used to make it faster are […]

May 5th, 2013
Tags: facebook, performance

CSS animations off the UI thread

This excellent Google I/O talk mentions that Chrome for Android moves the CSS animations off of the UI thread, which is, of course, a great idea. Playing around with it, here’s what I found: Browser support: Desktop Safari, iOS Safari, Android Chrome. You need to use CSS transforms. Animating regular properties doesn’t work. Update: (see […]

March 12th, 2013
Tags: CSS, performance

C3PO: Common 3rd-party objects

Problem: too much JavaScript in your page to handle 3rd party widgets (e.g. Like buttons) Possible solution: a common piece of JavaScript to handle all third parties’ needs What JavaScript? If you’ve read the previous post, you see that the most features in a third party widget are possible only if you inject JavaScript from […]

February 18th, 2013
Tags: facebook, JavaScript, performance