01 Feb 2015

Migrated to Hugo

As I explained a few weeks ago, I’m migrating all my blogs and static sites from Wordpress to Hugo.

Even though this site was not using Wordpress but Jekyll, I feel it’s better to just use one tool across al my websites. Also, I like Hugo more ;)

I’d say that migrating from Jekyll to Hugo is even easier than migrating from Wordpress. The main pain point are the templates.

I’m incapable of doing a beautiful site, so I’ve grabbed the purehugo theme and made some tweaks here and there.

Also this blog is now in a public repository in github.

31 Jan 2015

Exploring reactjs

There’s been a lot of activity around the announcement of React Native this week. I’ve been wanting to take a look at reactjs for sometime. I don’t know exactly where I am on the javascript learning ladder, but I’m starting to feel the urgency of putting some kind of organization on my javascript code.

The best way to experience a new technology, language, framework or library is to build something for yourself. So after reading a couple of tutorials I decided to try to build something.

I keep a list of the movies I watch, just because, you know, maybe someday will be interesting to analize the data. Anyway, I’ve tried to use reactjs to show the posters of those movies. Who knows, maybe I could use it in the future to show the movies I watch in this blog.

In order to get the posters I’m using the Rotten Tomatoes API. The code just uses an array of movie titles, make an API request for each one and returns it’s image.

It was necessary to throttle the AJAX requests as the API only allows you to make 5 req/s.

Here is the code in case you are interested: react-movies in github

react-movies image

I have to say that I like reactjs. I plan to dive deeper to see if it will help me improve my javascript applications.

28 Jan 2015

git cherry

Today I learned about git cherry. I knew about cherry-pick, which I use from time to time, but this is a different cherry.

In one of my projects, a desktop application, I maintain a branch per released version. This way I have branches like production-5.0, production-5.1 and so on.

From time to time I make some changes that need to go to master too. Instead of merging and getting a lot of noise, I sometimes cherry-pick those commits to add them to master.

The problem is that sometimes I don’t know which commits has been back-ported to master. git cherry is useful in this situation:

$ git cherry -v master production-5.1
- d326c2997eb355eb79d4974e2e4a75a4bcc7755d gen_searches fix description
- d326c2997eb355eb79d4974e2e4a75a4bcc7755d gen_searches sex filter
+ 7b804f83de325f31b43f372793a5acaf563b8ec9 select result and compare it as known parental against other results

In this example, the first two commits are already on master, and the third one is not.

Now I only have to cherry-pick the third one and I’m done.

26 Oct 2014

Removing complexity hosting static websites

The incident

One of my product websites was hit with the Google Viagra Hack. This hack injects different content to your website when is fetched by Google.

It’s subtle because you might not be aware of it for weeks. When you visit your site everything seems fine. If you take a look at your source files, everything is fine. However, when Google crawls your site it only finds Viagra links and related content.

When you google your site, you’ll find that it displays an scary message:

This site may be hacked

And the descriptions altered with medicine ads.

The investigation

Ok, so someone somehow managed to change the content of my website, at least to Google. After the initial panic, I used Google Webmaster Tools to see my website through Google eyes. It was a mess.

I investigate a bit this hack and it seems that it’s just a script that takes advantage of some PHP plugin or misconfiguration. On my website root folder there was an obfuscated PHP files called stats.php.

This website, as many others I have to maintain, are just static content. HTML, CSS and JS client code. Some of these websites are hosted on Dreamhost, together with some old WP blogs and old PHP websites, and they are likely to be the door to this hack.

My resolution: simplify

I’ve been migrating my websites away from WordPress for some months. First I discovered Jekyll but now I’m using Hugo. It just feels right to have my content as version controlled files instead of having a full PHP framework running including a MySQL database.

In my view the next logical step is to get away from traditional hosting all together. There are several alternatives like using Dropbox+Github or using Amazon S3.

I chose the later.

Hosting static websites in Amazon S3

The setup is very simple.

Basically you create a bucket with your website address, put there your files, configure the bucket to serve the website and update DNS records using Amazon Route 53.

22 Oct 2014

Make vim and command-T work on Yosemite

The upgrade from Marvericks to Yosemite went smoothly except for one thing: vim is segfaulting every time I use Commant-T

The most common answer is that vim has been compiled with a different ruby version than Command-T. However, after being sure to recompile Command-T the problem was still there.

Turns out that I had Command-T on the vim’s plugin directory. After removing it and cloning it into ~.vim/bundle, and recompiling it with:

ruby extconf.rb

it started working again. Be sure to leave no Commant-T files on the plugin folder. I left commant-t.vim by mistake and even though I was no longer getting SEGFAULTs, command-t was not working properly.

18 Jun 2014

How to change network adapter order in Windows

One of my applications acts as a TCP/IP server for an external laboratory instrument. In one of my customers, this instrument is directly connected to the PC running my app using a USB to Ethernet dongle.

The problem is that my application is binding to the default ethernet adapter which is a WIFI card.

It took me a while to find out how to change the order of the ethernet adapters. If you do a quick google search http://support.microsoft.com/kb/2526067, you’ll find that you have to go to:

View network connections > Advanced settings > Change the binding order

However, this did not work for me. My app was still reporting the IP address of the WIFI adapter, even after a system restart.

Deep in a Microsfot KB support article is the solution. You can change a parameter in the adapter called Interface metric. And that worked! I put 3 on the USB converter and 5 on the WIFI adapter, and voilà!

 Click Start, click Run, type ncpa.cpl , and then click OK.

 The available connections appear in the LAN and High-Speed Internet section of
 the Network Connections window.

 Right-click the network adapter that you want to change, click Properties, and
 then click the General tab.

 In the This connection uses the following items box, select Internet Protocol
 (TCP/IP). Then, click Properties.

 In the Internet Protocol (TCP/IP) Properties dialog box, click the General
 tab, and then click Advanced.

 On the IP Settings tab, click to clear the Automatic metric check box. Then,
 type a value in the Interface metric box.

26 May 2013

Upgrading passenger and nginx

I deploy code to production servers on a daily basis, however when I have to upgrade system components I feel uneasy.

I had a couple of servers still running an ancient version of nginx, 1.2.0 or somethig like that. It was upgrade time…

Better be safe than sorry

Instead of go ahead and update directly on the production machine, I launch a new linode and restore the last backup to it. This way I can see if there will be any problem with the upgrading process.

Passenger makes installing / updating nginx easy

The process can’t get easier than this:

gem update passenger
rvmsudo passenger-install-nginx-module

I choose to let it download and install nginx itself.

The last step is to edit your nginx.conf and update the passenger root folder.

Adding SPDY support

If you want to activate additional modules other than the defaults, you need to download the nginx source code first. Again the install is very simple thanks to passenger.

First download and untar the nginx source code:

wget http://nginx.org/download/nginx-1.4.1.tar.gz
tar xvzf nginx-1.4.1.tar.gz


rvmsudo passenger-install-nginx-module

This time you want to choose option 2. You simply have to type where the nginx source code is located and pass addtional compile options.

In my case to activate the SPDY module: –with-http_spdy_module

23 May 2013

localhost subdomains

I maintain a multitenant rails application where each customer (tenant) gets its own subdomain.

In order to develop and test this application on my development computer I use the domain lvh.me which uses a DNS trick, this domains and all its subdomains point to localhost.

This way I can type customer1.lvh.me:3000 and it just works. No need to touch anything on your computer.

Today I receive a bug report that only happens on IE < 10 (oh well!). I usually just use a Windows machine and type my dev machine IP on the address bar, however this time I need to access a subdomain on my dev machine so 192.168.1.XXX:3000 was not going to work.

The solution was to edit the file \Windows\system32\drivers\etc\hosts and add the following entry:   myapp.com

This way now I can type http://customer1.myapp.com:3000 on the Windows machine and get it routed to my dev box with the subdomain name.

20 Mar 2013

How to resize a VirtualBox Ubuntu guest partition

Usually I rarely use more than 20GB on my Linux virtual machine. However I set up Dropbox and, once it synced, I had only a few megabytes left on my VM.

These are the steps I’ve followed to resize the VM partition:

Make a backup of your VM

You can potentially destroy your VM so better safe than sorry. Make a copy of your VM.

Delete snapshots

If you have snapshots you must delete them first so changes are merged on the main disk file.

Resize the virtual disk

Run the following command:

VBoxManage.exe modifyhd ubuntu.vdi –-resize 40000

Download GParted Live CD/USB image and use it to boot the VM

You need to download GParted Once downloaded boot your VM with the GParted image.

Resize the partition

If the swap partition happens to be between the primary partition and the unallocated space, you need to remove it. Resize the primary partition and then create the swap partition back.

Be sure to write down the size of the swap partition before delete it and leave that space unallocated when resizing the primary partition.

Once you are happy with changes click apply and exit GParted. Remove it from the boot sequence and restart the VM. Enjoy the extra space.

06 Mar 2013

Portabilidad Movistar-Vodafone + iPhone 5

No soy de los que cambian de móvil cada año. De hecho, el contrato de permanencia que firmé con Movistar hace unos años finalizó en 2011. Y aún seguiría con el mismo iPhone 3GS que adquirí entonces si no fuera porque lo perdí hace 1 mes (historia que no viene al caso).

Desde que lo perdí, he estado usando un iPhone 4 prestado. Comparado con mi 3GS se nota sobre todo la mayor resolución de la pantalla y que funciona algo más rápido. Sin embargo, hay cosas que eran mejor en el 3GS. La batería dura menos, el botón de inicio falla en ocasiones, la señal de WIFI es más débil y sobre todo tiene menos cobertura.

La cobertuta de Movistar no es muy buena en mi zona, ya con el 3GS tenía en ocasiones problemas, pero con el iPhone 4 directamente es imposible trabajar. Prácticamente ninguna llamada me entra directamente y los avisos de llamada llegan tarde. Para hacer una llamada tengo que esperar a ver 3 barras, estando la mayor parte del tiempo con tan solo 2.

Curiosamente la cobertura de Vodafone es excelente en esta zona. Así que decidí cambiar de compañía tras más de 3 años con Movistar.

Aprovechando el cambio de compañía y puesto que el teléfono que tengo ahora no es realmente mío, cogeré el iPhone 5.

Esta ha sido el proceso:

1302: Hago el pedido en la web de Vodafone. El proceso es bastante claro. Elijo el plan Red Pro y un iPhone 5 32GB. Sale por 59€/mes + 176€ por el teléfono. 24 meses de permanencia. Envío la documentación que piden por email en ese mismo momento para acelerar el proceso.

1402: Me llaman de Vodafone para formalizar el contrato. El proceso lleva unos 20 minutos pues me vuelven a pedir todos los datos que metí en el pedido. Vuelvo a enviar la documentación, esta vez por fax porque me dicen que suele ser más rápido!! En serio??

1902: Sin noticias. Por curiosidad me meto en la página de vodafona a ver si hay alguna manera de ver el estado de mi pedido/portabilidad. Si que la hay. Sin embargo no es muy informativa. Estado del
pedido Decido llamar no sea que haya algún problema. Es un 902 de pago; mala forma de tratar a los clientes. Me atiende una señorita en España, tras pedirme el DNI, me dice que:

Hay algún problema con nuestros sistemas informáticos y no podemos saber el estado de su pedido. Llame dentro de 30 minutos.

¿Cuántas veces habré oído esa excusa? A las 2 horas vuelvo a llamar. De nuevo me atienden de forma local. Esta vez sí me dicen que hay un problema. Por lo visto falta la parte de atrás del DNI, la cual envié junto al resto de documentación. Le pregunto que si no llego a llamar, ¿cuánto tiempo habría estado parado el pedido? En su defensa hay que reconocer que sólo han pasado 4 días laborables.

Vuevo a enviar la documentación.

2102: Sin cambios en la página de seguimiento del pedido. Llamo de nuevo al 902 y la persona que me atiende me dice que ya disponen de toda la documentación necesaria y se disponen a iniciar el proceso. 4 o 5 días más.

2602: Vuelvo a llamar tras la falta de información en la página de seguimiento del pedido / portabilidad. Me dicen que ya está iniciado el trámite y que mañana o pasado me debería llamar Movistar para confirmar la portabilidad. Me asegura que como mucho lunes o martes debería estar ya funcionando con Vodafone.

2802: Parece que ya hay movimiento. Recibo un SMS diciendo que la portabilidad se realizará en la madrugada del día 6 de marzo. La página de seguimiento de Vodafone sin cambios. Más tarde recibo una llamada de Movistar intentando hacerme una contraoferta. Le digo que lo siento pero que es por un problema de falta de cobertura en mi zona. Vodafone me manda un SMS dicicendo que el pedido ha sido enviado. Hay página de seguimiento del pedido. Sin embargo, la página de seguimiento original sigue diciendo que no se ha iniciado ningún trámite.

01/03: Llega el teléfono y la tarjeta SIM. Sólo queda el paso de hacer efectiva la portabilidad.

06/03: Se completa la migración y por fin puedo empezar a usar el móvil con Vodafone.


Me ha gustado bastante la página de Vodafone para realizar el pedido. Sin embargo la página de seguimiento del pedido no funciona en absoluto. Deberían deshabilitarla pues lo único que hace es preocupar al cliente y forzarle a llamar.

Tampoco me ha gustado tener que llamar a un 902 de pago para saber el estado de la portabilidad/pedido.

Muy extraño que recomienden mandar la documentación por fax en lugar de por email. Por fax!!

Tres semanas para tramitar todo esto… excesivo!

Por lo menos parece que he solucionado mis problemas de cobertura.

Older posts...