Casting spells in the Vim language

For the past few years I used Vim almost exclusively to become efficient with it. I printed out a cheat sheet which I placed beside my keyboard, had sticky notes on my screen, ran the Vimtutor and watched a bunch of YouTube tutorials.

I wrote code, countless articles and documentation. Me and Vim we were ok till I watched this video and realized I had been living in blissful ignorance, relying on plugins, a 200 lines long .vimrc file that completely changes how Vim works, and bad advise given by people who know nothing about pure VI.

If anything, here starts my new journey into the depths of Vim’s grammar.

Watch the video

Please note that Chris Toomey is ‘flying’ through commands and concepts, which makes it quite difficult to follow for Vim newbs and regular users alike.

Goyo, distraction free writing in Vim

Can’t believe I’ve never mentioned Goyo, one of my most used Vim plugins ever.

It adds a distraction free mode that helps me focus while writing by centering the content and hiding all other elements.

Other nice features are the support of console ANSI-sequences for curl, httpie or wget; HTML for web browsers; or PNG for graphical viewers.

Usage

Toggle Goyo:
:Goyo

Turn on and resize Goyo to the dimension 100x50:
:Goyo 100x50

Turn off Goyo:
:Goyo!

My configuration changes

The plugin works just fine as is, but I did change the text area in my vimrc config file (as seen in the image above), as I find that to be a better fit for my eyes:
let g:goyo_width=100
let g:goyo_height=50

Finally, as piece de resistance, I added a shortcut by bounding the toggle feature to the key g:
map <C-g> :Goyo<CR>

Note

Are you interested in trying Vim? I can highly recommend checking out this link. Trust me, it’s by far not that hard as many people want you to believe. :)

Optimizing Ubuntu 22.04.1 Jammy Jellyfish

These tips are meant for Ubuntu systems, but in general any Debian based distro should be ready to go. Keep in mind that, as everything in life, nothing comes for free. Every optimization has its own pricetag and you must decide how much you are willing to pay for it.

Burning my disk, no more …

The Firefox sessionstore

Sessionstore is responsible for caching which pages were already opened should Firefox suddenly crash. While this is a great feature (you reopen all lost tabs and continue browsing), it causes a lot of writes to your SSD.

Disabling is really easy. Type about:config in de addressbar and press Enter. Click on agree and look for sessionstore. Double-click on browser.sessionstore.interval and change 15000 (15 seconds) to 15000000. Press OK, restart Firefox.

Swappiness (dismiss when having more than 16 Gb RAM)

When working with limited RAM, Ubuntu will aggressively try to free memory to enlarge the caches aka swapping. This again will lead to large quantities of write actions on your SSD which in their turn slow down your system and chip away at the disk’s total lifetime.

To change Ubuntu’s standard swap_tendency weight, open a terminal and query the current swappiness value by typing:

$ cat /proc/sys/vm/swappiness

Probably swappiness wil return a value of 60 which is too high for normal use. Let’s edit the configuration file:

$ gedit admin:///etc/sysctl.conf

The text editor app will open. At the end type:

# Lower swap_tendency
vm.swappiness=25

and save. To activate the new setting, restart the computer.

Faster, faster, performance is key!

Move /tmp to tempfs

Another trick to make a machine run faster is moving /tmp to tmpfs. Temporary files will no longer be placed on the physical disk but in a virtual RAM disk.

Open a terminal and type:

$ sudo cp -v /usr/share/systemd/tmp.mount /etc/systemd/system/
$ sudo systemctl enable tmp.mount

Reboot the computer.

Should you experience issues, you can always undo the change by typing:

$ sudo rm -v /etc/systemd/system/tmp.mount

Activate the zram system kernel function

If your PC has enough memory, zram could be used to replace the /swap.img file altogether.

Enabling zram causes conflicts with zswap, which is activated by default. Disable it by typing the following command in your terminal:

$ echo 0 > /sys/module/zswap/parameters/enabled

Now we can load the zram module:

$ modprobe zram

We should find a device node named /dev/zram0. Let’s allocate a size for it:

$ echo 1024M > /sys/block/zram0/disksize # change size to your liking.

Format that new device as if it was just a normal disk partition we designated for swap:

$ mkswap --label zram0 /dev/zram0
$ swapon -p 100 /dev/zram0

To set zram permanently, once again run gedit and add or change following lines in /etc/default/grub:

GRUB_CMDLINE_LINUX_DEFULT=""
GRUB_CMDLINE_LINUX="zswap.enabled=0"

Save the file and run:

$ update-grub 

to update the bootloader config files.

Now, we make sure the zram module is loaded at boot, and knows the number of devices we need (if we were also using zram for other tmpfs directories like /tmp, we’d have to increase the number):

$ echo "zram" > /etc/modules-load.d/zram.conf
$ echo "options zram num_devices=1" > /etc/modprobe.d/zram.conf

Create a udev rule so that the device node is formatted automatically as swap:

$ sudo -i
$ [sudo] password for **my username**:
$ root@yourmachinename:~# cat > /etc/udev/rules.d/99-zram.rules KERNEL=="zram0", ATTR{disksize}="1024M" RUN="/usr/sbin/mkswap -L zram0 /dev/zram0", TAG+="systemd"

Add the device to /etc/fstab. Additionally, we can give the pri=value as an option to the swap entry:

$ sudo -i
$ [sudo] password for **my username**:
$ root@yourmachinename:~# printf "/dev/zram0\tnone\tswap\tdefaults,pri=100\t0\t0\n" >> /etc/fstab
$ root@yourmachinename:~# tail /etc/fstab # to check the output.

Reboot and verify that the swap device is active:

$ history | tail -n 2
$ swapon

Lower the pressure on the inode cache

If your PC has has enough free RAM available, you can also achieve a little more performance by lowering the tendency on reclaiming the memory which is used for caching of directory and inode objects.

Warning, clearing cache less frequently can impact new processes trying to load (bad_address or address_in_use).

Open your terminal and type:

$ gedit admin:///etc/sysctl.conf

Our text editor opens. Add following lines to the config file:

# Customize cache management
vm.vfs_cache_pressure=50

and save. This setting will be activated after rebooting your computer.

These are just some tips I think are useful. Should something be missing or you have an item that belongs in this list, please let me know by mail.

Ref: Web: zram: Compressed RAM based block devices - Kernel.org.

To-do's when upgrading Ubuntu EOL 20.10 to 22.04.1

Warning for non-experienced users

General recommendation from Canonical is making a backup and re-install your system should you run a non-secure EOL release. Their advice is sound and often proves to be the safest way. So, if you still decide to give my post a try, don’t dare yelling at me when your system goes bonkers. I told you so.

List of commands

$ sudo apt-get update                   
[sudo] password for lgeurts:
# You should see output similar to this.
E: The repository 'http://old-releases.ubuntu.com/ubuntu groovy Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://old-releases.ubuntu.com/ubuntu groovy-updates Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
E: The repository 'http://old-releases.ubuntu.com/ubuntu groovy-security Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.

# Next test, spewing more jibberish.
$ sudo do-release-upgrade
Please install all available updates for your release before upgrading.

# Clean the apt cache.
$ sudo rm -rf /var/lib/apt/lists/*

# Remove old kernels and all automatically installed dependencies that are no longer needed by any package.
$ sudo apt --purge autoremove

# Replace entries in sources files. 
$ sudo sed -i "s/old-releases/archive/g" /etc/apt/sources.list /etc/apt/sources.list.d/*.list

# These 3 echo commands are for making sure you really have the correct entries even the above should have done the trick.
# Can also use any editor you want if that makes you feel more comfy.
$ echo "[deb http://old-releases.ubuntu.com/ubuntu/ groovy main restricted universe multiverse]" | sudo tee -a /etc/apt/sources.list
$ echo "[deb http://old-releases.ubuntu.com/ubuntu/ groovy-updates main restricted universe multiverse]" | sudo tee -a /etc/apt/sources.list
$ echo "[deb http://old-releases.ubuntu.com/ubuntu/ groovy-security main restricted universe multiverse]" | sudo tee -a /etc/apt/sources.list

# Kick it.
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get dist-upgrade # do-release does this again.
$ sudo apt install update-manager-core
$ sudo do-release-upgrade

Final remarks

When finished, clean up (sudo apt autoclean | sudo apt autoremove), check those non apt installed apps, and renew your custom PPAs.

The advantage of serverless computing for CIOs & CFOs

Back in the days, a company had to buy expensive physical servers, set those up somewhere in rooms that were outfitted with peripheral subsystems for cooling, ventilation, fire suppression, etc., and then configure each server in order to run their applications. They also had to hire engineers to maintain these bare-metal servers and troubleshoot any issues that could occur along the way.

This entire process of deploying servers, or any other devices, could take days to complete, and required properly allocating capacity since you can’t dynamically add and remove CPUs, RAM, disks, etc. For those living on the bleeding edge the server-based model often proved to be quite inconvenient, very labor-intensive, and entailing high costs (CAPEX vs OPEX).

Starting 2016, cloud computing ushered the era of on-demand virtual machines that you can use to launch online solutions in a matter of minutes instead days or weeks. A bare-metal server runs the host OS and a virtualization layer which produces tens or hundreds of virtual machines. This pool of virtual machines is sharing the CPU cores, RAM, network bandwidth, and disks that are attached to the host computer.

Since a VM has its own OS, it also has its own kernel which provides for a secure boundary over other VMs running in our host computer. It takes time to launch all of these instances due to the different components that the hypervisor must virtualize and allocate. Moreover, you will have to pay the costs of running your VMs, including idling time when a resource isn’t used at all. And let’s not forget that virtual machines are running a guest operating system that needs updates.

Next step was a smaller virtualized entity called container (Docker, Kubernetes pods). Containers share the physical server’s OS system kernel but do not run a guest OS with its own kernel, unlike a VM. They are primarily used to virtualize and run application libraries and dependencies.

Although a container provides a significantly reduced startup time over a VM, it still has operating costs that you have to cover. The burden of paying active and idle time remains, even if no one is using your containerized application at all.

This is where serverless kicks in. Serverless is in essence a combo of a VM and a container, but in contrast to containerization, serverless uses a small optimized kernel virtualized on top of a kernel-based virtual machine (MicroVM).

Serverless let’s you run code, manage data, even integrate business applications without managing any servers because the CSP will handle these tasks for you.

Speaking about fees, in contrast with VMs and/or containers, serverless services don’t run continuously. A serverless setup will only start when it is invoked, and will afterwards release all computing capacity. This is the reason why serverless architectures are the most cost-effective since you don’t pay for idle time.

Why I decided to -limit- my social presence on the internet, and why I think this will be good for the both of us

A few years ago something totally unexpected happened. It was at the end of the day and I was fully prepared to move behind my laptop at the home office. Instead I decided to do something else, not waste my evening on what became a daily routine; tweeting, liking posts on my LinkedIn, uploading fresh pictures on Instagram, answering Slack messages, scouring internet for anything interesting to read and learn.

Being away from my computer felt like something special. I started living regular life, spending my free time as any other guy would do, watching movies together with J. (girlfriend), playing with our dogs on the beach, going out with friends.

I could have spent time behind this blog as well, but I chose not to. I was able to get a clear head, think about how I used my computer, and phone, how I perhaps consumed and processed more information than I really wanted to, and what the long term effects of that do to a person.

In periods I can burn a lot of time tinkering with all kinds of hardware, Linux and open source software!! I’m that introvert perfectionist with a slight touch of OCD who gets a bit too obsessed about particular things and who can’t let anything go before he’s really done with it > In the past this behavior actually led to a few years of unhealthy multiplayer gaming (CS:GO), so it’s not something I take lightly.

In the back of my head I already knew I had to take counter-measures to prevent falling back in the same trap, and letting my mind go on the loose again.

So, first task, I started with disposing old hard-disks, floppy’s, zipdrives, network cables, a Pentium Pro desktop, even an old SPARCstation. All that awesome stuff you usually gather when working years in IT. Sometimes it was a painful activity because you feel bonded with objects that link to good memories from the past.

Anyways, this was a big step in de-cluttering my life and it has made some huge positive improvements on my productivity and what I call my hyper-focus.

I also realized that while my workflow had improved, I did things the younger me would never ever have approved.

As an example, one of those things was leaving an application open and letting it run in the background, even when I was not there. I know this sounds rather silly but closing an application when I don’t use it does help focus on what I’m doing. For that reason, I replaced the OS on two of my Lenovo workstations with vanilla Debian & I3 WM. (See guys? Told you this post was not exclusively about scoring points on LinuxPorn!)

The third step. I became picky about what channels to subscribe to, and made an agreement that at a certain time in the evening I’d stop, no matter how much my desire to keep hanging on (if I don’t I have to take her out to a fancy diner). After some time I found the everlasting craving for more was gone, and I truly enjoyed the nothingness, loved all that time I now had on my hands more than anything.

I eventually launched Newsboat, and closed it after a quick glance. Then fired up Vim and removed about 80% of the feeds. Most were other we(b)logs, a variety of tech and/or open source related projects and some news sites. The first was CNN International that posts —multiple times per day— about everything from movie trailers, science and tech, to politics. While this was pretty good at giving me the latest highlights it took more time than what it was worth to keep up with.

We both don’t like TV channels because of the irritating commercials filled with products we are never going to buy. Thus Netflix was the only agreeable option.

Last week I took the last step and told my customer(s) I would take 5 days off for studies, no matter what outcome. Yes, every unproductive day is money lost, but at the end those certifications are a long-term investment that will pay for itself.

Update d.d. 15/11/21: Bought a Garmin Fenix 6 Smartwatch and Aeku M5 phone after reading this blog post. Let’s see if they can replace my BlackBerry Android.

Something to think about. Since we have a limited quota of time in this world, why not rather spend that on things and people we find fun, that bring joy in our life and that keep us productive?

So. I hope you will understand and don’t feel offended if I can’t follow on social media; it’s nothing personal. It’s for the good of me, and hopefully you.