Git Fundamentals

It is not uncommon to meet fellow developers who are able to use git, we are ones ourselves. Most of us are able to commit, push, resolve conflicts, etc. However, how many would be still comfortable to use it when things deviate from a normal workflow? E.g., hotfix, recover deleted branch, fixing our local branch if the remote is squashed, detached HEAD, etc.

These are all symptoms of learning git usage through surface level commands without understanding git itself. I was in the same boat, and many developers I spoke to share the same experience, especially the new ones. Hopefully, this article will give us an improved understanding about git to be able to leverage it more.

Read more →

KDE in wsl2

Cheers 🍻 to those who owns a surface pro x and tries to do some development work on it.

By now, most is probably regretting why they didn’t buy a normal non-ARM surface pro or just an M1. Although wsl2 is very nice, it is not really mature enough. It has some nasty bugs such as slow network and slow filesystem, which leads to a big pain when development code is running on WSL while being accessed from a browser or IDE in windows. This pain explodes further by the fact that almost no IDE except VS Code runs on the windows ARM platform.

Read more →

JavaScript, filling an array with empty array.

I love JavaScript, however very often, it doesn’t love me back.

const dataBuffers = new Array(4);
dataBuffers.fill([]);

for (let i = 0; i < 4; i += 1) {
  dataBuffers[i].push(7);
}

console.log(JSON.stringify(dataBuffers));
// guess what is the answer?

If you guess the answer would be [[7],[7],[7],[7]], then think again.

The problem is that dataBuffers.fill([]) will create you a single array, and fills the dataBuffers with the reference of the array. It is actually pretty clear if you have done JavaScript or any language long enough, but one might be stuck with the impression that the dataBuffers is filled with an empty array. In actuality, they all reference to the single same array, which means, the result of the above is.

Read more →

Adding New Currency in Java 8

If you are using the java.lang.Currency as part of your entity, most likely you are already regretting it now. Most of the time, a currency is a three letter word, and we don’t need the logic to be bundled in there. Keeping things simple and mapping these currencies as a String or own custom class is the way to go.

For people who did use java.lang.Currency, the pain will arrive when a country changed its currency or added a new one. As example, Belarus changed its currency from BYR to BYN at July 1st, 2016. If you are using java.lang.Currency, you prolly already know by now that Currency.getInstance("BYN") will throw you an exception. Most likely you have also google around, and most likely again, you will stumble upon this or this. It’s basically telling you that there is this new feature in java 7, which lets you overwrite the currency. You will happily overwrite BYR to BYN, and now it starts working. This happyness doesn’t last long as you realize that now that you support BYN, but not BYR anymore. You might also stumble upon some pages which write that we can’t support both currency at the same time.

Read more →

To Lead, and to Serve

Around last week, I was listening to Rev. Stephen Tong’s Masterclass (basically like a Seminar). He said something which really struck me deeply. It’s something along this line:

Woe to you who wants to become a leader because you want people to serve you! Woe to you if you want to be a leader because you think you will have many people helping you!

A leader is the one who serves all his people! He should be the one who works the hardest! The one with the heaviest responsibility!

Read more →

Event Driven Architecture

Why do we need it?

In the early stages of the development, event driven architecture is not needed since everything is still small and could still be contained in one place. Unfortunately, as the system grows bigger and bigger, putting everything in one place is not a very good way to scale (a.k.a monolith). The logic of the whole system will also keep increasing in complexity, and eventually there will arise the need to separate the giant system into domains.

Read more →

Spring Boot Actuator + Dropwizard + Cloudwatch

Exporting spring boot metrics to cloudwatch may not be that straightforward. Since I’ve done that for my project, I will show how we can do it easily with the help of a couple of libraries.

First, spring boot is using its own metrics mechanism. The first step to do that is to swap it with dropwizard’s metrics library which is more powerful and has more feature. Thankfully, the actuator has complete support for the library from what it’s written in the documentation. Spring will just swap its interface to use the implementation which wraps the dropwizard metrics.

Read more →

Docker and (Console) Logs Problem

Anyone who used docker before and care about quality will have to deal with the logs problem. As we all know, docker runs in a container, and if we don’t handle the logs in a special way, the logs will be lost when the container is restarted.

In order to deal with this, usually we will map the logs folder of our application to the parent host of the container, so that the logs don’t get lost when the container is restarted or changed.

Read more →

Broken Docker in Debian Jessie

So after a few dist-upgrades, docker is not running anymore in my debian Jessie. A quick run of sudo service docker status shows me:

● docker.service - Docker Application Container Engine
   Loaded: loaded (/lib/systemd/system/docker.service; disabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2015-09-02 00:03:18 CEST; 8min ago
     Docs: https://docs.docker.com
  Process: 22770 ExecStart=/usr/bin/docker -d -H fd:// $DOCKER_OPTS (code=exited, status=1/FAILURE)
 Main PID: 22770 (code=exited, status=1/FAILURE)

Sep 02 00:03:18 rowanto-mdeb systemd[1]: Started Docker Application Container Engine.
Sep 02 00:03:18 rowanto-mdeb docker[22770]: time="2015-09-02T00:03:18.434820725+02:00" level=error msg="[graphdriver] prior storage driver \"aufs\" failed: driver not supported"
Sep 02 00:03:18 rowanto-mdeb docker[22770]: time="2015-09-02T00:03:18.434912173+02:00" level=fatal msg="Error starting daemon: error initializing graphdriver: driver not supported"
Sep 02 00:03:18 rowanto-mdeb systemd[1]: docker.service: Main process exited, code=exited, status=1/FAILURE
Sep 02 00:03:18 rowanto-mdeb systemd[1]: docker.service: Unit entered failed state.
Sep 02 00:03:18 rowanto-mdeb systemd[1]: docker.service: Failed with result 'exit-code'.

Ops, problem with aufs. A quick fix would be to delete it. You might lose some data, so please do it with care.

Read more →

KDE is fully broken in Debian Jessie/Testing

I use Debian Jessie, and I am the type who do this command frequently:

sudo apt-get update && sudo apt-get dist-upgrade

Now I am suffering from the consequences. The desktop is completely broken. I googled around, and there was nothing. So I thought something in my laptop is broken at first.

Well, if you are a long enough linux user, this kind of stuff is kind of normal. It always happens once in a blue moon. It happened once when I was upgrading Fedora. It happened once when Debian removed ati driver. This stuff is normal, it’s also Debian Testing anyway. One just need to keep calm and fix the problem.

Read more →