Posts

Showing posts from May, 2025

How to Push to a GitHub Repository in IntelliJ

Image
1. Initialize and Connect the Git Repository # Run in the terminal from the project root git init git remote add origin https://github.com/[user]/[repository].git 2. Configure Git in IntelliJ Select VCS → Enable Version Control Integration . Choose Git and click OK . 3. Connect Your GitHub Account Go to File → Settings (on Windows) or IntelliJ IDEA → Preferences (on macOS). Navigate to Version Control → GitHub . Click Add Account ( + ). Select Log In with Token... and enter your GitHub Personal Access Token. 4. Add and Commit Files Go to VCS → Git → Add (or use the shortcut Ctrl+Alt+A ). Select the files you want to commit. Go to VCS → Commit (or use the shortcut Ctrl+K ). Write a commit message and click Commit . 5. Push Go to VCS → Git → Push (or use the shortcut Ctrl+Shift+K ). Click the Push button. Simpler Method (Using IntelliJ's Built-in Feature) Go to VCS → Share Project on GitHub . Set the repository name to vita-user-...

How Modern Java Improves Exception Handling (Java 21)

Image
In recent Java releases, especially Java 21, exception handling mechanisms have been significantly enhanced to improve both code safety and system reliability . These improvements help developers write more robust, maintainable, and error-resilient applications. 1. switch Statements Now Handle null and Support Pattern Matching In Java versions prior to 21, passing a null value to a switch statement would throw a NullPointerException . Java 21 allows developers to explicitly handle null values inside switch , preventing unexpected crashes. switch (input) { case null -> System.out.println("Input is null."); case "YES" -> System.out.println("Yes!"); default -> System.out.println("Other input."); } Benefits Prevents NullPointerException by design Improves clarity and readability 2. Pattern Matching and when Clauses in switch Java 21 introduces pattern matching for switch , allowing developers to write m...

Spring Boot Actuator, How to Monitor Application Health with actuator-health

Image
Spring Boot Actuator provides a wide range of features to monitor and manage your application when it's deployed in a production environment. These features can be accessed via HTTP endpoints or JMX, and they automatically enable capabilities such as auditing, health checks, and metrics collection in your application. Actuator is essential in cloud-native and microservice architectures, allowing real-time monitoring of application status, metrics, and traffic data. In particular, the /actuator/health endpoint offers a basic mechanism to check if the application is running properly, making it crucial for integration with load balancers, Kubernetes, and other orchestration tools. Spring Boot Actuator Setup 1. Add Actuator Dependency pom.xml (maven) <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> </dependencies...

Managing Shared Libraries in Microservice Architecture Using GCP Artifact Registry

Image
In a microservice architecture, it's common for multiple services to share common functionality or utility classes. To handle this effectively, I manage these shared components as a reusable library (like libs.jar ) that each service can depend on. In this post, I’ll show you how I use GCP Artifact Registry to efficiently manage and distribute a shared library across microservices. Step 1: Enable the Artifact Registry API $ gcloud services enable artifactregistry.googleapis.com --project=[PROJECT_ID] Step 2: Create a Maven Repository in GCP Artifact Registry $ gcloud artifacts repositories create maven-repo \ --repository-format=maven \ --location=us-central1 \ --description="Shared Maven Repo for common libraries" $ gcloud artifacts repositories list --location=us-central1 REPOSITORY FORMAT LOCATION DESCRIPTION maven-repo MAVEN us-central1 Shared Maven repo Step 3: Configure pom.xml for the Shared Library Project In the share...

Mastering GitHub Copilot with IntelliJ

Image
If you're developing Spring Boot applications using IntelliJ and GitHub Copilot (paid plan), this post is your ultimate guide. Learn how to generate boilerplate code, auto-generate tests, refactor suggestions, and much more—all using AI-powered assistance. Supported IDEs IntelliJ IDEA (Community & Ultimate) Visual Studio Code ⚠️ Requires GitHub Copilot Chat plugin installed Summary of GitHub Copilot Usage Feature Description Example 1. Editor Autocomplete Autocomplete suggestions appear after typing comments or method signatures // Create a REST controller → Press Tab 2. Copilot Chat + Slash Commands Use commands like /explain , /doc , /test to analyze, document, or test code /explain → describes what the code does 3. Natural Language Requests Ask questions conversationally without a slash Generate a method that...

How To Install Python 3.10 on Ubuntu 24.04 for pyannote.audio Compatibility

Image
I'm currently working with pyannote.audio version 3.1.1, and for full compatibility, it requires Python 3.10—especially because it was trained with torch==1.13.1 and CUDA 11.7. But by default, Ubuntu 24.04 ships with Python 3.12, and that caused some issues with dependencies. Python 3.10 Isn’t Included in Ubuntu 24.04 Ubuntu 24.04 (codename: noble ) only comes with Python 3.12 by default. When I tried to install Python 3.10 using just sudo apt update , the package simply couldn’t be found—because it isn’t included in the official package repositories. To install Python 3.10, I had to add the deadsnakes/ppa . This is a reliable third-party repository that provides older or alternative Python versions not offered in Ubuntu’s official repositories. # Add the Deadsnakes PPA $ sudo add-apt-repository ppa:deadsnakes/ppa $ sudo apt update # Install Python 3.10 and related tools $ sudo apt install python3.10 python3.10-venv python3.10-dev \ python3.10-distutils p...

How to Install Python 3.12 on Ubuntu 22.04

Image
Ubuntu 22.04 ships with Python 3.10 by default. Since I needed Python 3.12 for newer features and compatibility, I installed it manually. Here’s how I safely set it up alongside the system Python. Step 1: Update your system sudo apt update sudo apt upgrade -y Step 2: Install Python 3.12 and tools sudo apt install -y python3.12 python3.12-venv python3.12-setuptools python3.12-dev python3.12 : The main Python 3.12 interpreter. python3.12-venv : Enables creation of virtual environments using python3.12 -m venv . python3.12-setuptools : Provides tools to build and install Python packages (replacement for deprecated distutils). python3.12-dev : Includes headers and libraries needed to build Python C extensions and compile native modules. Step 3: Set python3 to point to Python 3.12 If your system still points to an older version, you can use update-alternatives to switch. sudo update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.12 2 sudo updat...

Speech-to-Text and Speaker Diarization with Wav2Vec2 and pyannote.audio 3.1 on Ubuntu 24.04

Image
In this post, I walk through how to use Wav2Vec2 for speech-to-text (STT) and pyannote.audio 3.1 for speaker diarization on Ubuntu 24.04. I'll use a Python virtual environment with Python 3.10, CUDA GPU acceleration, and Hugging Face models. Step 1: Python 3.10 Installation Ubuntu 24.04 comes with Python 3.12 by default, but since pyannote.audio 3.1.1 was trained with torch==1.13.1 and CUDA 11.7, which support Python 3.10, I need to install Python 3.10: How To Install Python 3.10 on Ubuntu 24.04 Step 2: Create Virtual Environment stt@GU502DU:~$ python3.10 -m venv wav2vec2_env stt@GU502DU:~$ source wav2vec2_env/bin/activate Step 3: Install torch 2.5.1 and cuda 12.1 My laptop is equipped with an NVIDIA GeForce GTX 1660, so I chose to install and use CUDA. Since the GPU driver reports CUDA Version 12.8, I installed the cu121 build of PyTorch, which is compatible with it. (wav2vec2_env) stt@GU502DU:~$ pip install torch==2.5.1+cu121 torchaudio==2.2.1+cu121 \ --extr...

Install NVIDIA Driver for GeForce GTX 1660 Ti on Ubuntu 24.04

Image
If you have an NVIDIA GeForce GTX 1660 Ti installed on your laptop and want to enable GPU support (e.g., for CUDA-enabled libraries like PyTorch), here's how to install the appropriate NVIDIA driver on Ubuntu 24.04. Step 1: Check if your NVIDIA GPU is detected stt@GU502DU:~$ lspci | grep -i nvidia 01:00.0 VGA compatible controller: NVIDIA Corporation TU116M [GeForce GTX 1660 Ti Mobile] (rev a1) 01:00.1 Audio device: NVIDIA Corporation TU116 High Definition Audio Controller (rev a1) 01:00.2 USB controller: NVIDIA Corporation TU116 USB 3.1 Host Controller (rev a1) 01:00.3 Serial bus controller: NVIDIA Corporation TU116 USB Type-C UCSI Controller (rev a1) Step 2: Check current driver status If you see something like this when you run nvidia-smi , it means the driver is not installed yet. root@GU502DU:~# nvidia-smi Command 'nvidia-smi' not found, but can be installed with: apt install nvidia-utils-470 apt install nvidia-utils-535 apt install nvidia-utils...

Speech-to-Text and Speaker Diarization with Whisper and pyannote.audio 3.1 on Ubuntu 24.04

Image
If you want to generate subtitles with speaker labels from an audio file using Whisper and pyannote.audio on Ubuntu 24.04, this blog post walks you through the full setup process. Step 1: Python 3.10 Installation (Manual) Ubuntu 24.04 comes with Python 3.12 by default, but pyannote.audio 3.1.1 was trained with torch==1.13.1 and CUDA 11.7, which supports Python 3.10 . So I need to install Python 3.10: How To Install Python 3.10 on Ubuntu 24.04 Step 2: Create and Activate a Python Virtual Environment stt@GU502DU:~$ python3.10 -m venv whisper_env stt@GU502DU:~$ source whisper_env/bin/activate Step 3: Install torch 2.5.1 and cuda 12.1 My laptop is equipped with an NVIDIA GeForce GTX 1660, so I chose to install and use CUDA. Since the GPU driver reports CUDA Version 12.8, I installed the cu121 build of PyTorch, which is compatible with it. (whisper_env) stt@GU502DU:~$ pip install torch==2.5.1+cu121 torchaudio==2.2.1+cu121 \ --extra-index-url https://download.py...

Use jq to Format JSON in gVim on Windows (Prettify & Minify)

Image
jq is a powerful command-line tool for processing and formatting JSON data. While there's no official Windows version available anymore, you can still use jq on Windows with an unofficial executable. Step 1: Download the jq Executable Visit the following GitHub release page and download the 64-bit version (jq-win64.exe): https://github.com/jqlang/jq/releases/tag/jq-1.6 Rename from jq-win64.exe to jq.exe and move it to your Vim folder like "C:\Program Files\Vim\vim91" Step 2: Add to System Path Open: Control Panel → System → Advanced system settings → Environment Variables Under “System Variables”, find and select Path, then click “Edit”. Add the following path: C:\Program Files\Vim\vim91 Step 3: Test jq in Terminal Open Command Prompt or PowerShell and run: PS C:\Users\jason> jq --version You should see: jq-1.6 Step 4: Use jq Inside Vim/GVim In Vim/GVim, format the current file using: :%!jq . This sends the whole file through jq and repla...

AWS SAM Template: How to Properly Define Inline IAM Policies

AWS Serverless Application Model (SAM) is a powerful framework for defining serverless resources like Lambda functions. One commonly misunderstood part of SAM templates is the Policies section under AWS::Serverless::Function . I used to write YAML files without ever including the Version field, so I habitually left it out in the Policies section as well — this caused unexpected error when deploying, and it took me quite a while to figure out what was wrong and fix the problem. Incorrect: Using Only " - Statement:" Policies: - Statement: - Effect: Allow Action: - transcribe:GetMedicalTranscriptionJob Resource: "*" This will result in errors like: Invalid ARN: Could not be parsed! Template format error: Every policy must contain a Version field Correct: Include Full Policy Document Policies: - Version: '2012-10-17' Statement: - Effect: Allow Action: - transcribe:GetMedicalTranscrip...