https://github.com/ahmadtheswe.png

Generate UUID in PostgreSQL

UUID is an important data type that we can utilize in relational database (RDS). There are two common ways to generate UUIDs in PostgreSQL: using the uuid-ossp extension or the pgcrypto extension. In this article, we will discuss how to generate UUIDs using both pgcrypto.

To use this function, make sure that the pgcrypto extension is enabled in your database. You can do this by running this command:

CREATE EXTENSION IF NOT EXISTS "pgcrypto";

Let’s say, you have a table named candidate with a UUID column named id. You can create the table like this:

How to Export & Import Docker Image

We can always pull docker images from docker registry. But, sometimes we need to share our images manually. In this post, I will share you how to import and export docker images.

Export Docker Image

Let say we have these two docker images in my local docker

$ docker images
REPOSITORY    TAG       IMAGE ID       CREATED         SIZE
mysql         5.7       547b3c3c15a9   4 weeks ago     501MB
postgres      12        d480c196f9b0   3 months ago    405MB

We want to export postgres docker image. To do that, we can do that using docker export command like this :

Move Your WSL2 to Another Drive

Windows Subsystem Linux (WSL) is one of the most useful modern tools for software development, in my opinion. Since Windows offered this feature, we don’t need to use fully virtualized Linux (using VMWare or VirtualBox) but can just use WSL that fully integrated with our Windows machine.

The downside of WSL is we can’t choose the directory to install it. I will installed by default in our system drive (C drive). This maybe not a problem if we allocate huge amount of storage for our C drive. But, the case is we commonly not allocate much storage for our system drive because we thought we will only use this drive to install essential things.

Configure GitHub Actions Unit Test for Java Project (Plus code coverage with Jacoco)

In this short article, we will talk about how to set up GitHub Actions for Java projects (such as Spring Boot projects). We also integrate Jacoco to produce code coverage information.

Configure Jacoco

We must set up Jacoco in our build.gradle file. The script is like this :

plugins {
    /* Other plugins */
    id 'jacoco'
}

/* Other configurations and dependencies */

test {
    testLogging {
        events "passed", "failed", "skipped"
    }
    finalizedBy jacocoTestReport
}

jacoco {
    toolVersion = "0.8.9"
}

jacocoTestReport {
    dependsOn test // tests are required to run before generating the report
    reports {
        xml.required = false
        csv.required = true
        html.outputLocation = layout.buildDirectory.dir('jacocoHtml')
    }
}

Here are some explanations :

Connecting Spring Boot Microservices With Kafka

There are many available ways to connect microservices. But, one of the most reliable ways is using message queue protocol. Apache Kafka is one of many message queue systems that you can use freely and it offers so many features that we can customize based on our need.

In this blog post, I will share with you how to connect two Spring Boot microservices using Apache Kafka.

Project Architecture

/images/connecting-spring-boot-microservices-with-kafka/spring-boot-kafka-1.webp

Solid Principles in a Nutshell

I think one of the most important sets of principles that should be understood by all software engineers is SOLID principles (not the only one, but the most basic). By understanding this principle, we assume that we’ll be able to deliver good, cleaner and maintainable codes.

SOLID is an acronym that stands for Single Responsibility, Open-Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion. It’s a best practice for developing a program using object-oriented programming.