This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@searchBox.keyupAsObservable() | |
.select((ev) -> $(ev.target).val()) | |
.where((text) -> text.length > 2) | |
.throttle(500) | |
.distinctUntilChanged() | |
.select(@searchItems) | |
.switchLatest() | |
.subscribe(@handleItemSearchAutoCompleteSuccess) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AutofacScopedHubActivator : IHubActivator | |
{ | |
private readonly ILifetimeScope rootScope; | |
public AutofacScopedHubActivator(ILifetimeScope rootScope) | |
{ | |
this.rootScope = rootScope; | |
} | |
public HubActivationResult Create(HubDescriptor descriptor) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[AttributeUsage(AttributeTargets.Property, AllowMultiple = false, Inherited = false)] | |
public sealed class CsvEntryAttribute : Attribute | |
{ | |
public string HeaderName { get; set; } | |
} | |
public class CsvParser | |
{ | |
private class CsvDescriptor | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class SystemTime | |
{ | |
private static Func<DateTime> now = () => DateTime.Now; | |
public static Func<DateTime> Now | |
{ | |
get { return now; } | |
set { now = value; } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Utils = | |
let private rng = new Random() | |
let rec PickRandomPair<'TKey when 'TKey : equality> (pool:('TKey * int) list) = | |
let decreasePair(needle:'TKey, pool:('TKey * int) list) = | |
let decrease (key:'TKey, value:int) = if key = needle then (key, value - 1) else (key, value) | |
pool |> Seq.fold (fun acc r -> (decrease(r) :: acc)) [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module BaseTest = | |
[<TestFixture>] | |
[<AbstractClass>] | |
type public AggregateTest<'TState, 'TCommand, 'TEvent>() = | |
abstract member For: Aggregate<'TState, 'TCommand, 'TEvent> | |
abstract member Given: 'TEvent list | |
abstract member When: 'TCommand | |
abstract member Then: ('TState -> unit) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let spawn (f:(unit -> unit)) = let t = new Thread(f) in t.Start(); t | |
let valueStm = newTVar 0 | |
let incStm() = stm { | |
let! current = readTVar valueStm | |
let newValue = current + 1 | |
do! writeTVar valueStm newValue | |
} | |
let funcStm() = for _ in 1..10000 do incStm() |> atomically |> ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Maybe a = Just a | Nothing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TypeFamilies #-} | |
import Data.Function (on) | |
import Control.Applicative | |
data EventData e = EventData { | |
eventId :: Int, | |
body :: Event e | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.concurrent.{Executors, TimeUnit} | |
import scala.concurrent.duration.Duration | |
import scala.concurrent.{Await, ExecutionContext, Future} | |
import scalaz.Applicative | |
import scalaz.syntax.applicative._ | |
object Main extends App { | |
implicit def applicativeFuture(implicit executionContext:ExecutionContext) = new Applicative[Future] { | |
override def point[A](a: => A): Future[A] = Future.successful(a) |
OlderNewer