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
using System; | |
using System.Threading; | |
namespace PureDI | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
// Create the singletons once |
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
MIT License | |
Copyright (c) 2014 Jan Brestan | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: |
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 filesToExcludeFromTestCoverage rootDir projectExcludes = | |
rootDir</>"paket.lock" | |
|> File.ReadLines | |
|> Seq.choose (fun line -> | |
// Expecting paket.lock line format for dependencies and transitive dependencies, e.g.: | |
// xunit (2.3) | |
// xunit.analyzers (>= 0.7) | |
// We'll use the version to recognize it from `remote: <url>` definitions, but take just the package name. | |
match Regex.Match(line,"^[ ]{4,6}([^ ]+) \((.+)\)") with | |
| m when m.Success && m.Groups.Count = 3 -> Some m.Groups.[1].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
let rec retryForever (delay: TimeSpan) (workflow: Async<Result<_, _>>) = async { | |
(* | |
this always fully executes the `workflow` again, | |
no result caching like Task's Result property | |
*) | |
let! result = workflow | |
match result with | |
| Ok r -> | |
return Ok r | |
| Error _ -> |
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
fizzbuzz n = last $ zipWith fb fbs [1..n] | |
where | |
fbs = zipWith (++) (cycle ["","","fizz"]) (cycle ["","","","","buzz"]) | |
fb s m = if s == "" then (show m) else s | |
map fizzbuzz [1..100] |
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
type Result<'result, 'message> = | |
| Success of 'result | |
| Failure of 'message list | |
[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] | |
module Result = | |
let inline succeed v = | |
Success v | |
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 ExponentialBackoff = | |
open System | |
[<Measure>] type ms | |
type Backoff = | |
| Immediate | |
| Initial | |
| Double of previousDelay: int<ms> |
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 Reducees = | |
type Instruction = Cont | Done | Halt | |
let rec reduce source instruction func = | |
match source, instruction with | |
| head::tail, (Cont, acc) -> reduce tail (func head acc) func | |
| [], (Cont, acc) -> Done, acc | |
| _ -> instruction |
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 IDictionary<string, TValue> Dict<TValue>( | |
params Func<dynamic, TValue>[] pairs) | |
{ | |
return pairs.ToDictionary(pair => pair.Method.GetParameters()[0].Name, | |
pair => pair(null)); | |
} |
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 AutoLogger : DynamicObject | |
{ | |
private readonly Action<string> _logMethod; | |
const string SplitterName = "splitNameBy"; | |
public AutoLogger(Action<string> logMethod) | |
{ | |
_logMethod = logMethod; | |
} |
NewerOlder