Skip to content

Instantly share code, notes, and snippets.

View swagfin's full-sized avatar
🖥️
Just a little research

George Njeri (Swagfin) swagfin

🖥️
Just a little research
View GitHub Profile
@swagfin
swagfin / how-to-recover-suspect-sql-server-database.md
Created October 29, 2025 10:44
How to recover a SUSPECT SQL Server database

How to recover a SUSPECT SQL Server database

If your SQL Server database (for example, semantic_pos_db) is marked as SUSPECT, this guide will walk you through the steps to bring it back online safely.


1. Identify the problem

@swagfin
swagfin / await-vs-configureawait-false.md
Last active October 25, 2025 00:49
Await vs ConfigureAwait(false) — Explained Like a Gentleman

Await vs ConfigureAwait(false), Explained Like a Gentleman

👋 Introduction

When working with async and await in C#, you might come across this mysterious line:

await Task.Delay(2000).ConfigureAwait(false);
@swagfin
swagfin / force-delete-pods.md
Created September 13, 2025 08:00
Force Delete Stuck Pods in Kubernetes / MicroK8s

Force Delete Stuck Pods in Kubernetes / MicroK8s

Sometimes pods get stuck in the Terminating state due to node issues, kubelet problems, or blocking finalizers.
This guide shows how to force delete them both individually and across all namespaces.


🔹 Delete a Single Pod

@swagfin
swagfin / upgrading-argocd-on-microk8s.md
Last active July 2, 2025 06:55
This guide helps you check for new Argo CD versions and upgrade safely when installed via Helm.

🔄 Checking for Argo CD Updates & Performing an Upgrade (Helm-based)

This guide helps you check for new Argo CD versions and upgrade safely when installed via Helm.

🧰 Prerequisites

  • Argo CD installed using helm via MicroK8s community addon
  • Access to microk8s helm3
  • Namespace: argocd

🔁 WithRetry Helper for C#

A minimal retry utility for async methods with and without return values.

📦 Code

using System;
using System.Threading;
using System.Threading.Tasks;
@swagfin
swagfin / horizontal-scaling-aspnet-core-razor-pages-auth-problem.md
Created April 5, 2025 19:34
Horizontally Scaling an ASP.NET Core Razor App (Authentication with Redis)

Horizontally Scaling an ASP.NET Core Razor App (Authentication with Redis)

When scaling your ASP.NET Core Razor app to multiple instances (pods, containers, etc.), authentication can become problematic. This is particularly true for cookie-based authentication, where each instance of your app needs to be able to encrypt and decrypt cookies using the same encryption keys.

Problem

By default, ASP.NET Core stores its data protection keys locally within the app (e.g., in /root/.aspnet/DataProtection-Keys). This approach works well in single-instance scenarios, but when you scale horizontally, each instance of your app has its own set of encryption keys. As a result, cookies encrypted by one instance cannot be decrypted by another, causing authentication failures.

Symptoms:

  • Users are redirected to the login page when they switch between different instances (pods).
@swagfin
swagfin / updating-ubuntu-hostname-after-cloning.md
Last active September 18, 2025 16:19
Updating Ubuntu Hostname After Cloning a Disk

Updating Ubuntu Hostname After Cloning a Disk

Step 1: Change the Hostname

Update the hostname using the hostnamectl command:

sudo hostnamectl set-hostname NEW_HOSTNAME

Or Update /etc/hostname

Edit the file manually:

@swagfin
swagfin / how-to-join-a-node-into-microk8s-cluster.md
Last active October 28, 2025 17:38
How to Join a Node into MicroK8s Cluster

How to Join a Node into a MicroK8s Cluster as a Worker

MicroK8s provides an easy way to create lightweight Kubernetes clusters. This guide explains how to join a new node as a worker in an existing MicroK8s cluster using the --worker flag.


1. On the Control Plane (Primary Node)

Run the following command to generate a join token:

@swagfin
swagfin / how-to-setup-nfs-server-on-ubuntu.md
Last active November 3, 2024 14:08
How to Set Up NFS Server on Ubuntu

How to Set Up NFS Server on Ubuntu

Install NFS Server

First, install the NFS kernel server:

sudo apt install nfs-kernel-server

Start the NFS service:

sudo systemctl start nfs-kernel-server.service

How to re-generate K8s SSL Certificates on MicroK8s

Issue

You might encounter the following error when you the IP addresses is changed on the host machine:

Unable to connect to the server: x509: certificate is valid for <internal IPs>, not <external IP>

Solution