Skip to content

Instantly share code, notes, and snippets.

View shirhatti's full-sized avatar

Sourabh Shirhatti shirhatti

View GitHub Profile
@shirhatti
shirhatti / snat.md
Created January 6, 2026 07:00
How a Missing SNAT Flag Broke My Homelab's Cloud Database Connection

I run Coder (a development environment platform) in my homelab Kubernetes cluster, with the PostgreSQL database hosted in Azure. The networking setup uses Tailscale to connect my homelab to Azure resources through a subnet router VM. Everything was working fine until I migrated to a new Azure subnet router—then Coder went down hard.

The Symptom

Coder was crash-looping with 693 restarts over 22 days. The logs showed:

2026-01-06 06:15:03.939 [warn] ping postgres: retrying

Approach

  1. Stash-like tracking: Instead of using git stash, use a sequence of temporary commits on a detached HEAD.
  2. Detached HEAD commits: Each incremental automation change is committed but does not affect the working branch.
  3. Reflog for tracking: Each commit is reachable via git reflog, so you can review each change step by step.
  4. No changes left behind: Once the tool completes execution, the working directory still contains uncommitted changes.

Step 1: Start in a Detached HEAD

Before making changes:

@shirhatti
shirhatti / index.html
Last active October 18, 2021 23:00 — forked from magjac/index.html
d3-graphviz Demo
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<script src="//d3js.org/d3.v5.min.js"></script>
<script src="https://unpkg.com/@hpcc-js/wasm@0.3.11/dist/index.min.js"></script>
<script src="https://unpkg.com/d3-graphviz@3.0.5/build/d3-graphviz.js"></script>
<div id="graph" style="text-align: center;"></div>
<script>
var dotIndex = 0;
@shirhatti
shirhatti / ConsoleApp.csproj
Created April 7, 2021 19:07
Activities via EventPipe
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Diagnostics.NETCore.Client" Version="0.2.217401" />
<PackageReference Include="Microsoft.Diagnostics.Tracing.TraceEvent" Version="2.0.66" />
@shirhatti
shirhatti / Program.cs
Created March 19, 2021 19:25
Mean ≠ Median
using System;
using System.Threading;
namespace ConsoleApp
{
public class Program
{
const int interations = 100;
const int spinWaitIterations = 1000000;
private static Random random = new();
@shirhatti
shirhatti / CounterPayload.cs
Created November 18, 2020 19:20
EventCounters via ETW
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.
using System;
using System.Collections.Generic;
namespace Microsoft.Diagnostics.Tools.Counters
{
public interface ICounterPayload
@shirhatti
shirhatti / hello-world-deployment.yaml
Created June 19, 2020 08:57
Kubernetes manifest for dotnet-monitor
# This Deployment manifest defines:
# - single-replica deployment of the container image, with label "app: dotnet-hello-world"
# - Pod exposes port 8080
# - specify PORT environment variable to the container process
# Syntax reference https://kubernetes.io/docs/concepts/configuration/overview/
apiVersion: apps/v1
kind: Deployment
metadata:
name: dotnet-hello-world
spec:
@shirhatti
shirhatti / container-azm-ms-agentconfig.yaml
Created June 19, 2020 08:53
Azure Monitor configuration
kind: ConfigMap
apiVersion: v1
data:
schema-version:
#string.used by agent to parse config. supported versions are {v1}. Configs with other schema versions will be rejected by the agent.
v1
config-version:
#string.used by customer to keep track of this config file's version in their source control/repository (max allowed 10 chars, other chars will be truncated)
ver1
log-data-collection-settings: |-
@shirhatti
shirhatti / ConsoleApp.csproj
Last active April 29, 2024 05:30
Consume ILogger logs through EventListener
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.EventSource" Version="5.0.0-preview.4.20251.6" />
@shirhatti
shirhatti / Program.cs
Created February 10, 2020 16:33
MWA Set environment variable on ApplicationPool
using Microsoft.Web.Administration;
namespace MWASample
{
public class Program
{
static void Main(string[] args)
{
var serverManager = new ServerManager();
var config = serverManager.GetApplicationHostConfiguration();