How to Write Good Unit Tests

It is probable that you have encountered numerous tests, or perhaps none at all (though this scenario is hopefully uncommon). If you belong to the former group, you may have experienced the laborious process of comprehending and constructing tests, which is painful for the eyes and patience. Despite the challenges, investing effort into test creation yields considerable benefits in the long term. Consider a scenario where you aim to enhance your codebase.

Using JWT for authentication in Gin

Authentication is a crucial part of any web application. It allows us to verify the identity of users and ensure that only authorized users can access sensitive information. In this post, we will learn how to use JSON Web Tokens (JWT) for authentication in the Gin framework for Go. The Gin framework is a popular web framework for Go that makes it easy to build fast and scalable web applications. It provides a simple and elegant API that makes it easy to handle HTTP requests and responses.

Quick Mock Server

Are you in a need of a quick mock server? One simple solution for Linux/Mac/BSD users is to employ an existing tool, nc. It exists in most distros and it’s very easy to use. #!/bin/bash if [ "$#" -ne "1" ]; then echo "usage: ./mock_server.sh <port>" exit 1 fi trap "{ exit 0; }" SIGINT SIGTERM SIGKILL PORT="$1" function make_response() { read -r response echo -e "HTTP/1.1 200 OK\r\n\r\n${response}" } while true ; do dd if=/dev/zero count=10000 make_response | nc -l "$PORT" done Save this in a file called mock_server.

Favourite VSCode Extensions

I’ve been using VSCode for about 3 years now, it’s not the best editor out there, but I like it. I try to keep it minimal with only a few extensions for executing certain things quickly and easily. Here’s a list of the extensions I use: C# - I’ve been writing C# over 5 years now, the first years I used Visual Studio, then vscode came out and I switched.

Learning a Musical Instrument

About 2 years ago I decided to learn a musical instrument. I have always been interested in string based instruments so I decided to learn how to play guitar. First, I tried out a friend’s guitar and then I realized that I really liked it, so I bought a cheap acoustic guitar. My knowledge about playinng musical instruments was very limited, I knew very basic things from school most of which have faded over time.

Editors Choice

I’ve used a few editors over time, Emacs, Atom, Sublime, Vim, VSCode, IntelliJ, Visual Studio and Xcode. From those I’ve used professionally Xcode, Emacs, Visual Studio, vim, vscode and Intellij. I have tried to use atom and sublime, but they never really stack. Here is a small review of what I like and what I don’t for each one of them. FYI my favourite 2 are vim and vscode. Atom didn’t really click for me, I’ve met people that liked it, but I never managed to like it.

Go Patterns?

I came across a repository on github that consolidated simple examples exhibiting design patterns in Go. In the beginning I thought that was a great resource, but after a while I got a bit confused. You will find a list of patterns like creational, structural, behavioural, synchronization, concurrency, messaging, stability, profiling, idioms and anti-patterns. You find patterns like Abstract Factory, Singleton, Bridge, Decorator, Mutex, Semaphore, Coroutines, and many more. My favourites are synchronization and concurrency.