Kafka Java Programming

Kafka Java Programming I’ve been learning Apache Kafka over the past week. I took the Udemy course Apache Kafka Series - Learn Apache Kafka for Beginners v3. I’m using this blog to take notes, and this post focuses specifically on Java programming with Kafka. Producer Basics To configure a Kafka producer: Set the key and value serializer to, for example, StringSerializer flush() the buffer close() the producer, which will flush the buffer automatically Callback Callbacks allow us to examine the state of a message. ...

July 19, 2025

Kafka CLI

Overview I’ve been learning Apache Kafka over the past week. I took the Udemy course Apache Kafka Series - Learn Apache Kafka for Beginners v3. I’m using this blog to take notes, and this post focuses specifically on Kafka CLI commands. Installation and Setup Client Installing the Kafka client on macOS is very straightforward: brew install kafka Homebrew will install both JDK and Kafka for you. You can verify the installation by running kafka-topics in your terminal. ...

July 16, 2025

Kafka Basics

Kafka Basics I’ve been learning Apache Kafka over the past week. I took the Udemy course Apache Kafka Series - Learn Apache Kafka for Beginners v3. This blog covers the theory part of Kafka. Topics, Partitions and Offsets Here are some important notes: Kafka is append-only Data retention policy (one week by default) Order is guaranteed only within a partition Producers When a key is null, data is sent to partitions in round-robin fashion When a key is specified, all messages for that key will always go to the same partition (using hashing). This is useful when you need message ordering. Messages ...

July 15, 2025

Redis Basics

Redis Basics Here are my notes on Redis. Installation, Start, and Shutdown I installed WSL and then installed Redis using sudo. To start Redis, cd to /usr/bin and run sudo ./redis-server To connect to Redis, cd to /usr/bin and run sudo ./redis-cli To shutdown Redis, run shutdown in the redis-cli, and Redis will save an RDB snapshot before exiting To check whether Redis is running, run ps -ef | grep redis To kill the process, run kill -9 <pid> Commands keys * returns all keys. This command also supports regex patterns dbsize returns the number of keys expire key sets the TTL of the key in seconds pexpire sets the TTL in milliseconds expireat sets the absolute time when the key will expire ttl key returns the remaining time of the key -1 means it won’t expire -2 means it has already expired Non-negative values show the countdown in seconds set key value setnx key value only sets the value when a key does not exist mset k1 v1 k2 v2 k3 v3 ... sets multiple key-value pairs This can save network bandwidth! get key mget k1 k2 k3 gets multiple keys rename old_key new_key renames the old key to the new key Use renamenx for safer operation, so it won’t override existing keys Naming Convention Naming convention for keys is very important. ...

July 13, 2025

Data Structure (in Python)

Recently, I have been re-learning Python in my spare time, and I want to write a blog (or blogs) to document something new to me. Stack Surprisingly, there’s no stack type in Python. There are three ways to implement a stack in Python. Check out How to Implement a Python Stack: list collections.deque queue.LifoQueue List List is built upon blocks of continous memory. To implement a stack: >>> stack = [] >>> stack.append(1) >>> stack.append(2) >>> stack.pop() 2 >>> stack.pop() 1 Deque A deque is implemented as a doubly linked list. ...

June 8, 2025

Integrating App Insights with Hugo

Tracking website usage is essential for understanding your audience and improving your content. For my Hugo website, I chose to use Azure Application Insights (App Insights) because I just like it. This guide is inspired by this tutorial. Setting Up Azure Resources To get started, search for Application Insights in the Azure Marketplace. Click Create and fill in the required details: Once done, click Review + Create to finalize the setup. ...

April 29, 2025

Geneva

Geneva is an internal monitoring platform developed by Microsoft. While Geneva is widely used within Microsoft, it is not publicly available. However, Microsoft offers similar monitoring tools for external customers, such as Azure Monitor. Recently, I have been working on a feature to implement infrastructure for sending metrics using Geneva APIs. In this blog, I’ll share a high-level overview of what I have learned. Source Code I cannot talk too much about the infrastructure setup here, as those are internal implementations. ...

April 28, 2025

VSCode Extension Advanced Topics

In this blog, I want to document some useful apis, such as chat extension api and workspace api. Get the current workspace We can use the workspace API to create folders and files in vscode. To do that, we need to get the reference to the current workspace. You can read more about VSCode workspace from this doc. Basically, when you first open a vscode editor, the workspace is empty: You can open a folder to work with: ...

April 21, 2025

VSCode Chat Extension Basics

Introduction A VSCode Chat Extension is an extension uses the Chat extension API by contributing a chat participant - a domain expert that can answer user queries within a specific domain. The reason why I am looking into the VSCode Chat Extension is that I want to build a domain expert on Threat Modeling. In this blog, I will talk about the basic usage of a chat extension. Here are the references: ...

April 18, 2025

Vibe Coding Like a Pro

Introduction Vibe coding is a term introduced by Andrej Karpathy. While some perceive vibe coding as using AI for merely writing code, I see it as: a method to learn new concepts a way to write higher-quality code leveraging AI to handle boilerplate code, allowing me to focus on more critical aspects, such as: product vision tech stack decisions architectural design design patterns test cases At work, I use GitHub Copilot for projects written in TypeScript and C#. Outside of work, I use Cursor to collaborate on open-source projects and build my own products. The languages I work with range from TypeScript to Python and Swift. So far, I have been able to create more than I ever imagined. ...

April 14, 2025