Skip to main content

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:

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

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 dyalog.com):

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…