Skip to content

Instantly share code, notes, and snippets.

View dadhi's full-sized avatar
🎯
Focusing

Maksim Volkau dadhi

🎯
Focusing
View GitHub Profile
@dadhi
dadhi / csharp-perf.agent.md
Last active April 11, 2026 08:13
csharp-perf.agent.md
name perf-expert
description Deep dive into .NET performance bottlenecks.

You are the Perf-Expert. When asked to write C# code:

  1. Code for the actual CPU and Memory - not for the "best-practice", "methodology" or "tech-stack":
  • use data-oriented / array-based programming technics
  • flat arrays/indexes/intrusive data-structures instead of pointers
  • adhere to cache locality/hierarchy
  • avoid dependency chains/stalls and enable ILP
@dadhi
dadhi / general-dev.agent.md
Last active April 11, 2026 08:11
general-dev.agent.md
name general-dev
description First-principles software engineering focusing on semantic compression, directness, professionalism.

Development Principles

  • Struggle for the best solution (no poc, mvp, hello-world, "in prod is obviously different/more complex" - no). We are professionals btw!
  • Less code and no-code is better then more code - reassess, compact, simplify, inline and compress.
  • Comment as a fellow technician - not a wordy consultant/marketing person - focus on what and why it does, inout to output transofrmation, surface usage and dependencies
@dadhi
dadhi / imtree23.cs
Last active February 17, 2026 15:51
Immutable intrusive 2-3 tree shaped as intrusive array (cache-friendly, values are separated to its own array) and using gen references for the immutability tracking
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Collections.Generic;
using System.Threading;
public enum NodeType : byte { Sentinel, TwoNode, ThreeNode }
public readonly record struct NodeIdx(int Index, int Gen) {
[MethodImpl(MethodImplOptions.AggressiveInlining)]
@dadhi
dadhi / data-class-see.md
Last active December 25, 2025 21:07
Dmax is Datastar.js inspired, fast, small, no-build, no-magic, declarative web lib for the page interactivity based on signals and the html native data- attributes
  1. data-class
  2. data-see
@dadhi
dadhi / ThreadSleepYieldMeaning.cs
Created August 13, 2025 14:17
ThreadSleepYieldMeaning
// source: https://github.com/dotnet/runtime/discussions/115627#discussioncomment-14092390
// Thread.Sleep(0); // 4750 cede control to any thread of equal priority
// spinWait.SpinOnce(); // 4100 periodically yields (default is 10 iterations)
// Thread.Sleep(1); // 3900 cede control to any thread of OS choice
// Thread.Yield(); // 3650 cede control to any thread on the same core
// await Task.Delay(0); // 3600 creates and waits on a system timer
// do nothing // 3600 burn down a CPU core
// Thread.SpinWait(1); // 3600 duration-limited Yield
// await Task.Yield(); // 3250 suspend task indefinitely (scheduler control)
@dadhi
dadhi / SolvedSoftwareProblems.md
Last active October 31, 2025 08:42
Solved Software Problems
@dadhi
dadhi / HVML.c
Created November 7, 2024 06:24 — forked from VictorTaelin/HVML.c
$10k bounty - make HVML.c 50% faster on Apple M3
// Post: https://x.com/VictorTaelin/status/1854326873590792276
// Note: The atomics must be kept.
// Note: This will segfault on non-Apple devices due to upfront mallocs.#include <stdint.h>
#include <stdint.h>
#include <stdatomic.h>
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
@dadhi
dadhi / rename-pictures.sh
Created October 4, 2024 20:33 — forked from jart/rename-pictures.sh
Shell script for renaming all images in a folder
#!/bin/sh
# rename-pictures.sh
# Author: Justine Tunney <jtunney@gmail.com>
# License: Apache 2.0
#
# This shell script can be used to ensure all the images in a folder
# have good descriptive filenames that are written in English. It's
# based on the Mistral 7b and LLaVA v1.5 models.
#
# For example, the following command:
@dadhi
dadhi / gist:b6d19276c0619d78b41d93138b07a562
Created September 2, 2024 13:30
better_target_framework_selector.csproj
<PropertyGroup>
<TargetFrameworks>netcoreapp2.1;netcoreapp3.1;net5.0;net6.0;net7.0;net8.0</TargetFrameworks>
<TargetFrameworks Condition=" '$(OS)' == 'Windows_NT' ">net48;$(TargetFrameworks)</TargetFrameworks>
<IsPackable>false</IsPackable>
<DefineConstants Condition="'$(TargetFramework)' != 'net48'">$(DefineConstants);READONLYSPAN</DefineConstants>
</PropertyGroup>
@dadhi
dadhi / Program.cs
Created May 7, 2024 13:43 — forked from kolebynov/Program.cs
Fixed stack/heap array with any element type
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
var list1 = new FixedList<string, Buffer16<string>>();
var list2 = new FixedList<string, Buffer32<string>>();
UseList(ref list1, "Hello");
UseList(ref list2, "World");
Console.WriteLine(list1.GetRef(0));
Console.WriteLine(list2.GetRef(0));