IRC server rejects custom quit message: solution

I was working on my IRC bot recently when I stumbled upon a confusing problem while trying to add a graceful shutdown. The idea is that when a process receives a request to terminate itself (SIGTERM), it should send a QUIT command with some text, rather than disappearing like some barbarian.

Like this:

<= QUIT :bye
=> :poring-dev!~poring@user/poring QUIT :Quit: bye

Alas, the IRC server completely ignored my message, replacing it with a generic "Client Quit" text:

<= QUIT :bye
=> :poring-dev!~poring@user/poring QUIT :Client Quit

I spent about two hours trying different things and debugging my code to no avail. I knew the command I was sending was valid and that Libera Chat supported this feature.

What I didn't know is that there's apparently a type of spam attack that utilizes quit messages.

Read more...

Function overloading in TypeScript

As more and more companies migrate from Java to JavaScript for UI and API testing, I decided to study it too. After all, even this blog is powered by React. One of the features I sometimes used in Java is function overloading, which I thought wasn't possible in JavaScript. However, as I've recently learned, TypeScript adds this functionality. Well, kind of.

JavaScript code on a screen

Photo by Pixabay

Read more...

Trie data structure

I recently learned about a trie data structure. While it may not be as widespread as arrays, hash tables, linked lists, or binary trees, there are applications where it excels. The main advantage of a trie is that you can search in constant time, regardless of how many elements it contains. This makes tries useful for autocomplete systems, spell checkers, dictionaries, and similar applications.

A tree in black and white

Read more...

Lombok compilation error: cannot find symbol

I was working on the service that powers this blog when I stumbled upon an odd issue.

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /app/service/src/main/java/ee/fakeplastictrees/blog/service/user/model/UserExceptionFactory.java:[8,1] cannot find symbol
  symbol:   static withData
  location: class ee.fakeplastictrees.blog.service.core.exceiption.PublicExceptionFactory

There were 52 more errors like this in different classes. I hadn't changed the Java version or any dependencies since the previous build. Moreover, most of the files that reported failures had absolutely no changes in them. I was able to build this code not long ago! It was as if lombok had suddenly stopped working for no obvious reason. Nothing in maven's log pointed to the root cause.

A confused man screaming at his laptop

Photo: not exactly me, but the same energy.

Search results were misleading and suggested that my project was configured incorrectly, even though it had worked in the exact same environment just a couple of weeks ago. Eventually, I found the answer!

Read more...

Secret Handshake: Solving an exercise using bitwise operators and comparing performance

A couple of days ago, I took on an interesting task on Exercism. You can find the full description here. The goal is to create a function that takes a number between 1 and 31 and converts it to a list of actions. The sequence is defined by the five rightmost digits of the number when converted to binary. If you're unfamiliar with the binary system, I recommend reading this explanation first.

In this post, I'll discuss how I gradually improved my initial solution and share some interesting findings about the performance of different approaches.

Read more...