Simple Features Thoughts about simple features in software development


How to run visual apps from an Ubuntu EC2 instance (Ubuntu 13.10 server/Windows client)

First of all: don't try to make this if you actually want to watch streamed videos from an EC2 instance; you can do it if you spend enough money for such purposes. The intention of this setup is to display low quality plots being updated from Gnuplot since I'm studying some stuff that makes use of it.

Second: I will not get in depth in how to setup and initiate an instance since there is a lot of information available for this (and more important: I have contractual reasons not to talk about this without proper authorization).

Here I will just get into the details of what to setup after you have your instance ready and running and then set up what it takes to open the visual applications from your Windows desktop.

The part of setting up an EC2 instance can be achieved if we follow the instructions given in the following video up to the minute 04:45. If you keep on watching the video after that moment we will not get the final goal that we want:

The console as its shown is a bit different from what you will see since the video is a bit outdated, but the overall goal can be achieved with the information he's giving. We are using also a Ubuntu instance and the free tier version may work for this tutorial.

After doing what is in this video (before minute 04:45), we must have 3 things at hand:

  • We must download Putty and PuttyGen, which are two pieces of software that would allow us to connect safely to our EC2 instance from Windows. The software can be downloaded from here and there is no need to install it, it will just run;
  • we also must download Xming from here and install it by just following the default options. Xming will be the software that will receive the instructions from the instance of what has to be shown in our Windows box and then draws it in the screen. This is achieved via a protocol named X11 which beauty relies and that it just works;
  • we must have at hand the private key downloaded from AWS when we were creating our instance (02:09-02:21) and transformed with PuttyGen as shown in the video (03:06-04:00). Its original name had the extension .pem and now it has an extension .ppk. This private key has to be kept only in those computers that will connect to the instance: if you want to use two different computers to access such instance (or more instances if they share the same key) then share it between such computers, just don't email it to yourself because the security people gets mad and yells at you.

Once we have our previous requisites we should start with the following steps:

  1. Make sure that Xming is running. Its status will be shown in the notification area of the task bar:
  2. Open Putty, and first it will open in the "Session" options window. There you will write the name of the EC2 instance that you want to connect to. It is important to note that I added the username ubuntu at the beginning of the instance address: such user is by default in the Ubuntu instances from AWS and that is part of the instructions that Amazon will provide when setting up an instance.
  3. We now navigate in the left three to the Auth node, and there we will tell Putty to use our secret key provided by Amazon and transformed by PuttyGen. In specific we will select the .ppk file.
  4. The next parameter to set, is that Putty will serve as a gateway for the X11 protocol. We will enter the proper configuration window and set it:
  5. And since we don't want to do it over and over every time we want to use it, we save our configuration:
  6. Now, let's open the connection. It's a magical feeling. It will then ask you whether you are sure you want to connect to this instance. Just say "Yes".
  7. Now we will install stuff in the server, and then we will test that it works by running the program "xterm":
    $ sudo apt-get update
    $ sudo apt-get install xorg openbox
    $ xterm

  8. If the previous screen is visible then it means that it works. We are done if all you wanted is to make sure that X11 was working. Nevertheless, I said that I wanted to install gnuplot. You have to close the open terminal window and now we will type:
    $ sudo apt-get install gnuplot gnuplot-x11
    $ gnuplot
    gnuplot> plot sin(x)

    and there's sin(x), plotted, for you.

Filed under: devops No Comments

Mexico’s regions list for Magento

In order to handle shipping rates, Magento requires you to use country and area codes in ISO-2 format (short for ISO 3166-1 alpha-2).

Here there are the codes for Mexico:

Instructions for their use may be found here.


My first Maven Web Archetype

I have just made my first maven Archetype for my own Web projects.

It includes:

  • Spring MVC
  • Tiles
  • Hibernate
  • SLF4J
  • JUnit4
  • EasyMock 3

To use it you may first download the file (perroazul-webapp-archetype.rar but may not be the lastest) or get it from its Subversion repository. Once downloaded, you enter into the directory and then write mvn install. That's it.

To use it, you must type the following command:

mvn archetype:generate                                \
  -DarchetypeGroupId=net.perroazul                    \
  -DarchetypeArtifactId=perroazul-webapp-archetype    \
  -DarchetypeVersion=1.0-SNAPSHOT                     \
  -DgroupId=<your.groupid>                            \

In case you don't realize values for groupId and artifactId, groupId is the package and artifactId is the application name. An example may be:

mvn archetype:generate                                \
  -DarchetypeGroupId=net.perroazul                    \
  -DarchetypeArtifactId=perroazul-webapp-archetype    \
  -DarchetypeVersion=1.0-SNAPSHOT                     \
  -DgroupId=net.perroazul.testapp                     \

And happy coding!


MySql Backup example script

As part of the poor man's high availability server array posts series, I include the following script that synchronizes  the master and backup database servers.

Filed under: devops Continue reading

Mexico full area code list

In Mexico, we call telephony area codes "LADA" (short for LArga DistanciA) . I couldn't find any usable list of such area codes so I made one myself.

Here is the full list in both XLSX and CSV formats.

Filed under: resources No Comments

How did you fail now, Mr. Dumbass!

What was your failure now, Mr. Dumbass?

I have seen a lot of things about Node.js in the last 12 months. In the beginning I started following the hype on blogs and Twitter. I was interested in knowing what was so great about a JavaScript based socket server. The first time I thought it was something like a WebSockets framework. Then I understood it was something else, built to live in the server side and I got even more amazed. I thought there was something I wasn't aware of, like I was missing the great part of having JavaScript on the server side. I was ready to start working on a new project that involved Node.js so I could see its potential. I studied more about it. It was the moment I realized what was under the box of amazement: it was nothing. At least nothing new.

The real hype was because it was developed in a language that is affordable for almost every developer out there. Affordable not because its easy to learn but because it's everywhere. Even plenty of web designers know JavaScript decently enough.

I'm not saying it doesn't work, or it doesn't work correctly (in the end I haven't even used it).

The hype was driven because a lot of people had never worked with sockets and its various flavours (socket event handling included), people that has always been far from working with multi-threading (and it's debugging issues), people that has always programmed with a Software Architect by his/her side and using plenty of frameworks. People who has never had to profile and debug, and some of them who have never had to improve memory and throughput consumption when working with byte level protocols. And it's not that I think that low level programming is more interesting or more difficult, or just for computer geniuses. It because there are people that does that kind of programming, some other are great web designers, some others are great architects while some other code a lot of useful boilerplate.

Now, what happens when someone with a decent knowledge on JavaScript, but no experience at all in systems and network management, data transfer rates, network security, etc., starts opening network sockets all over the infrastructure: format errors, security breaches, stack overflow issues, and so on... because it takes a lot of time for server systems to get mature. So is with server developers. You will not make the next Apache just because you know JavaScript and know a bit about sockets; you will make the next Apache when you have gone a long way with development, network understanding, systems administration and many other stuff, and then you know a language better suited for low level programming.

And the real problem is with people that does stuff just because they can, not because they know. We have a lot of tools that deals with all of the "I don't know how"'s and turns it into an "I have a tool for that!". "I know a wizard", "I've read a tutorial", "My IDE makes it very simple" and many others also stand for the same kind of technology abuse.

Tutorials, wizards and tools are for improving learning and development times, not for turning any developer into an instant expert of any subject. We all must go a long way before really knowing something, and sometimes we think something will work great just because the tutorial example works perfect.

I used to work in a company where my former boss thinks that any time he asked "What was the failure?", there would be someone among us that knew every coding line in our systems and would give him an answer sooner or later. In order to make it happen we would have to implement as much as possible by ourselves. It would take us plenty of development time, but there were no large delays in problem solving. Some of our advantages were that we had a controlled network environment, and that we grew as a development team together with the infraestructure. We were dumber when the network was smaller. We would always had an answer for such question.

Whenever you have a problem and you don't know the whole picture, and you don't know how to fix it, the question will change  from "What was the failure?" to "How did you fail now, Mr. Dumbass?".

Image: Ambro /


De la factura electrónica o cómo no me haré millonario este fin de año

Si facturas más de cuatro millones de pesos al año es probable que  no te interese este post (también es probable que puedas contratar a alguien para que lo lea). Si no es ese tu caso es probable que estes pensando en adquirir software, hardware o contratar servicios para resolver ese problema del 2011. Mi primer consejo: siguelas llenando con pluma, negra de preferencia, azul si es la que hay.


Java Dates – Is long a good idea for handling dates?

Answer goes: yes, most of the times, but...


RFID Pasivo – Inexplorado, simple y rodeado de mitos

Desde hace unos meses estoy trabajando con RFID pasivo. La experiencia es dulce y amarga. Amarga porque parece que hay una regla generalizada para que los proveedores de esta tecnología se esfuercen en dar un mal servicio y considerar esta tecnología como una ciencia oculta. Dulce, porque RFID simplemente funciona.


Texto, tiempo, y monedas

Hace un par de semana estaba por entregar un nuevo sistema de comunicaciones para AVL (Localización automática de vehículos). Nos percatamos que ese fin de semana, México finalizaría el horario de verano: la diferencia de -5 UTC cambiaría a la diferencia normal de -6 (HCM). En nuestra compañía establecimos un estándar para ejecutar los cambios de horario coherentes en todo el sistema de acuerdo con las especificaciones nacionales. Sin embargo ahora el sistema estaba reportando una diferencia de -4 horas.

¿Qué demonios pasa? ¿Como paso de que tenía una diferencia de -5 horas a la normal de -6 hasta una totalmente anormal diferencia de -4, y para hacerlo más complicado, 5 horas antes de que el cambio de horario ocurriera?

Este es el tipo de requerimientos que pueden volver a un programador en un lío en una nada de tiempo... Fue en ese momento que mi amigo Carlo y yo recordamos una de las cosas más importantes de la computación: luego de 60 años de innovación, nuevas tecnologías, logros sorprendentes en la ciencia, aterrizajes lunares, etc., no ha existido una resolución definitiva para tres temas principales.

  1. Monedas,
  2. texto,
  3. y tiempo

La moneda por si misma es un tipo de dato. La moneda no puede ser representada por un float ó por un double. El problema con la moneda no es como hacer aritmética simple con una clase Currency (cuya verbosidad puede hacernos querer cambiar de carrera), sino en toda la complejidad de establecer el valor del dinero cuando el sistema no está preparado para cambios de moneda... esto es una sentencia final de sistema.

El problema con el texto es acerca del manejo de caracteres (charsets). Hoy observaba un webcast donde una de las características fabulosas del procesamiento de texto en Silverlight 4 era la capacidad de mezclar charsets en el mismo documento. En un sólo párrafo estábamos viendo UTF-8 mezclado con otros textos unicode. Finalmente había un documento de texto con una característica sólo vista antes en tinta y papel, y sólo tomó sesenta años de tecnología e investigación.

Con el uso de formatos altamente verbales (estoy pensando en tí, XML) el almacenamiento y distribución de la información no es una tarea fácil cuando llega el momento de elegir los formatos. La primera vez que use XML simplemente copié el header que más comunmente encontré en los ejemplos, y siempre decía "UTF-8"; usar UTF-8 en español es como cortar el diccionario a la mitad. Después de algunos intentos empecé a utilizar ISO-8859-1 con todas las capacidades que esto me dió de usar el diccionario español completo pero, ¿Fué la mejor decisión de diseño?

El tiempo es una ciencia completa. Las zonas horarias son HORRIBLES: diferencias horarias de horas, medias horas y cuartos de hora (ver Nepal aquí y aquí y las islas Chatham aquí) entre las zonas horarias son simplemente una locura. Y hay mucho que responder con respecto al tiempo:

  1. ¿A qué hora pasó X? ¿Tiempo del usuario? ¿Tiempo del servidor? ¿Y que tal que mi aplicación es distribuída?
  2. ¿A qué hora sucederá X?
  3. Si cambia la zona horaria (aparatos móviles), ¿se dará cuenta mi dispositivo?
  4. Si estoy usando Linux y mi aplicación cambia a Windows, ¿seguirá siendo el tiempo coherente?
  5. y las preguntas pueden continuar ad-infinitum...

Los calendarios... ¿ha trabajado alguien con calendarios sin sentir la necesidad de ser enterrado vivo? No hay correlación entre todos los calendarios. Por ejemplo, observemos dos hechos del calendario judío: el año del 2009 al 2010 corresponde al 5770 de su era, y el año tien 354 días (ó 353, ó 355) divididos en 12 meses lunares, llenando los días restantes con un mes periodicamente.

El mayor problema acerca de estos tres temas que estamos tocando: la mayoría de las preguntas surgen cuando han salido a la superficie en la forma de un bug.

Una aplicación normal a ser usada dentro de una compañía debe estar atenta a estos problemas. Regularmente, un desarrollador sólo usará el primer enfoque que le de el lenguaje ó el IDE al momento de necesitar entregar un nuevo producto. Resolver estos temas tal con las opciones predefinidas se convertirá en una decisión que se heredará en tus pasos siguientes en la compañía, y en la decisión de la que SIEMPRE te arrepentirás.

Estos tres temas son la razon de existir de este blog. Al revisar estos temas podemos percatarnos que hay muchos requerimientos básicos en la programación que afectan el comportamiento de un sistema y que no están bien enfocados para los principiantes, y donde los programadores avanzados sólo dan consejos generales pero no respuestas directas. Estos no son necesariamente los únicos temas, pero estaremos trabajando en ellos frecuentemente.

En términos vagos, esto fué lo que pasó con la diferencia de cuatro horas: no consideré el comportamiento del lenguaje al implementar el estándar de la compañía. En detalle, esto será analizado y corregido la próxima semana.