Categories
ActivityPub Fediverse Void

Composable with microservices in the backend

I was listening to the Decoder podcast, where Jay Graber (the CEO of Bluesky) was interviewed, and it reminded me of a mental trap that I often fall into. It’s much better now because I detect it a mile away and successfully stop myself fast.

When I start a new project, I devise a grand plan. It all looks perfect in my head, like magic. Then, I deconstruct that grand plan into reality. I call this process first principles reversal. I start stacking ideas on top of ideas, forcing squares into circles until I achieve a Frankensteinian creation.

During this process, I am in awe of myself, in a state of absolute arousal. I’m a genius. Then, when I attempt to build my vision, I realize how complex it will become. Little by little, things start to not make sense, and in the angst of moving forward, I keep adjusting course and forcing pieces of the puzzle into places they do not belong.

After some time, I completely forgot what I was trying to achieve in the first place and created something that makes little sense because there are much simpler solutions that basically accomplish the same thing.

I am not saying saying that this is the case with Jay Graber. I don’t know Jay, and I have never used Bluesky or read through Bluesky’s documentation (who in their right mind would want to read that). Plus, I don’t believe Jay would be hired as CEO of a multimillion-dollar project if that were the case. I am just sharing that I enjoyed listening to the podcast because it reminded me how much better I feel when I stop myself from this mental trap.

Categories
Fediverse

Fediverse: what can we do now that we couldn’t before?

After listening to the DotSocial Podcast episode “Moving the Fediverse Forward at FediForum and Beyond, with Johannes Ernst of Dazzle Labs“, a question stuck with me and I think is very relevant: What can we do now that the Fediverse exists that we couldn’t before?

One example Johannes Ernst provides is someone trying to make money with Linux instead of considering what it allows since it’s free and open.

A similar situation happens with the Fediverse. I don’t believe the aim should be “How can I make money with this” (I have seen people wondering that question time and again) but “What can one do that wouldn’t be possible before”.

Categories
Dev

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:

$num=123.1/0.1;
if(floor($num)!=$num){
  echo "has decimals";
}else{
  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;
//1231

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

echo floor(123.1/0.1);
//1230

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

$num=round(123.1/0.1,1);
if(floor($num)!=$num){
  echo "has decimals";
}else{
  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.

Categories
Mac

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.

Categories
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 https://ftp.gnu.org/gnu/bash/bash-5.1.tar.gz
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