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 / EventAggregatorImpl.cs
Created August 11, 2016 08:48
Simple EventAggregator
using System;
using NUnit.Framework;
namespace DryIoc.IssuesTests
{
[TestFixture]
public class Issue164_EventAggregatorImpl
{
[Test, Explicit]
public void Able_to_handle_multiple_events_being_singleton()
@dadhi
dadhi / Army.elm
Last active September 16, 2016 09:38
Small elm app for civilian / in-army people tracking
import Html exposing (..)
import Html.App as Html
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import String as String
main =
Html.beginnerProgram
{ model = model
, update = update
@dadhi
dadhi / ClearingInput.elm
Created October 12, 2016 07:45
Small example if clearing input value in elm
import Html exposing (div, button, text, input, p)
import Html.App exposing (beginnerProgram)
import Html.Events exposing (onClick, onInput)
import Html.Attributes exposing (placeholder, value)
main =
beginnerProgram { model = model, view = view, update = update }
@dadhi
dadhi / Transducers.cs
Last active February 23, 2017 12:05
Sample of Clojure Transducers in C# (LINQPad snippet)
Func<Func<T,T,T>, Func<T,T,T>> Mapping<T>(Func<T,T> map)
{
return reduce => (sum, item) => reduce(sum, map(item));
}
Func<Func<T,T,T>, Func<T,T,T>> Filtering<T>(Func<T,bool> condition)
{
return reduce => (sum, item) => condition(item) ? reduce(sum, item) : sum;
}
@dadhi
dadhi / DelegateVsInterfaceStruct.cs
Last active August 10, 2017 08:04
Benchmark of Delegate vs Interface Struct implementation
using System;
using BenchmarkDotNet.Attributes;
namespace Playground
{
[MemoryDiagnoser]
public class DelegateVsInterfaceStruct
{
[Params(10, 100, 1000)] public int ArraySize;
@dadhi
dadhi / PerfTest_ManuallyCompilingExpressionTreeWithEmit_InvokingResultDelegate.cs
Last active September 6, 2017 21:14
Comparing times of manually compiling Expression Tree vs Expression.Compile and result delegates invoke times
/*
Results:
Compile Expression 3000 times: 814
Invoke Compiled Expression 5000000 times: 724
Emit from Expression 3000 times: 36
Run Emitted Expression 5000000 times: 722
*/
using System;
@dadhi
dadhi / DryIoc_Issue164_EventAggregator.cs
Created September 17, 2015 16:22
DryIoc_Issue164_EventAggregator
using System;
using NUnit.Framework;
namespace DryIoc.IssuesTests
{
[TestFixture]
public class Issue164_EventAggregatorImpl
{
[Test]
public void Able_to_handle_multiple_events_being_singleton()
@dadhi
dadhi / InsertTabsOrSpaces-vc2010macro.vb
Last active October 26, 2017 09:19
Visual Studio 2010 macros to set "Insert spaces" or "Keep tabs" in Tools -> Options -> Text Editor -> C# -> Tabs page. Thanks to answer http://stackoverflow.com/a/1721896/2492669. For those who switching between solutions with spaces and tabs. As for me, I have assigned macros on ctrl+shift+alt+s and ctrl+shift+alt+t and quite happy now.
Option Strict Off
Option Explicit Off
Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports EnvDTE90a
Imports EnvDTE100
Imports System.Diagnostics
@dadhi
dadhi / NServiceBus_PipelineExecutionExtensions.cs
Last active November 12, 2017 19:45
NServiceBus PipelineExecutionExtensions implementation based on FastExpressionCompiler.ExpressionInfo
#define USE_EXPRESSION_INFO // I am here!
namespace NServiceBus
{
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Threading.Tasks;
@dadhi
dadhi / Cofree.cs
Last active December 28, 2017 08:08
C# Cofree experiments from John De Goes talk https://www.youtube.com/watch?v=R_nYc4FItcI
using System;
namespace FP
{
// final case class Cofree[F[_], A](head: A, tail: F[Cofree[F, A]])
public interface ICofree<F, _, A>
{
A Head { get; }
CofreeF Tail<CofreeF>() where CofreeF : ICofree<F, _, A>;
}