Skip to main content

Writing the game of life in Futhark

Some time ago I found a found a video of someone implementing the Game of Life on APL (you should take a look at it, the rest of the post will make more sense afterwards). APL is famous for being both expressive and unreadable for the non initiated. For example this Game of Life can be expressed as (code from

life{                                  ⍝ John Conway's "Game of Life".
    1 .3 4=+/,¯1 0 1∘.¯1 0 1∘.⌽⊂  ⍝ Expression for next generation.

The video linked above is quite interesting as it explains what all that symbols mean.

Some time later I was fiddling with the Futhark programming language and found a blog post titled "Futhark as target language for an APL compiler". This made me realize that APL and Futhark operate over (mostly) the same base concepts, and that replicating the same process on Futhark will be a good way to get to learn the basic operations of the language.

As an side note that this Game of Life is already implemented as a benchmark sample program for Futhark, so if you're interested in a useful implementation you should probably consider that one ;)

What is Futhark?

Futhark website describes the language as a "High-performance purely functional data-parallel array programming on the GPU". You could think it's something like a Haskell (with no recursion) which compiles its programs to something that a GPU can run (or anything OpenCL-enabled).

Read more…

Writing a browser extension in typescript

Every once in a while I write some small web browser extension to do little things. You could, for example, write an extension for showing the ID's of elements in a web or replacing AI with "a bunch of dudes", and after firefox adopting WebExtensions as the way to write these plugins we can make it so the same code works with Firefox and Chrome!

While we're at it, let's see which extra steps we have to take to write these extensions on Typescript, after we have a running Javascript version.

So let's go ahead and write a simple extension which allows us show the ID's of elements on a web. This could be used, for example, to generate links which end with #id-of-element which when opened will make the browser scroll to that element. We won't go in depth, let's make it fast.

Extension popup

Read more…

Clone this wiki

Wow, a post after almost two years!

I'm going to be brief to avoid taking hours to make a single post and going back to not writing.

First things first, I setup a wiki for personal references/notes it's not thought to have refined or complete content, just fast tips to solve situations I encountered. It might be handy, it might not, it's your decision.

I had a bit of fun making it as minimalistic as possible, and now it should run with only sh and a markdown to html compiler. All of this while being fully version-controlled by git. You can take a look at it on my gitea or on github. (Yep, content and "code" shares version control as there's really little code)

Ok, with that out of the way...

Lots of things happened lately, but in summary

  • I'll start writting back, now in english. It's not harder and saves me the effort of translating every post, which was what made me stop in the first place.

  • Posts will get smaller, and i'll cover mostly my own projects. Doing comprehensive writeups take a loooong time so (unless something is very interesting) I won't be doing more. Also, tips and how-to's will go to the wiki but i'll try to add an entry here just to link back.

That is the plan anyway ¯\_(ツ)_/¯

Saw that? A post written in ~30 minutes, that's much better that 2 days for a writeup :D!

Primer batch de tweetcodes (1 - 10)

Desde finales de enero estoy publicando un tweetcode al día en gnusocial (@oneliners), y en twitter (@twtcodes). El concepto viene de una idea que tuvo @hacklego para hackliza: un twitcode sería un pequeño codigo, de no más de 140 caracteres, que tenga alguna utilidad. Parte de la idea, era también dar una explicación de como funciona, así que ahora que va más de un mes de estos twitcodes, toca empezar a explicarlos. Veamos...

Read more…

Setting the brightness in Awesome

Being able to change the luminosity of a screen is always something useful, to adjust it when there's more or less light, or even switching it off to keep a laptop processing. This usually works on it's own when we use an environment like KDE or Gnome, but it may not be like this if we don't use certain drivers or if we prefer more configurable environments (like awesome).

Read more…

Subuser: un Docker para el escritorio

Hoy andaba trasteando con Docker e intentando hacer que corriera una aplicación de escritorio, algo que no se puede hacer sin salirse del flujo que se espera de esta herramienta.

Docker es una plataforma que permite gestionar “contenedores”, algo similar a las máquinas virtuales de toda la vida, pero sin la sobrecarga de tener que simular otro sistema completo con su kernel y sus cosillas... Estos contenedores encontraron un entorno perfecto en los servidores, donde permiten montar más VPS, o donde permiten que cada micro-servicio corra de forma aislada sin necesidad de varias máquinas.

Sin embargo estos sistemas no estan orientados a las máquinas de “escritorio”, y se portan especialmente mal con X11. Esto es así poque para que un programa funcione sobre X11 sería necesario levantar un socket desde el anfitrion, es decir, desde fuera del contenedor, algo que no se puede automatizar a través de estas herramientas (aunque si con un shell script). Otra solución es levantar un servidor VNC dentro del contenedor, pero podemos intuir que el rendimiento es “limitado” :P.

Pues bien, hay un proyecto que pretende solventar este problema, este es Subuser. Podríamos decir, y ellos lo hacen, que Subuser es un Qubes OS ligero, simplemente da una capa de abstracción sobre Docker para permitir que aplicaciones de escritorio funcionen de forma transparente (o casi). Para ello implementaron un puente para la interfaz gráfica, y un sistema de gestión de permisos.

Read more…