Browsers Dev Software Tech Void

Chromium browser extension to auto unload tabs

I created a minimal extension for Chromium browsers to auto unload tabs after a set number of minutes.

I created it because I wanted an extension to reduce my browser RAM usage. I didn’t want to install an extension that would auto-update and bring all sorts of shenanigans (spam, monitoring, ads, etc.). So, I came up with this extension and decided to share it in case someone is looking for something similar.

You can see the details here:

Personal Poetry Quotes

E vou escrever esta história para provar que sou sublime

Fiz de mim o que não soube,
E o que podia fazer de mim não o fiz.
O dominó que vesti era errado.
Conheceram-me logo por quem não era e não desmenti, e perdi-me.
Quando quis tirar a máscara,
Estava pegada à cara.
Quando a tirei e me vi ao espelho,
Já tinha envelhecido.
Estava bêbado, já não sabia vestir o dominó que não tinha tirado.
Deitei fora a máscara e dormi no vestiário
Como um cão tolerado pela gerência por ser inofensivo
E vou escrever esta história para provar que sou sublime.

– Álvaro de Campos

PHP floating point precision

I was attempting to find if the result of a calculation returned a number with any decimals.

So, I was doing something like:

  echo "has decimals";
  echo "doesn't have decimals";
//has decimals

To my surprise the code above returns: ‘has decimals’

If you do the math in any calculator the result of 123.1/0.1=1231 and in fact that is what PHP displays when you do:

echo 123.1/0.1;

But internally PHP stores the value in float and when you do:

echo floor(123.1/0.1);

As I only need to know if the number has any decimals, I ended up doing:

  echo "has decimals";
  echo "doesn't have decimals";

I completely understand why Steve Wozniak never got round to add floating point support on BASIC, no sane person wants to deal with floating points.


Remote Control another Mac on your network

You need to go to the Mac you want to access and under System Preferences->Sharing activate the following:

macOS Sharing Settings

On all this options you can limit the users that can have access.

On the File Sharing option, you can determine what folders can be accessed in the network and by whom.

On Remote Management you will be asked what you want from this list, use option/alt click to select all:

macOS Remote Management Options

Once that is done you can go to the other Mac you want to use and in Finder you should see the Mac on the sidebar under Locations or click Network:

macOS Finder ScreenShare Connect As

You see on the top right options to Share Screen or Connect As. Click Share Screen to get remote control of the other Mac or Connect As to simple browse the folders that you gave permissions on the File Sharing step.

Dev Mac

Change macOS terminal shell to Bash 5

Since macOS Catalina that zsh is the default shell. From what I could understand this was caused by a change in Bash license to GPL after version 3.

So, since version 3 of Bash is pretty old they changed the default to zsh.

Since Homebrew is not yet fully Apple Silicon compatible using Homebrew was not an option. If your Mac runs Intel a simple brew install bash will install a newer version of Bash on /usr/local/bin/bash (if you had Homebrew installed obviously). You can follow the updates for Homebrew compatibility with Apple Silicon here.

This leaves us with installing Bash the good old fashion way:

curl -O
tar xzf bash-5.1.tar.gz
cd bash-5.1
./configure --prefix=/usr/local && make && sudo make install

After that is done, you just need to add Bash to your available shells:

sudo bash -c "echo /usr/local/bin/bash >> /private/etc/shells"

And make Bash the active one:

chsh -s /usr/local/bin/bash

Open a new terminal window or restart your terminal app and check with:

echo "$SHELL"
bash --version