Posts

AWS VPN Client on a guest VM

Image
The AWS VPN Client for Linux ( https://docs.aws.amazon.com/vpn/latest/clientvpn-user/client-vpn-connect-linux.html ) at the time of writing (Nov 26, 2023) is only supported on Ubuntu and the latest Ubuntu version supported is 20.04 LTS. This version of Ubuntu is nearly 4 years old and people have been having problems with the client - there have been numerous complaints on the forums by people trying to get it working on newer Ubuntu versions, for example https://repost.aws/questions/QUNJeF_ja_Suykous7EvfX5Q/aws-client-vpn-on-ubuntu-22-04 . While it is possible to get the VPN client working on Ubuntu 22.04, there is a caveat - the client uses an outdated libssl version (libssl1) and Ubuntu 22.04 comes with a libssl3, which makes the client error out.  The workaround is manual installation of libssl1, replacing libssl3. If one uses another distro or simply does not want to downgrade libssl just for the AWS VPN client, one solution is to run the client on guest installation of Ubuntu

Go error handling and stack traces voted as the biggest challenge

Image
The results of Go Developer Survey 2022 Q2 came out and showed that error handling and working with stack traces in Go pose the biggest challenge to respondents: "Error handling remains a challenge. Following the release of generics, respondents' top challenge when working with Go shifted to error handling." The answer distribution is as below (click): In this blog post I would like to focus on error handling and try to explain in detail how, in my view, error handling in Go is or should be done. Ready? Let's begin. Error handling in Go explained A function or a method in Go returns a non-nil error if and only if it encounters an error during execution. The caller checks for the returned error value - if it is not nil, it either handles it or returns an error of its own. I hope this blog post makes Go error handling better understood and appreciated.  

Go application layering

Several months ago I built a web service in go which, inspired by the blog post "Packages as layers, not groups" , I made strictly layered. Not to make a rule out of it and not saying that this is what packages are, I think using packages as layers for different building blocks of an application (RPC, business logic, storage, cache, auth, etc) helps a lot in structuring an application. There was another blog post that talked about using separate structs for the same model (or data transfer object) in each microservice or layer, as opposed to re-using the same struct from a single library and so introducing a dependency everywhere. I cannot find it any more but I loved the idea and I used it in my app as well. I wanted to put these two ideas out there and so I changed all the code from the original app and made it a dumb key-value storage REST API. The project is on GitHub: https://github.com/varfrog/layers . Comments are welcome!

Building collections: Immutable Clojure vs mutable OOP

In traditional OOP, if you have some collection A and based on the elements of A you need to build another collection B, a common approach is instantiating B as an empty collection, iterating over A and at each iteration appending a new element to B. When working with Clojure I had to invite a new way of thinking about this sort of task. To demonstrate the two approaches, I've thrown up equivalent solutions to the same task in both PHP and Clojure. The task defines a map whose keys are years and values are structures which contain 2 integers (liabilities and equity). The goal is to calculate assets (the sum of liabilities and equity) of each year and just put them in another structure: an array in PHP and a list in Clojure. The original structure, of course, needs to remain intact. The following is the version in PHP which loops through one structure and mutates another. Now, the interesting part. In Clojure, as data structure are immutable you cannot instantiate an empty s

Preserving test cases when removing the tested classes

In my - most likely - final days of PHP development, I thought about writing something related to PHP. I had this topic on my todo list for some time. It is about testing. It is a strategy, actually 2 of them, that I often used to cover my arse when refactoring code. I have talked about it verbally but, in my opinion, writing information down is always a good thing. The whole idea is described in  https://github.com/varfrog/testing-topic . The content below is a copy-paste of the README from Github. Scenario There is a class  \App\Example1\Formatter  with a single public method  format(string) . This method receives a string, reverses the sequence if its words, and in the resulting set of words appends an increasing natural number to each word. For example: Input Output a b c c1 b2 a3 foo bar baz baz1 bar2 foo3 This method is unit-tested, see  \App\Example1\Tests\Unit\FormatterTest . It tests that the method correctly transforms the text as in the table above: # FormatterTestCase self

Proper thickness of gymnastics rings to learn the false grip

Image
I am training to do a proper muscle-up on gymnastics rings. A muscle-up has 3 components: a false grip ( https://www.google.com/search?q=false%20grip ) a pull-up a dip I do have the strength to do pull-ups and dips on rings separately. However, in a muscle-up you join two movements together - you transition from a pull-up to a dip. For the transition to be possible you have to hold the rings with a false grip, as it shortens the distance from your chest to the rings. For quite some time I was having big trouble with the false grip. I could not support my full body weight with a false grip, not to mention pulling myself up. It hurt the spot that touched the ring, at the hand joint area. Pushing through pain is an idiotic approach to exercise, and I did not want an injury. I did some research on the web and decided to try rings with a greater diameter. The rings I was having trouble with were  28 mm  in diameter, and they were made of plastic. I bought new wooden ones with a diameter of 

Database Deadlocks

Image
I have had to explain database deadlocks several times and I had this old code project to produce a database deadlock and I had the following scheme for explanation: However it was a bit too little or too confusing to get the idea through sometimes, so I retired the project and recreated a new one on the newest Symfony. It runs on Docker and produces a deadlock by running just one command. It’s on Github:  https://github.com/varfrog/deadlock-symfony . The main point is that a deadlock happens when the same records are being locked by different processes in a different sequence. More on this in the README of the project.