Skip to content

Instantly share code, notes, and snippets.

View akimboyko's full-sized avatar

Akim Boyko akimboyko

View GitHub Profile
akimboyko / gist:4538388
Created January 15, 2013 12:45
Ninject Contextual Binding for different environments
void Main()
// create kernel with conventions
using(var kernel = InitializeKernel())
var backend = kernel.Get<IBackend>();
Assert.That(backend, Is.Not.InstanceOfType(typeof(ProdBackend))
akimboyko / gist:4258647
Created December 11, 2012 13:41
PowerShell exception re-throwing sample
Write-Host 'throw'
throw "exception"
akimboyko / 01_SayHello.fsx
Last active May 28, 2023 13:00
Samples from "Actor-based Concurrency with F# and Akka.NET"
#time "on"
#load "Bootstrap.fsx"
open System
open Akka.Actor
open Akka.Configuration
open Akka.FSharp
open Akka.TestKit
// #Using Actor
akimboyko / gist:4622557
Last active February 23, 2022 07:11
Custom scope for Ninject that returns same instance based on first constructor argument. Using both kernel and factory
void Main()
using(var kernel = new StandardKernel(new Module()))
kernel.Load<FuncModule>(); // for sake of LinqPAD
var instance1 = kernel.Get<MyClass>(new ConstructorArgument("myArg", "test"));
var instance2 = kernel.Get<MyClass>(new ConstructorArgument("myArg", "test"));
Assert.That(instance1, Is.Not.Null.And.SameAs(instance2));
akimboyko /
Last active April 23, 2019 17:29
Let's play with a simple TCP server with SO_REUSEPORT
import socket
import sys
from contextlib import contextmanager
import click
so_reuseport = socket.SO_REUSEPORT
akimboyko / FsCheckSamples.fsx
Last active March 27, 2019 08:04
Samples for Property-based testing using FsCheck for F# and C# talk for Kiev Alt.NET
#I @".\packages\FsCheck.\lib\net40-Client\"
#r @"FsCheck.dll"
// #time "on"
open FsCheck
// simple example
let revRevIsOrig (xs:list<int>) = List.rev(List.rev xs) = xs
Check.Quick revRevIsOrig;;
akimboyko / gist:4457261
Created January 4, 2013 21:47
AOP: handwritten tracing decorator
void Main()
TraceDecorator.Aspect(() => StaticLogic.SuccessfulCall());
TraceDecorator.Aspect(() => StaticLogic.ExceptionCall());
TraceDecorator.Aspect(() => StaticLogic.SuccessfulCallWithReturn(42)).Dump();
TraceDecorator.Aspect(() => StaticLogic.ExceptionCallWithReturn(42)).Dump();
public static class TraceDecorator
akimboyko /
Last active February 2, 2019 00:02
Scripting: `eval()`-like for C# using Roslyn and ScriptCS
  • Install Chocolatey
  • Reopen console application (for example cmd.exe) to update %PATH% and other environment variables
  • Install ScriptCs using chocolatey
  • Save both Roslyn-EvalSample.csx and packages.config
  • Install dependencies using scriptcs -install
  • Run scriptcs .\Roslyn-EvalSample.csx
akimboyko /
Last active October 22, 2018 08:45
ScriptCs as embedded scripting engine for .Net application with NuGet support

ScriptCs as embedded scripting engine for .Net application with NuGet support

This gist contains:

  • ExecuteScriptCs.cs — class that are able to execute ScriptCs from another .Net application
  • ScriptModule.cs — AutoFac configuration for ScriptCs/NuGet dependencies
  • Program.cs — command-line example
  • Sample.csx — sample ScriptCs script
  • packages.config — NuGet packages configuration
akimboyko / gist:4530162
Created January 14, 2013 13:48
How to intercept method with custom attribute using DynamicProxy
void Main()
ProxyGenerator proxyGenerator = CreateProxyGenerator();
IService proxy =
.CreateInterfaceProxyWithTargetInterface(new Service() as IService, new TracingInterceptorAspect());