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
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
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
[<Struct>]
type Nothing =
private
| Nothing
View CurriedDelegateForSingleInstance.cs
using System;
class Program
{
// M wants to get an instance via Func
static void M(Func<string> factory)
{
Console.WriteLine(factory());
}
@dadhi
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
dadhi / GetMaterializedViewSize.sql
Last active Jan 16, 2019
Find disk size of Postgres materialized view
View GetMaterializedViewSize.sql
/*
https://dba.stackexchange.com/questions/96534/postgres-check-disk-space-taken-by-materialized-view?newreg=6b1d58604fce4a1fbe3033ddbb52d7ca
relkind:
r = ordinary table,
i = index,
S = sequence,
v = view,
m = materialized view,
c = composite type,
@dadhi
dadhi / index.md
Last active Mar 11, 2019
Discriminated Union or ADT Sum-type in C#
View index.md
@dadhi
dadhi / ImZipper.cs
Created Jul 5, 2018
Persistent Zipper data-structure for the win in C#
View ImZipper.cs
using System;
public class Test
{
public static void Main()
{
var x = ImZipper<int>.Empty.Pre(1).Pre(2);
Console.WriteLine(x);
Console.WriteLine(x.Focus);
}
@dadhi
dadhi / main.cs
Last active Jan 26, 2019
Discriminated Union (sum-type, co-product) from Algebraic Data Types (ADT) for C# which is memory efficient, supports one-line sub-typing
View main.cs
using System;
using System.Collections.Generic;
using static System.Console;
namespace Union
{
class Program
{
public static void Main()
{
@dadhi
dadhi / Lens.cs
Last active Jan 21, 2019
Functional optics, e.g. Lens, in C# - to simplify access and modification for deep part of immutable value
View Lens.cs
/*
Inspired by: https://medium.com/@gcanti/introduction-to-optics-lenses-and-prisms-3230e73bfcfe
*/
using System;
using static System.Console;
public static class Program
{
public static void Main()
You can’t perform that action at this time.