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. ...
Introduction to MCP Servers and writing one in Python
The picture of this article is the output of Claude, using a local MCP server that gives it the output of the ls -l command on a given path. Notice how the LLM likes to praise me, exaggerating a bit, In my opinion this is just a way to keep your users hooked on their product. Who doesn’t like to be praised and approved with everything they say, right? :D ...
Authenticating a generic client with Spring Security OAuth2 Client
Hello everyone 👋, I recently worked on a small side project written in Java with the Spring Framework and I had difficulties authenticating to an external OAuth2 client using spring security. The solution to my problem was clear after I perused the code and documentation of the Spring OAuth Client package. I thought that I’ll have to write custom classes to configure it for my specific need but it turned out that my issues was strictly configuration related. ...
Apache Kafka: How-to set offsets to a fixed time
Hello 👋, This is a short article about setting offsets in Apache Kafka for a consumer group. Normally, to reset offsets in Kafka you need to use the kafka-consumer-groups.sh tool, this means downloading the zip archive with Kafka’s source code and setting up the Java SDK. All Kafka’s tools are dependent on Java and this isn’t that nice or developer friendly… Sometimes getting Java correctly and getting the tools to run they don’t work 🤷🏻♂️. Either the tool versions are incompatible with the Kafka version on the server or the command executes successfully but it doesn’t seem to do anything… ...
Running a PHP Application inside a Container
Hello 👋, In this month’s blog post I’ll show you how to run a PHP Application inside a container. I’m quite a fan of online forums and the majority of forum software is written in PHP. To evaluate them quickly I wanted the ability to be able to run and install then locally. I’ve come up with this docker-compose file 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 services: nginx: build: context: ./ dockerfile: nginx.dockerfile ports: - "8080:80" # change port 10080 to any other port volumes: - ./config/nginx/conf.d:/etc/nginx/conf.d:z - ./.data/nginx:/var/log/nginx:z - application:/var/www/html:z - composer:/root/.composer:z php: build: context: ./ dockerfile: php83.dockerfile volumes: - ./config/php.ini:/usr/local/etc/php/php.ini:z - application:/var/www/html:z - composer:/root/.composer:z database: image: "postgres:latest" ports: - 15432:5432 environment: POSTGRES_PASSWORD: denis POSTGRES_USER: batman volumes: - ./.data/postgres/:/var/lib/postgresql/data/:z maria: image: mariadb restart: always ports: - 13306:3306 environment: MARIADB_ROOT_PASSWORD: example volumes: - ./.data/maria/:/var/lib/mysql:z volumes: composer: application: driver: local driver_opts: type: none device: ./application o: bind All you need to do is place the PHP application inside the ./application directory and run: ...
Anubis: Protection against LLMs and Scrapers
Hello everyone! 👋 In this blog post we’re exploring the option of self hosting Anubis. Anubis is a software that defends and protects your services from AI Scrapers and LLMs. Since AI started to get popular more and more scrappers started appearing. They grab your data in order to use it to train their AIs while ignoring any rules such as robots.txt, licenses and intellectual property laws. Meta even torrented 82TB of books to train their AI. ...
Accessing the host address from inside a container
Hello everyone! 👋 This post is about accessing the host URL from inside a Podman (or Docker) container and how to avoid a mistake I made when setting up containers. If you have a service running inside a container, and you would like to access the host URL you will have to use a special address called the host-gateway address. Other options include hard-coding the host ip address. You can use any of the following URLs when you want to access the host from inside a container: ...
How to zip and unzip a directory in Go
Hello everyone! 👋 I wanted to write a short article about zipping and unzipping a directory in Golang. The answer is quite simple, you can use the AddFS to add the entire directory to the zip file like so: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 package main import ( "archive/zip" "log/slog" "os" ) func main() { file, err := os.OpenFile("my_contents.zip", os.O_CREATE|os.O_WRONLY, 0644) if err != nil { slog.Error("failed to open file", "error", err) } writer := zip.NewWriter(file) err = writer.AddFS(os.DirFS("/home/denis/Pictures/not_in_train/zip_test")) if err != nil { slog.Error("failed to write files to zip archive", "error", err) } err = writer.Close() if err != nil { slog.Error("failed to close zip writer", "error", err) } } The AddFS will walk through the directory and add all the files to the zip file. ...
How to use RocksDB with Go
Hello everyone! 👋 I’ve had to work with RocksDB recently and in order to use it from Golang I had to jump a few hops before getting it to work properly. This article will show you how to compile a Go program and link it with RocksDB using CGO. We will use the grocksdb library. What is RocksDB RocksDB is an embedded key-value store developed by Meta. It can be used as a database engine by MySQL, MongoDB, Apache Cassandra and others. ...
Self Hosting a Calendar and Contacts server, Baïkal
Hello everyone! 👋 Welcome to another self-host article! This month we’re hosting a CalDAV and CardDAV server. Baïkal, the lightweight CalDAV+CardDAV server. We’re going to host it in a Podman container on a Fedora server. https://sabre.io/baikal/ Why Baïkal Baïkal has multi-user support and allows you to create users from the administration interface and each user has his own Calendars and Contacts address books. It can be configured with a SQLite database or PostgrsSQL. ...