Skip to content

Instantly share code, notes, and snippets.

Maksim Volkau dadhi

Block or report user

Report or block dadhi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
dadhi / Demo.csproj
Last active May 8, 2020 — forked from danielcrenna/Demo.csproj
DI Source Generator
View Demo.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.0-preview.3.20215.2" />
dadhi / SpinWait.cs
Created Jan 8, 2020
Better SpinWait
View SpinWait.cs
A better spin lock:
The result is a spin lock that's quite fast — about twice as fast as locking with a Monitor (or the C# lock statement).
(It can be further sped up slightly by breaking the Enter method into two methods: Enter,
dadhi / AddGeneratedFile.csproj
Created Oct 9, 2019 — forked from KirillOsenkov/AddGeneratedFile.csproj
Sample of generating a .cs file during build and adding it to the compilation
View AddGeneratedFile.csproj
<Project Sdk="Microsoft.NET.Sdk">
using System%3B
dadhi / WrappingImmutableValueInMutableBox.cs
Last active Apr 17, 2019
Wrapping immutable value in a mutable box
View WrappingImmutableValueInMutableBox.cs
using System;
using ImTools;
public class Program
public static void Main()
var map = ImHashMap<string, string>.Empty;
var map1 = map.AddOrUpdate("a", "42");
View DictionarySlimWtf.cs
private DictionarySlim<TypeVal, string> _dict;
public DictionarySlim<TypeVal, string> DictSlim()
var dict = new DictionarySlim<TypeVal, string>();
foreach (var key in _keys.Take(Count))
dict.GetOrAddValueRef(key) = "a";
dict.GetOrAddValueRef(typeof(ImHashMapBenchmarks)) = "!";
dadhi / Env.fsx
Created Mar 11, 2019
An F# toy example of Scala ZIO Environment
View Env.fsx
module EnvDemo
open System
open System.IO
type Nothing =
| Nothing
View CurriedDelegateForSingleInstance.cs
using System;
class Program
// M wants to get an instance via Func
static void M(Func<string> factory)
dadhi / BenchDelegatesApp.cs
Created Feb 20, 2019 — forked from xoofx/BenchDelegatesApp.cs
Benchmarks of calli vs delegate
View BenchDelegatesApp.cs
// | Method | Mean | Error | StdDev |
// |------------- |----------:|----------:|----------:|
// | Calli | 0.6718 ns | 0.0013 ns | 0.0012 ns |
// | Delegate | 1.1366 ns | 0.0099 ns | 0.0088 ns |
// | FastDelegate | 1.6239 ns | 0.0103 ns | 0.0097 ns |
// MyClassLib.cs is compiled in another project (havent tested if compiling with Fody is working with BenchmarkDotnet in the same project)
// This file is referencing BenchDelegates.MyClassLib
using System;
dadhi / GetMaterializedViewSize.sql
Last active Jan 16, 2019
Find disk size of Postgres materialized view
View GetMaterializedViewSize.sql
r = ordinary table,
i = index,
S = sequence,
v = view,
m = materialized view,
c = composite type,
dadhi /
Last active Mar 11, 2019
Discriminated Union or ADT Sum-type in C#
You can’t perform that action at this time.