Java Check for Null References


In Java we can check for null pointer references using below approaches. If you ask me why we have to do this, is to avoid NullPointerException. Traditional way public static List<Integer> getPrices (List<Integer> allPrices) { if (allPrices == null) { return Collections.EMPTY_LIST; } } Use declarative approach Before directly jumping into this, I want to share the methods we have to check for null referencs Objects.isNull() Objects.nonNull() These methods we use in functional approach.…
Read more ⟶

Troubleshooting Unable to Convert Binlog Coordinate


At work I got assigned to a bug, the MySQL Replication setup failing with error Unable to convert binlog coordinate (mysql-binlog.000002:430106631) to GTID when we tried to fetch the GTID using below command. MariaDB [(none)]> SELECT BINLOG_GTID_POS('mysql-binlog.000002', 430106631) AS gtid; +------+ | gtid | +------+ | NULL | +------+ 1 row in set (0.002 sec) MariaDB [(none)]> After investing time and effort, I thought like, what’s the gaurentee that 430106631 is presented in the mysql-binlog.…
Read more ⟶

Install Suckless Dwm in Debian


I was trying to install dwm in Debian 12 which is already having XFCE Desktop. From the suckless website I cloned the dwm repo git clone git://git.suckless.org/dwm And the changed to dwm to compile Fixing missing Xlib.h error raja@debian ~/s/dwm (master)> make cp config.def.h config.h cc -c -std=c99 -pedantic -Wall -Wno-deprecated-declarations -Os -I/usr/X11R6/include -I/usr/include/freetype2 -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_XOPEN_SOURCE=700L -DVERSION=\"6.5\" -DXINERAMA drw.c drw.c:5:10: fatal error: X11/Xlib.h: No such file or directory 5 | #include <X11/Xlib.…
Read more ⟶

Fix_LC_ALL_cannot_change_locale


I started seeing error bash: warning: setlocale: LC_ALL: cannot change locale (en_US.UTF-8) in my terminal. Upon searching I came across below solution which resolved my issue sudo su - apt-get update apt-get install locales echo "LC_ALL=en_US.UTF-8" >> /etc/environment echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen echo "LANG=en_US.UTF-8" > /etc/locale.conf locale-gen en_US.UTF-8 Hope it helps.…
Read more ⟶

Fix Bluetooth Headset Voice Chop in Linux


I am using Debian bookworm as my daily driver. As I connected my Sony Bluetooth headset, the voice started chopping or skipping the continuity. Upon searching/googling came across this fix via stackoverflow. In simple words, I need to increase buffer interval from 0 to 50ms and the audio will be buffered a bit early to avoid this lagging. Find out your bluetooth MAC and respective probe name via which the output coming out of your bluetooth headset.…
Read more ⟶

Behavior Parameterization


This programming pattern preferred when requirements of your project tends to change frequently. As name states, here you build a function and you pass that function as an argument. This way, as main logic not tightly coupled with functionality, when ever changes required, you update the defined behavior. As an example, you are told to process an order transaction with below steps - fetch order transaction - get the payment status - send to the vendor for further processing with order tracking as callback Now assume, you are told to a payment transaction - receive the payment details - user account has balance or not.…
Read more ⟶

Manage Binglog retention in Maria/MySQL


In Maria DB or MySQL DB we can manage update Binlog retention by updating the global property named expire_logs_days What is binlog ? binlog is a file where all the sql statements that were executed against the data in the database were record. using this binlog file, you can see what are the SQL queries executed against your database. And this binlog file can be used for replication or to perform PITR(point in time restore.…
Read more ⟶