Saltar ó contido principal

Detecting non halting programs

NOTE: This post comes from a place of little understanding of the base theory. I know the base comp-sci for this (I studied it in uni) but didn't read more in addition to that. For this reason it's probably full of misconceptions 🤷.

Introduction

There's this idea on math and computer-science that some problems cannot be resolved and are, fundamentally, incomputable. That makes sense! A specific example on comp-sci is the "halting problem".

The halting problem states that there is not possible to know, from a program description and it's imput, whether that program will eventually stop or whether it will run forever.

This is a widely accepted fact and known to be true. It has wide repercusions and many, really intelligent people has probably worked on it.

That being said, it just doesn't feel well. Certainly, you should be able to know if a program eventually completes or if it just runs infinitely! So from time to time I thought about this.

Ler máis…

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.

Ler máis…

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.

Ler máis…

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.

Ler máis…

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.

Ler máis…

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:

1
2
3
4
5
6
7
8
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

Ler máis…

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).

Ler máis…

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.

Ler máis…