Skip to content

Instantly share code, notes, and snippets.

View dadhi's full-sized avatar
🎯
Focusing

Maksim Volkau dadhi

🎯
Focusing
View GitHub Profile
@mausch
mausch / Reducers.fsx
Last active December 17, 2015 07:09
Clojure reducers in F#
// http://clojure.com/blog/2012/05/08/reducers-a-library-and-model-for-collection-processing.html
// original by Nick Palladinos: http://fssnip.net/ip
#r "FSharp.PowerPack.Parallel.Seq.dll"
module Reducer =
open System
open System.Text
open System.Collections.Generic
open System.Linq
@dubmun
dubmun / package.bat
Last active December 18, 2015 13:29 — forked from joshuaflanagan/package.bat
@ECHO OFF
SETLOCAL
SET VERSION=%1
SET NUGET=buildsupport\nuget.exe
FOR %%G IN (packaging\nuget\*.nuspec) DO (
%NUGET% pack %%G -Version %VERSION% -Symbols -o artifacts
)
@dadhi
dadhi / MultimethodsWithDynamicTests
Last active January 13, 2016 10:48
Proof of concept and very simple Multimethods implementation, that uses dynamic keyword from .Net 4.0. Thanks goes to <http://blogs.msdn.com/b/laurionb/archive/2009/08/13/multimethods-in-c-4-0-with-dynamic.aspx>.
using NUnit.Framework;
using Microsoft.CSharp.RuntimeBinder;
namespace MultiMethodsWithDymanic
{
[TestFixture]
public class MultimethodsTests
{
[Test]
public void What_is_good_for_rabbit_is_not_good_for_wolf()
@dadhi
dadhi / Either.cs
Last active April 12, 2016 10:04
Take on minimal yet extensible approach to implementing Either/Or/DiscriminatedUnion
using System;
using System.Reflection;
using NUnit.Framework;
namespace Playground
{
[TestFixture]
public class EitherTests
{
[Test]
@joshuaflanagan
joshuaflanagan / package.bat
Created June 24, 2011 02:57
Examples of how to build all Nuget nuspec files in a folder
@ECHO OFF
SETLOCAL
SET VERSION=%1
SET NUGET=buildsupport\nuget.exe
FOR %%G IN (packaging\nuget\*.nuspec) DO (
%NUGET% pack %%G -Version %VERSION% -Symbols -o artifacts
)
using System;
class Program
{
// M wants to get an instance via Func
static void M(Func<string> factory)
{
Console.WriteLine(factory());
}
@tonymorris
tonymorris / Lens.cs
Created August 5, 2012 05:43
Lens library for C# (demonstration)
using System;
using System.Collections;
using System.Collections.Generic;
/*
A basic lens library for the purpose of demonstration.
Implements a lens as the costate comonad coalgebra.
This library is not complete.
A more complete lens library would take from
#if NETCOREAPP3_1
using System;
using System.Linq;
using System.Text;
using System.Buffers;
using NUnit.Framework;
using System.Reflection;
using System.Buffers.Binary;
using static FastExpressionCompiler.LightExpression.Expression;
// ReSharper disable InconsistentNaming
@xoofx
xoofx / BenchDelegatesApp.cs
Created February 19, 2019 19:56
Benchmarks of calli vs delegate
// | 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;
@danielcrenna
danielcrenna / Demo.csproj
Last active May 10, 2020 14:59
DI Source Generator
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>preview</LangVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="5.0.0-preview.3.20215.2" />
</ItemGroup>
<ItemGroup>