Silly Bytes has moved - Silly Bytes se trasladó

23 sept. 2016

How do I blog? - Blogger posts from markdown and CLI

There are plans to migrate Silly Bytes to Hakyll and GitHub pages, but till then I'm still using Blogger and I wanted to make the posting process as painless and automatic as possible.

Every post I write is currently a separate git repo hosted on the Silly Bytes GitHub organization. The post is written and maintained in Markdown using Pandoc and a convenient Makefile generated by the made script.

Writing posts in Markdown is nice but is not very useful if you still have to mess around with Blogger's web interface, so here is the plan:
  • Write post in Markdown
  • Use made to generate a Makefile
  • Generate HTML from the Makefile post $ make
  • Push the HTML post to Blogger using Google APIs

The first 3 steps are already covered so lets dig into the Blogger negotiation part.

11 sept. 2016

Gentle introduction to STM32 ARM Cortex microcontrollers and boards programming

So you have been using AVR, PIC or some other microcontroller for a while and discover that ST Microelectronics offers some pretty cheap 32 bit ARM and feature rich microcontrollers: STM32, and want to start playing with them but don't know how or where to start; I'm here to help.

ARM is taking over the embedding wold, they're ubiquitous in smart phones, tablets, laptops, other computers, cars, refrigerators, microwave ovens, monitors, printers, you name it!

Note: Be aware that ARM is an architecture that manufacturers can implement. Is a common mistake to think ARM is a microcontroller on itself, it is not.

ST Microelectronics's implementation of ARM are the STM32 microcontrollers: inexpensive, powerful and with great free software/hardware support.

Various series are available: F0, F1, F2, ..., F7; From less to more powerful. You can identify your chip series after the STM32 prefix, I'm using a board with the "STM32F103C8" chip, so the series is F1.

28 ago. 2016

TDD (Test-Driven Development) Physical Traffic Light

Robert C. Martin (Uncle Bob) said in a talk:
Imagine you have a button that you can push, it will test your code and if everything is working a green light will come up, but if something is break, a red light will come up [...]
He was of course talking about TDD, but I was bored and get inspired to build this little toy.

Hardware schematics, firmware and host software is available in this Github repo. Along with information on how to compile and use.
This is a physical toy traffic light to be used with software development TDD (and testing in general) tools. It will not boost your productivity nor make you a better programmer or TDD practitioner, but it looks cool :)
Lets explain how it works, it's very simple:



The atmega328p AVR microcontroller is very popular and cheap, but if you buy them on Ebay for example, chances are it comes with an Arduino bootloader, which gets in the way because we can perfectly use the internal oscillator instead of an external 16Mhz crystal. So the first thing is to change de fuses to the default ones:

11 ago. 2016

Vim + Haskell

So you're writing in the right language using the right tool already, but lets put some extra magic under our sleeves.


  • Omnicompletion
  • Compilation and testing
    • Building
    • Linting
    • Testing
  • GHCI integration
  • Convenient mappings
    • Argument text object
    • Jump to importations
    • Jump between functions
  • Ghc-mod integration
    • Type inserting
    • Case splitting
    • Type asserting
  • Hlint integration
    • Linting
    • Managing the locationlist
  • Code formatting
    • Hindent integration
    • Trailing white space
    • Trailing blank lines
    • Spaces over tabs
  • Easy arrows generation
  • Types abbreviations
  • Yesod Haskell web framework

14 jul. 2016

PIC16F876A conversión analógica digital + UART (Ensamblador)

NOTE: This post is available in Spanish only. Please use a software translator.

He dejado de usar microcontroladores PIC por los motivos explicados aquí; Pero voy a dedicar este post para explicar un programa sencillo escrito en ensamblador para el PIC16F876A.

El objetivo es el siguiente:

Se desea usar el microcontrolador para llevar a cabo la conversión analógica-digital de una tensión variable (un LDR o un potenciómetro por ejemplo) y transmitir el resultado usando la UART. Además debe ser posible recibir por la UART un byte que debe alterar la configuración del Conversor Análogo Digital (DAC) interno del microcontrolador para, por ejemplo, cambiar el canal de entrada de la señal analógica o modificar la velocidad del reloj de conversión.

El código ha sido ensamblado con el ensamblador de GNU gpasm del juego de herramientas gputils, pero debería ser perfectamente compatible con las herramientas MPLAB de Microchip que no uso porque odio los IDEs. En cualquier caso la explicación y el 99% del código debería ser útil sin modificación alguna.

13 jul. 2016

Ratpoison: Fuzzy window selection

A nice feature to have is the ability to jump to an arbitrary window by performing a quick fuzzy searching whit just a few characters. We can achieve this by using Ratpoison's flexibility and the fantastic FZF tool.

The script will do the trick using FZF

29 jun. 2016

Aprende Haskell rápido y difícil

Asómbrate con Haskell

Esta es la traducción al español del artículo Haskell the hard way por Yann Esposito.

TL;DR*: Un corto y denso tutorial para aprender Haskell.

De verdad pienso que todos los desarrolladores deberían aprender Haskell. No creo que todos necesitan convertirse en ninjas de Haskell, pero deberían al menos descubrir que es lo que Haskell tiene para ofrecer. Aprender Haskell abre tu mente.

24 jun. 2016

Seamlessly Vim-Tmux-WindowManager-Monitor navigator

This Thoughtbot post describes how to make Vim and Tmux work together in Harmony based on this crhistoomey plugin, allowing you to traverse both your Vim and Tmux windows and panes respectively.

Having the ability to traverse Vim and Tmux splits without having to think about it using ctrl-h, ctrl-j, ctrl-k, ctrl-l is fantastic! But I still had an annoyance source from the window manager (Ratpoison) and the multi monitor setup.

So I took the same concept and extend it to those uses cases, so now I use ctrl-h, ctrl-j, ctrl-k, ctrl-l to move through my Window Manager splits, my Tmux panes, my Vim windows and my Monitors with minimum mental overhead. Here is how.

Some of the scripts are a bit of complex, so instead of explaining them in detail the general algorithm is described.

19 jun. 2016

How to write C in 2016

Matt wrote a very interesting and totally recommended post about how to C (as of 2016).

Keith Thompson wrote later a very detailed and rather useful critique with some extra notes about Matt's post.
Go a head and read both articles right now!

Here I would like to point out some things about tooling.

17 jun. 2016

From PIC to AVR

This is my humble contribution to the PIC vs AVR holy war.

TL;DR: I was a PIC user but decided I hate it, switched to AVR and love it!

PIC from Microchip and AVR from Atmel are both wonderful microcontrollers for hobbyist and professional as well (I am a hobbyist only if you're wondering).

I used to love PIC microcontrollers and originally choose them because they are the most widely available in my location. But there are just so many annoyances that AVR solves so wonderfully!

27 may. 2016

Firefox control on steroids [Firefox + Ratpoison + Mozrepl]

I'm not going to lie to you, what you're about to read is so cool you might want to buy me a cup of coffee and hug me.

Controlling all sort of stuff with Ratpoison, as you can see in my previous posts, is pretty neat and you can extend it to control your browser as well.

These are the current capabilities:

Every command start with the Ratpoison prefix + 'f' like so:

C-t f

**Command**     **Action**

    f           Facebook
    y           Youtube
    r           Reddit
    g           Github
    o           Open a new tab
    w           Open a new window
    s           Search for the current content in the clipboard
    /           Jump to the tab with url mathing a user input
    l           Open a new tab with the lyrics of the currenlty playing song (mpd)

22 may. 2016

A better and prettier mysql/mariadb CLI client

The default, unconfigured CLI client you use with mysql or mariadb is kind of awful, no colors, pretty bad query editing capabilities, and the output is not paged so you can't see a shit. Lets improve the experience.


Start by creating a configuration file ~/.my.cnf with the following content:


user = alx

Automatically prompt a password for your user, avoid giving --user option each time


Stop making annoying noises god dammit!


Is easy to type ^C by accident, don't kill the session!


4 may. 2016

Vim Kōans [Español]

Esta es la traducción al español de los vim kōans por Tom Ryder.

¿Qué es un Kōan?

El maestro Wq y el desarrollador de Windows

El maestro Wq se encontraba ayudado a algunos novatos de Vim. Luego de sus enseñanzas sobre las virtudes de Vim, pregunto si habían preguntas. Un hombre joven levantó la mano.
Maestro, como puedo filtrar la segunda columna de una tabla de texto plano para todas las filas que contienen la cadena 'tcp'?
El maestro Wq no dijo nada, se volteó al pizarrón detrás de él, y escribió:
    :%!awk '/tcp/ {print $2}'
Hubo un murmullo aprobador por parte de los estudiantes.
Pero yo desarrollo en Windows...
Balbuceó el estudiante.
El maestro Wq se volteó nuevamente, borró el comando, y escribió:

Qué!!? Eso es muy complicado para una tarea tan simple!
Replicó el estudiante.

20 abr. 2016

The Python Paradox is backwards

Paul Graham wrote a great short article back in 2004 called The Python Paradox where he states that if you look for python programmers you will end up with the best ones. The logic behind this is as follows:

Python is an esoteric language that universities and schools don't teach, so people that knows python are self thought, they know that their python skills wouldn't get them a better job so they do it for fun only; Considering that learning a new programming language can not be precisely a trivial task and that python knowledge wouldn't rank you higher for hiring we can infer that it takes a really passionate person, a hacker, to learn and use python.

That was very true 12 years ago, but now almost every single school and university not only teaches python, but use it as the primary language, and even as the only language!. Nowadays even some non technical schools teaches programming as a form of introducing their students to computers-logical thinking and they all use python precisely because of its simplicity; They even tend to over simplify an already simple language so their less clever students can catch it with ease.

28 mar. 2016

Why do I hate Java? / Por qué odio Java?

Everything is an object...

... No, it's not!

Not everything is a object. Have you ever carefully read Java code? It's full of actions dressed like objects: Mutator, Traverser, Factory, Maker, Creator, Generator, Mediator, Eliminator. So you don't mutate, traverse or create anything, instead you force an object that can do that.

Ok some of that stuff can be useful for well used design patterns and a good design, but most of the time is not!

16 mar. 2016

Why do I hate IDEs? / Por qué odio los IDEs?

Lets start by taking off of the discussion some important things:

  • Using an IDE and taking advantage of what it has to offer doesn't mean you're a bad programmer, and using a good text editor doesn't mean you're a good one.

  • Using an IDE can make you a bad programmer.

  • Relaying on an IDE can make you a bad programmer.

  • Depending on an IDE means your a bad programmer.

I think a lot of people will agree with this, so lets move on.

I'll keep updating this list in the future, if you have something you'd like to be added please let me know.

26 feb. 2016

Beautify your code with Astyle and Vim

Pretty code

Programmers love good code: good expressivity, good organization, ease of extensibility, maintainability, and so on. But we also like the code to be pretty, it makes the work more pleasant and enjoyable, but all this is probably not just for visually appealing reasons.

Is always nice to work with a style consistent code, it even makes it easier to navigate and read, our brains can dissect it more easily and our eyes can quickly jump to the right place. A pretty code transmits the idea that the people who wrote it do actually care about the program.

But there are some mundane reasons too... For lots of us an annoying voice in our heads is constantly telling us "you're wasting storage space, you're and idiot!" because some trailing white space or unnecessary blank lines are laying around in the code. Sure those few extra bytes won't hurt you 1+TB hard drive!, but for some of us it just feels wrong.

15 feb. 2016

Como escribir un emulador de computadora

Traducción al español de "Como escribir un emulador de computadora" por Marat Fayzullin

Escribí este documento luego de recibir varios correos electrónicos de personas a las que les gustaría escribir un emulador de una u otra computadora, pero que no saben por donde empezar. Las opiniones y consejos contenidos en este articulo son únicamente mios y no deberían ser tomados como verdad absoluta. El documento trata principalmente sobre los llamados emuladores "interpretes", contrario a los "compiladores", pues no tengo mucha experiencia con técnicas de recompilación. Se proporcionan un par de enlences donde se puede encontrar información sobre estas técnicas.