Skip to main content

Posts

Showing posts with the label Tech Tutorials

How Kafka replaced Zookeeper with the (K)Raft algorithm?

Back in 2021, when I first came across Kafka, I remember the DevOps engineer in my team using terms like Zookeeper, broker configs, etc on our team standup calls. I remember not caring about those terms, and simply focusing on learning about the producer, partitions, topics and consumer groups, and how they could be used in the product my team was developing. While platforms like Kafka were built to abstract certain aspects of distributed computing (replication, consistency) while storing & processing logs, it's a pity how so many of us miss out on knowing the amazing engineering that went behind to build the different parts of a platform such as this one. 4 years later, I'm hungry enough to reverse engineer one of my favourite distributed platforms - Kafka! What did the Zookeeper do? To quote the 1st  Kafka paper from 2011, Kafka uses Zookeeper for the following tasks:  (1) detecting the addition and the removal of brokers and consumers,  (2) triggering a rebalance ...

i3wm essentials - II

Welcome back! Let's continue this guide with other setup essentials for i3. Enabling Mousetap Chances are that if you're using a laptop, then tapping on the mousepad does not equal a click for you. You need to enable tapping in your config. Fortunately, there is one documentation available that works for majority of the setups. I don't need to explain this one in detail. Here you go: Enable tap to click in i3 . Volume Control This one is simple again. Do you remember the i3 config file I talked about in the previous blog ? All you need to do is go to that file and find the line: bindsym XF86AudioRaiseVolume Just below that line you will find lines with XF86AudioLowerVolume and XF86AudioMute too. Anyway, the truth is, there are 2 sets of lines with these keywords. Chances are that the line: bindsym XF86AudioRaiseVolume exec --no-startup-id pactl -- set-sink-volume 0 +5% Will be uncommented and the line: bindsym XF86AudioRaiseVolume exec --no-startup-id pactl -- set-sink vo...

i3wm essentials - I (Brightness)

So you have started using i3 and somehow managed to open your browser and almost resumed your normal work.  But wait, the brightness is too much isn't it? Or is it too low? The mousepad used to work fine, but now all of a sudden tapping does not equal click?!  Don't worry.  This blog series will tell you all about the essential setup commands and common shortcuts that I use to navigate my work in i3, and how you can too. Changing the brightness So you just started i3 and you just can't take this brightness setting. You go for your function keys, and damn! They aren't working. Quick fix: Run the following command if you need to change the brightness ASAP. xrandr -q | grep ' connected' | head -n 1 | cut -d ' ' -f1 This will give an ouput that's the name of your monitor.  Use that monitor name here and change the values of brightness to suit your needs. xrandr --output <monitor-name> --brightness 0.7 Now that your eyes are comfortable, let me show...

Review: Nestjs - Finally a scalable way to build APIs

I have been thinking about this for a long time. There HAS to be a defined way to build APIs in a scalable way.  If you have used Node, Express, etc in your side projects, you might have felt that after a point in development, debugging truly becomes a pain. Sure, enterprise-level API codes are great. But a lot of times, these configurations are too much, and probably not even needed in other projects. To be honest, I haven't seen a lot of Open-Source API codes either to make a judgement on how experienced developers build their APIs. Anyway, I came across an amazing framework recently, and I think if you are coding a complex API, this should be your way to go. Nest.js Nest.js is a framework for building efficient, reliable and scalable server-side applications.  You essentially break your APIs into controllers, services, and modules, which allow you to modularize the smallest of functionalities in your endpoints or the API as a whole. Why is modularizing important? As I have...

An introduction to APIs

API is an acronym for Application Programming Interface. Let's start with first defining some basic terms: Browser: These are browsers. To visit any website on the internet, you need a browser. Server: Hmm, this is tough. In simple words, server is a computer. Yes, just like the laptop, or PC at your home. The only difference is that it does not have a screen. Of course, there are other differences in technical specifications, but at its core, the server is just, simply, a computer. That's it. So why is it called a server? Because it serves . When you go to a website like google.com , your computer connects to the internet and gets you your search result. But your computer's internet connection has to get that result from somewhere, right? If the google search result is giving you some answers, the answers have to come from somewhere. What is that place? The answer to that some place is: a server. When you click on the search button on google, or hit enter after typing, ...

DrawPI - Building an API in 2 minutes

Build a good design, materialize a great idea, you still need data to play with your product. Collect as much as data as you want, you still need to send it back to the client in a systematic, secure manner. What do you call this systematic, secure manner ? APIs. You are most probably aware of the concepts of an API. You're just wondering how can you build an API in 2 minutes when there are literally 1000+ courses over the internet teaching the intricacies of building it through code that takes hours?! Well, the short answer is: you design, we code. All you have to do is Create, Define, Declare. Create a project. Define a model (a simple database). Declare your endpoints. Have a look at the Create page here. This single screen outscores the manual process of code writing for APIs.  The right pane focuses on building each endpoint, while the left defines the properties for the entire API. Let's look at each ...

Quick Guide to CRON syntax

Cron jobs are used to schedule recurring or one-time jobs by a specific time. The libraris allowing these jobs use something known as cron patterns. This is a blog post to quickly and simply explain their usage and functionality. Tip: Find out the finest granularity of the library function you are using. The cron job you are using will specify the finest granularity . This can be explained as the least count of the library function. For example, if it says, 1 minute, the smallest cron job you could run is at the specification of a minute. So a job that has to be run by specifying the second-th time is not possible. If the finest granularity is 1 second , you can even run a job at say, at 15 seconds past 4:35 pm. The best cron library to use is: cron. Cron Syntax Assuming the finest granularity is 1 second, a cron pattern has fields. These fields are: field allowed values ----- -------------- second 0-59 minute 0-59 hour 0-23 day of month 0...

Having an organized Browsing Experience

Are you the kind of person who inevitably has to work on multiple tabs due to the complexity of your work? We have all been there. You are researching about something, or building something, or doing any other task on your browser, and you end up opening at least 4 tabs if the task is simple, 10/12 tabs if the task is tough, or sometimes tabs you're too afraid to even count! You know what opening so many tabs creates? Chaos . Yes, after a certain point, you don't even remember exactly on which tab is the information you looked at recently. You know everything that's going to help you is right in front of you, but you don't know where exactly. And if a time comes when you have to disconnect from the work in progress, and maybe call the day or start working on some other thing, you are too much afraid to close these tabs. Eventually, you start doing all the tasks on the same window, and mixing everything, or you open a new window and never really close anything. ...

Tips and Tricks - Arch Linux Installation

A month ago, I had embarked on this remarkable challenge of installing Arch Linux, and truth be told, it was worth every bit. Any CS Engineer should be aware of the nuances of the Linux Kernel, Distro, Display Manager and how all of these work together. The installation process of this Linux distro will make sure that you learn all of this, the right way. Here are some tips to begin with: 1. Always try installation on Virtualbox first   You don't know about the enormous struggle you will be facing with the installation and running Arch Linux on your machine. If you're not a Linux expert, please do not single boot this Linux on your first try.  Only when you have finished installing Arch Linux on a Virtualbox, should you try dual/single booting Linux on your actual system. I took 3 attempts to get Arch Linux running properly (up till installing a DE) on my Virtualbox before installing it in my system. 2. Refer a tutorial for your first time "But I might ...

Jarvis, we love you 3000!

Would you dig a Desktop like that? Of course you would! I cannot imagine anyone saying no to this screen! And guess what, this is all Live. Have a look at the GIF below: If you're thinking this would look more cooler in person, you're absolutely right, Mr. Stark! Go build your own JARVIS right now on your Linux OS. I must credit the amazing blog which guided me to this customization. Here is the link: NomiSpeaks' Blog on Making a JARVIS Live Wallpaper However, since this post is 2 years old, there are some things that you will need to do additionally to make this work. Installation of Conky Manager First, when you try to install conky-manager by running the command: sudo apt-get install conky-manager  You will get an error something like this: E: Unable to locate package conky-manager So here's another way to get to this. A github repo named conky-manager2 is built for the same purpose. Follow the steps in that repo to install conky-manag...

Detailed Understanding of What a Web Socket Really Is?

A Web Socket is, in its simplest explanation, a connection between two processes running in two different (computer) systems. Detailed Explanation: There are a few terms that you should know about to fully understand Web Sockets. Note: A computer system is everything from your mobile device, to your laptop/PC to a proper Web Server. IP Address:  IP Address is a unique Identification of a computer system for the Internet. You log onto Instagram. There is an Instagram server situated somewhere far away. Any page you open, anything you click sends a request to that server. Within that request, obviously, some data is requested. Along with that, the request should also have a FROM property, right? How can anyone know who to respond to unless they know who has asked the question?! That required FROM tag, is the IP Address of your device. Everywhere you go on the Inernet, it's basically this IP Adress going in places and getting you all your results. IP Adress s...

Find First and Follow for Syntactical Parsing - Compiler Frontend II

Hey! In my last post, I talked about the implementation of the Lexical Analyzer that would detect errors in the program originating from the use of invalid tokens. If you want to read more about it, you can start here . In this blog, we will write a very short program to find the First & Follow of a set of productions in a Grammar. I'm hoping you have a basic understanding of Productions, and deriving First & Follow manually. Why? When I tried to understand the code to find the First & Follow from the internet, namely on sites like GeeksForGeeks, the code was too long, and sometimes I'm just too lazy to read code :). As it turns out, I was recently in a situation where I had no option than to write the code myself. Surprisingly, that turned out to be a blessing in disguise, as I developed a much shorter code for it using Hash Tables.   (Yeah, 82 lines is a much shorter code for this program!) Here's the link for the gist . Please note the c...

Building a Lexical Analyzer - Compiler Frontend I

Hey guys, today I'll be building a fully functional Lexical Analyzer that detects unrecognized tokens in C++! Beginning: The foundation of this program is derived from another program that counts different tokens in a C/C++ program.  While I will try to explain all the basics of Lex here, if you find yourself stranded, you can refer the above link too. Once you understand the method of identifying tokens, the following program is just the converse of it! Here's a basic overview of what happens in a Lex Program: Some basics about a Lex Program Lex (FLEX) basically iterates through your entire input string, trying to match everything it finds in the rules section. Once it finds the pattern, it executes the set of lines listed within the {} brackets. So you can consider the "rules" an informal way of function declaration. Rule Section in a Lex Program:                         Rule Section in ...