the bloggest of mendes

Ramblings on life, development and me. Failing. Eventually. Consistently.

Read this first

Plug-based authorisation for Elixir and Phoenix

Note: this post was originally published on the Subvisual blog.

Some years ago, most of us here at Subvisual got really-perhaps-a-bit-too-much into Elixir. Ever since then, whenever we are free to choose the technology to work with, we’ve pretty much been going Elixir all the way.

We learned a lot. We laughed a lot. And I copy and pasted some code from different projects a lot. Don’t tell the rest of the development team. Aaaaanyway, I finally got around to open sourcing the copy/pasted code and releasing it as a package.

I called this thingy Dictator. It implements a plug-based authorisation system and allows you dictate (get it??) what your users can access, by defining policies (hah! get it??). You can be as granular as you want and override pretty much everything. The philosophy behind it is to implement sane defaults but be easily overridable as well. You might even call it ...

Continue reading →

jobs and timers in neovim: how to watch your builds fail

Note: this blog post was originally written for the [Subvisual blog][sv-blog]. You can find the original [here][original-post].

If you’re like me (and for your own sake, I truly hope you are not), you
probably tend to have a lot of builds fail. Even worse, if you really are like
me, you spend most of your time in vim.

If that is not the case, you’re in the clear, there’s nothing wrong with you,
feel free to go, end this blog post now, be free, happy, enjoy the sunlight and
the birds and the trees. Life is good.













… Are we, the sadists, all alone now? Cool. Ok, so you use vim a lot and you make builds
fail. Chances are you would like to know when that happens without ever leaving vim. It’s alright. I got you, mate.

Here’s an asciicast of my nvim. Notice how the status bar includes, on the bottom
right, the status of the CI. Notice how it updates...

Continue reading →

you must return here with a shrubbery: the pixels camp quizshow qualifier treasure hunt

This is the story of how I locked myself inside my room for 29 hours and only left after finishing one of the craziest tech wargames/treasure hunt I have ever taken part in.

Screenshot 2019-03-04 at 23.56.16.png


For those of you who don’t know, Pixels Camp has a quiz show.

To get to the quiz show, you have to be tortured get through a very good and awesome and oh so fun, so amazingly fun qualifiers.

The qualifiers run for 4 weeks. Then there’s a week off. Then the 16 top players get to find a partner to violently murder the quizmaster go on stage and make fools of themselves. In order to do that, you get asked questions and then you fail. Invariably. Eventually consistently.

2 editions ago, me and @naps62 failed so hard we won. The next year, we felt a bit more confident and got swept in the first round. As far as logic goes, leave it by the door of the quiz finals and pick it up afterwards. Think you know the...

Continue reading →

stop the overhead, refresh from your editor

tl;dr: I am lazy and I made a script for when I don’t have webpack to refresh my browser for me. I can now refresh it from my editor. It’s available here. This is specific for macOS. Script is explained ahead.

I’m a lazy programmer. If anything requires me to get off my terminal or my vim, I will probably automate it. Like checking the most recent xkcd.

Sometimes I don’t have webpack to refresh my browser for me. This is an issue because it requires me to change focus from the terminal to the browser and then refresh. You may think that automating this is a huge overkill. However, I found that having a shortcut in my editor to do that has significantly decreased the time it takes for me to process everything that happened.

Let’s go through this one step at a time.

First of all, you need to do cmd+tab. You are very likely to code in full screen and in macOS which means you have a cute...

Continue reading →

I always wanted to do a screencast

I always wanted to do a screencast. I was also always afraid to do it.

That being said, it’s called Beware of the Software and the first episode is here:

You can find the code for it here.

The screencast is going to be about… uh… computer stuff, let’s call it that. I can’t promise you it will always be about Elixir or distributed systems. But at least the next batch of episodes will be precisely on that. Distributed systems with Elixir. From there, I’m thinking about going through some CS papers. I also take suggestions if you’re willing to give them.

I’m still learning and experimenting with the format so it is far from perfect… Or maybe even “good”. But you can help me make it good.

I’m asking everyone for feedback. Drastically reducing the number of minutes, showing myself while coding, increasing the font size, tips for the mic and voice. Help has been invaluable. Hit me on...

Continue reading →

mix format in vim from anywhere (or just in umbrella apps)

Spoiler alert: This post is about setting up vim so that you run mix format automatically when you save a file and have it detect the nearest .formatter.exs

I have this weird issue with mix format and umbrella apps.

The issue is that mix format assumes you have a .formatter.exs file in the current directory. If you don’t, it doesn’t look upwards in the file tree. It simply assumes you want to run it with the default config. You can change this behaviour by using the --dot-formatter flag to explicitly point to the formatter file you want to use.

Now, in vim you can also use ale to run mix format on save. If you don’t know ale, take the time to do so. I set up ale to do this precisely by adding the following line to my (n)vim config:

let g:ale_fixers['elixir'] = ['mix_format']

Most of the time you will be good to go with this and you won’t find any more issues.

But when I’m working...

Continue reading →

a look into bloom filters with ruby

Disclaimer: this blog post was originally written and published in the Subvisual blog in April 2016.

I remember one particular class I had. It was late May and, as pretty much every Spring day in Portugal, the sun decided to greet us with a little too much enthusiasm.

The class was about Reliable Distributed Systems, as part of my Distributed Systems & Cryptography master’s program. Distributed Systems students at University of Minho have their classes every Monday in the mythical 0.05 room. A room conveniently located just a couple of meters away from the coffee machine. A room in front of a beautiful, grassy, green patch right in the middle of the campus. A room where the blazing heat caused by 6 straight hours of direct sunlight meets the noisy embrace of dozens of servers in the back. Of course, eager PhD students have millions of tests, queries and transactions to analyse, which...

Continue reading →