This file contains hidden or 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
/// Discriminated union representing two messages - one for sending | |
/// numbers to the agent and one for resetting the state of the agent | |
type CounterMessage = | |
| Update of float | |
| Reset | |
// Simple agent that calculates average and can be reset | |
let counter = MailboxProcessor.Start(fun agent -> | |
let rec loop sum count = async { |
This file contains hidden or 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 FSM = | |
type FSM<'TState, 'TEvent, 'TCommand when 'TEvent : comparison and 'TState : comparison> = | |
{ | |
Transitions: Map<'TState, Map<'TEvent, 'TState>> | |
CurrentState: 'TState | |
InitState: 'TState | |
Commands: Map<'TState, 'TCommand list> | |
ResetEvents: 'TEvent list | |
CommandChannel: 'TCommand -> unit | |
} |
This file contains hidden or 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
System.Threading.Tasks.TaskCanceledException: {"A task was canceled."} | |
at Neo4jClient.GraphClient.Neo4jClient.IRawGraphClient.ExecuteCypher(CypherQuery query) in D:\temp\8815004\Neo4jClient\GraphClient.cs:line 1053 | |
at Neo4jClient.Cypher.CypherFluentQuery.ExecuteWithoutResults() in D:\temp\8815004\Neo4jClient\Cypher\CypherFluentQuery.cs:line 388 | |
at [email protected](FSharpList`1 data) in C:\dev\git\Sfag\src\Sfag.GraphView\WriteToNeo4j.fs:line 37 | |
at Microsoft.FSharp.Primitives.Basics.List.iter[T](FSharpFunc`2 f, FSharpList`1 x) | |
at Microsoft.FSharp.Collections.ListModule.Iterate[T](FSharpFunc`2 action, FSharpList`1 list) | |
at WriteToNeo4j.mergeNodes[T](GraphClient client, NodeMetaData nodeMeta, IEnumerable`1 nodes) in C:\dev\git\Sfag\src\Sfag.GraphView\WriteToNeo4j.fs:line 33 | |
at [email protected](IEnumerable`1 nodes) in C:\dev\git\Sfag\src\Sfag.GraphView\WriteToNeo4j.fs:line 107 | |
at IndexingImpl.saveState(GraphClient client, IndexingState state) in C:\de |
This file contains hidden or 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 CachingAgent | |
open System | |
type AgentCacheMessage<'T> = AsyncReplyChannel<'T> | |
type Agent<'T> = MailboxProcessor<'T> | |
let CreateCache<'T> timespan (funcGen:Func<'T>) = Agent.Start(fun inbox -> | |
let rec loop expire (cached:Lazy<'T>) = async { | |
let! (message:AgentCacheMessage<'T>) = inbox.Receive() | |
let renew = expire <= DateTime.Now | |
let cached' = if renew then lazy (funcGen.Invoke()) else cached |
This file contains hidden or 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
Stacktrace: | |
at <unknown> <0xffffffff> | |
at (wrapper managed-to-native) System.MonoCustomAttrs.GetCustomAttributesInternal (System.Reflection.ICustomAttributeProvider,System.Type,bool) <0xffffffff> | |
at System.MonoCustomAttrs.GetCustomAttributesBase (System.Reflection.ICustomAttributeProvider,System.Type,bool) <0x00053> | |
at System.MonoCustomAttrs.GetCustomAttributes (System.Reflection.ICustomAttributeProvider,System.Type,bool) <0x0005f> | |
at System.MonoCustomAttrs.RetrieveAttributeUsageNoCache (System.Type) <0x00063> | |
at System.MonoCustomAttrs.RetrieveAttributeUsage (System.Type) <0x000ab> | |
at System.MonoCustomAttrs.IsDefined (System.Reflection.ICustomAttributeProvider,System.Type,bool) <0x000ff> | |
at System.MonoType.IsDefined (System.Type,bool) <0x0001f> |
This file contains hidden or 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
open System | |
open System.Drawing | |
open System.Windows.Forms | |
// Create a form to display the graphics | |
let width, height = 1000, 1000 | |
let form = new Form(Width = width, Height = height) | |
let box = new PictureBox(BackColor = Color.White, Dock = DockStyle.Fill) | |
let image = new Bitmap(width, height) |
This file contains hidden or 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 SokEnhet : ISokEnhet<ElasticSearchKonsesjon> | |
{ | |
public Guid Id { get; set; } | |
public EnhetNummer Enhetsnummer { get; set; } | |
[JsonProperty(TypeNameHandling = TypeNameHandling.Objects)] | |
public IEnhetNavn Navn { get; set; } | |
public string IndeksertNavn => Navn != null ? Navn.LagKortversjon() : ""; | |
public EnhetType Enhetstype { get; set; } | |
public string KortAdresse { get; set; } | |
public List<ElasticSearchKonsesjon> Konsesjoner { get; set; } = new List<ElasticSearchKonsesjon>(); |
This file contains hidden or 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 Car | |
type Make = Make of string | |
type Color = Color of string | |
type Year = Year of int | |
type Car = private {Make: Make; Year: Year; Color: Color} | |
with | |
member a.PrintYear() = printfn "%A" a.Year | |
let print (a:Car) = printfn "%A" a // Car+Car |
This file contains hidden or 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
open System | |
let digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";; | |
let ex = "101010101011101010101011101010101011101010101011";; | |
let convert (chars:string) (ul) = | |
let baseLength = (int64 (chars.Length)) | |
let rec convert' (acc,rest) = | |
if rest = 0L then acc |> List.rev | |
else convert' (chars.[int (rest % baseLength)]::acc,(rest/baseLength)) | |
convert' ([],ul) |
This file contains hidden or 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
open System | |
[<AutoOpen>] | |
module FileHelper = | |
type FileCheck = | |
{ | |
FileName: string | |
Size: int64 | |
} |