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!