Testing Tips: Avoid sleep in tests
Hi 👋, In this article I wanna show a testing tip that I’ve recently learned myself by reading Software Engineering at Google: Lessons Learned from Programming Over Time. The technique improved the way I write unit tests. When I’m writing bigger unit tests, I have execute something in the background, like for example publishing a message to a message broker, wait for the message to be published and then consume it to test that what I published is correct....
The Hash Set
Introduction A hash set is a data structure that allows storing elements inside a set using a hash function. The set is a data structure that offers efficient access to its elements and does not allow duplicates. The uniqueness of an element in the hash set is determined by the hash function, in this implementation hash collisions are not handled. If the hash of “a” is 123 and the hash of “b” is 123 as well then we consider “a” and “b” to have a hash collision and if “a” is already present in the set adding “b” has no effect....
Changing Microk8s' default hostpath addon storage location
Hello everyone, This is a short guide on how to change Microk8s’ default storage path for the hostpath addon. First, ensure the addon is enabled: microk8s enable hostpath-storage Then create a new directory in which you want to store volumes created in the Microk8s instance. mkdir -p /var/microk8s-volumes Then create and apply the storage class yaml file: kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: custom-storageclass provisioner: microk8s.io/hostpath reclaimPolicy: Retain parameters: pvDir: /var/microk8s-volumes volumeBindingMode: WaitForFirstConsumer To change the default storage class for Microk8s you need to run these commands:...
Ranking: BM25+
Introduction The BM25+ is a ranking algorithm used to rank text documents based on a relevance score. It is used in search engines to determine which documents are the most relevant given a terms query. The algorithm implemented is based on the Improvements to BM25 and Language Models Examined paper. Implementation An index can be used to index the terms and the documents in which the terms occur: [term: apples] - doc1, doc2, doc3 [term: grapes] - doc2, doc4 When a user queries using the apples term then doc1, doc2 and doc3 is returned....
The Linked List
Introduction A linked list is a fundamental data structure which consists of Nodes that are connected to each other. Other variations are: Double linked list Circular linked list (circular buffer) The Singly Linked List To visualize the data structure, if you want to store two integers 10 and 20 you will have a 2 node linked list that will have: [Node 1, Value 10] -> [Node 2, Value: 20] -> [null]...
Cancellation Token Pattern in Python
Hello! 👋 The Cancellation Token Pattern article is a pattern inspired by C#’s CancellationToken struct and Golang’s context package. The main idea of the pattern is to allow the user of an API to cancel its operations, but in order for this pattern to work, the API must be written with the cancellation token pattern in mind. To use the pattern, you need a class that represents a cancellation token. Here’s my simple version:...
How to install HP LaserJet 107a Drivers on Linux
Hello everyone! 👋 I’ve recently installed Fedora on my main PC and I wanted to write this post to serve me as a memo on how to install the HP LaserJet 107 printer driver. The driver should also be compatible with the following products and generally HP’s LaserJet 100 printer series. HP LaserJet 107a HP LaserJet 105a HP LaserJet 103a Installing the Drivers Installing the drivers requires Python3 available on your system if I remember correctly, it should be already available on Fedora and Ubuntu....
My experience with BambuLab A1 and 3D printing
Introduction Hello everyone, 👋 This is my first post of 2024, and ever since I’ve started the blog in ~2018, I’ve had engineering Programming, Cloud and Engineering! 👨🔬; in the blog’s description. 😄 I made a few posts related to “engineering” other than Software Engineering. In 2018, I was still studying computer science and engineering at UPT, and I was fascinated by the Electrical Engineering courses. I figured that I’d write blog posts about circuit analysis techniques such as Ohm’s Law, Thévenin’s Theorem, Mesh Analysis, and so on....
Implementing cat with Kotlin Native
Introduction Hello! 👋 In this article we’ll implement the cat command utility which is used in many Unix like systems like Linux and macOS. To implement it, we’ll use kotlin and to drop the Java Virtual Machine (JVM). We’ll build a binary directly with Kotlin Native. In the end, we’ll get an executable that we can simply run on our Linux or macOS box. What is cat? The catutility which has purpose of concatenating files....
Learning Kotlin
Introduction Hello everyone! 👋 The year of 2023 has come closely to an end, and I want to write a short article about my experience with Kotlin and what other programming languages I’ve tried this year. Outside work, I like experimenting with new programming languages and technologies. I don’t usually build side projects in the languages and frameworks that I use full time at work because I don’t find it fun....