Skip to main content

Get process's progress when reading a file

Hi! Lately in my day job I've been using a Blender plugin to read PC2 animations. Animations of about 8Gb in size. On the current state of this plugin this blocks the whole GUI of Blender and can take up to ~10 minutes to load the whole file. Sometimes I could work on something else in parallel, but one time I've been stuck waiting for this to load though "how difficult can it be to find out how far into reading the file is the process?".

Turns out, thanks to /proc it is not very difficult to know from outside a process how much that process has read into a given file.

Read more…

A simple status indicator

Hi! Today I want to show you how to build and use a simple status indicator system.

Waybar showing "build" in green and "test" in red

You can see here the end result, applied on Waybar indicating that build passed but tests failed.

It can also be used on AwesomeWM.

AwesomeWM showing "build" in green and "test" in red

This is entirely written in bash (and some Lua for the AwesomeWM plugin), and built with real simplicity in mind.

I've worked with them in their current state for the latest 2 years (although just some hours for the Waybar version) and found them enough for me.

Keeping this in mind, there's lots of improvements that may be easy to apply, so I'll write down some ideas at the end. Think of this as a Minimum Viable Product.

You can find all the code on: GitHub.

Read more…

Secure Websockets with ESP8266 and Arduino

This last week I've been working on connecting an ESP8266 to Plaza, so it could be used to stream sensor data to the platform (and back).

Along the way I learned a bit of Arduino. The first hour you get to connect the tiny board to a WiFi and write some C code. After that you can keep trying until everything gets to work.

The goal of this post is to show the steps needed to connect the board to a secure WebSocket endpoint (the ones starting with wss://)... the tricky part is the secure. All of this using the Arduino programming environment.

Read more…

Fast test on simplified english

In this post I'd like to do a brief (and not scientific at all) test on how easy is to write English in a simple way, and indirectly to personally understand how wordy I am, hopefully it can be interesting to you too.

The reason for this is that some time ago, when writing Plaza's documentation, a friend which helped me writing it expressed concern on the documentation's use of words being too complex for someone whose first language is not English. That criticism made a lot of sense as the goal of the documentation was (and is) to be an easy way for people to understand the goal and technical structure of the project, so they can contribute to its development.

For the purposes of this post, the criteria used to check if the text is "simple" or not will be the ones of the Simple English Wikipedia.

Read more…

A Kubernetes concept map

Kubernetes is a tool which is now apparently everywhere. It addresses a lot of the problems related with running microservice, container-based infrastructures and does so in a very flexible way.

But a downside of this technology is that it requires getting used to so many concepts before anything makes sense, that the initial learning curve might be a bit too steep.

As my 2 cents to help with this (and as a sort of follow-up for the last post), here is a rough map, showing most of the resources available to a Kubernetes user and how everything relates.

It's certainly not complete, and there's probably bugs (pull requests appreciated). There's not much to explain about it... most importantly, links are clickable, arrows goint into the Pod resource are purple and those going out of it are brown-red so it isn't too messy, but it doesn't have a special meaning.

Kubernetes concept map Click the image to see it properly

Graphviz: fast and simple diagrams

Lately I've been looking for tools that take plain-text and generate a representation useful for humans. These are generally easy to use with git, and to build scripts around. Also, because they are operated from plain-text, they usually can be treated as a distraction-free way of organizing data.

Graphviz is one of such tools, it allows us to define this:

digraph {
  rankdir=LR;  // Set orientation as horizontal

  // And just define the connections.
  one -> two -> three;
  three -> four;
  four -> two;

And obtain this image:

Render of the sample code

Read more…

Matrix operators as stack languages 2: closing maps

On the last post we saw how some matrix operations can be considered as forth-like operations over a stack of dimensions.

  • To do a swap add a transpose(mat) and continue on the left of it.
  • To move from dimension stack to the auxiliary one, open a map( (don't close it) and continue on inside the map.
  • New operations can be performed inside the map as long as they are done over the map lambda parameter.

Now, let's try to extend the process to allow exiting a MAP (moving from the auxiliary stack back into the dimensions one).

Read more…

Matrix operators as stack languages

On the last post we explored how some program written on APL can be translated to Futhark.

Both Futhark and APL can be considered array programming languages.

A difference between them is that APL can express inner or outer operations when handling a multidimensional array, meaning that having an array 3×3×5×7 we can sum the values when only the first dimension is different, converting it into a 3×5×7 matrix (see the operation demonstrated here). By the way, the sizes come from the example on last post and don't have any special meaning.

Read more…

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…