Skip to content

Instantly share code, notes, and snippets.

View akimboyko's full-sized avatar
🙃

Akim Boyko akimboyko

🙃
View GitHub Profile
@akimboyko
akimboyko / gist:4593576
Created January 22, 2013 10:20
Ninject factory with custom naming instance provider
void Main()
{
using(var kernel = new StandardKernel(new CarModule()))
{
kernel.Load<FuncModule>(); // for sake of LinqPAD
var factory = kernel.Get<ICarFactory>();
Assert.That(factory, Is.Not.Null);
@akimboyko
akimboyko / !readmt.md
Last active July 26, 2016 20:08
How to disable FSharpLint while building using nCrunch?

Configure FSharpLint

Including The Task In Your Project's Project File Afterwards you will get following build error:

The "FSharpLintTask" task failed unexpectedly.
System.IO.FileNotFoundException: Could not load file or assembly 'FSharpLint.Application, Version=0.1.11.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
File name: 'FSharpLint.Application, Version=0.1.11.0, Culture=neutral, PublicKeyToken=null'

nCrunch conditional build behaviour

@akimboyko
akimboyko / IronPythonScript.cs
Last active April 19, 2016 13:50
Simple performance and readability test: RoslynScript vs. IronPython from C# Performance ratio 1:2,7-3 Readability: both scripting engines required some knowledge about underlying APIs
async void Main()
{
GetType().Assembly.FullName.Dump();
IEnumerable<Model.ProcessingModel> models =
Enumerable.Range(0, 1000000)
.Select(n => new Model.ProcessingModel { InputA = n, InputB = n * 0.5M, Factor = 0.050M });
var sw = Stopwatch.StartNew();
@akimboyko
akimboyko / quotes.txt
Last active January 5, 2016 13:57 — forked from mausch/gist:8227399
Quotes by Erik Meijer from Reactive programming course
"Hopefully the third answer is right; but who knows, maybe I made a mistake; I’m just a human, I can throw exceptions as well."
"I am waving my hands on purpose here, this is very spaghetti like code. And spaghetti is great as food, but not good as code."
"flatMap will allow us to focus on the happy path. flatMap will take care of all the noise. flatMap is the dolby for programmers."
"Great programmers write baby code"
"it's obviously correct"
public static class EnumerableEx
{
public static IEnumerable<R> Select<T1, T2, R>(this IEnumerable<Tuple<T1, T2>> source, Func<T1, T2, R> f)
{
return source.Select(t => f(t.Item1, t.Item2));
}
}
Enumerable.Range(1, 10)
.Select(x => Tuple.Create(x, x))
@akimboyko
akimboyko / DI_patterns.fs
Created January 12, 2014 13:24
DI patterns from Scala adopted to F#: structural typing and currying
// Inspired by Scala and http://skov-boisen.dk/?p=289
type Cell() =
override m.ToString() = "*"
type IGameOfLife =
abstract member Next: IGameOfLife
abstract member Generation : seq<Cell>
// Types for Structural Typing
@akimboyko
akimboyko / BinaryTreeCheck.scala
Created December 22, 2013 14:08
Properties proved by ScalaCheck about BinaryTree from Reactive course week #005
package actorbintree
import scala.concurrent.duration._
import akka.actor.{Props, ActorSystem}
import akka.testkit._
import org.scalacheck.{Gen, Properties}
import org.scalacheck.Prop._
import actorbintree.BinaryTreeSet._
import actorbintree.BinaryTreeSet.Contains
import actorbintree.BinaryTreeSet.OperationFinished
@akimboyko
akimboyko / GameOfLife.scala
Created December 15, 2013 13:13
Game of Life implemented on Scala during Global Day of Coderetreat 2013 at Kiev
package main.scala.com.coderetreat
object GameOfLife {
// data structure
class Cell(x: Int, y: Int) {
val posX = x
val posY = y
override def toString = "Cell: " + x + "," + y
@akimboyko
akimboyko / 1readme.md
Created December 5, 2013 04:23
Why is Future.always useful? Why would I use it if its value is already precomputed?

Future.always is a way to lift a normal value T to a Future[T] value. This lifting pattern is something you will see often in functional programming, so remember it well!

To make its usefulness more apparent - imagine that your API method should either call some Web service or look in the cached responses to see if the Web service was already queried with that request. In the first case you have to return a future Future[String] of a response, and in the second you need to return a response String right away from your cache. Future.always can help you solve this tricky type situation.

@akimboyko
akimboyko / producer_consumer.scala
Created December 2, 2013 16:59
Producer/Consumer from section "Futures and Promises" http://docs.scala-lang.org/overviews/core/futures.html
import scala.concurrent.{ future, promise }
import scala.concurrent.ExecutionContext.Implicits.global
val p = promise[T]
val f = p.future
val producer = future {
val r = produceSomething()
p success r
continueDoingSomethingUnrelated()