Skip to content

Instantly share code, notes, and snippets.

View mastoj's full-sized avatar

Tomas Jansson mastoj

View GitHub Profile
@mastoj
mastoj / Error.txt
Last active January 27, 2016 15:16
Unwind sample
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
@mastoj
mastoj / fowler_fsm.fsx
Last active February 12, 2016 23:18
Simple FSM in F#. The fowler_fsm.fsx is an F# implementation of Miss Grant's controller from Fowler's DSL book: http://www.informit.com/articles/article.aspx?p=1592379&seqNum=2
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
}
/// 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 {
#r "packages/Suave/lib/net40/Suave.dll"
open System
open Suave
open Suave.Filters
open Suave.Successful
open Suave.RequestErrors
open System.Text.RegularExpressions
[<AutoOpen>]
@mastoj
mastoj / README
Last active March 8, 2016 23:02
FAKE build script with spawn, run, stop and attach
Copy `build.fsx` manually to root as a starting point for your build file.
open Microsoft.FSharp.Reflection
module MA =
type A = { AStr: string}
type B = { BInt: int}
type private DU =
| A of A
| B of B
@mastoj
mastoj / RouteParser.fsx
Last active August 14, 2016 19:27
Parser proof of concept for fable.
(*
Based on the excellent blog series by Scott Wlaschin: http://fsharpforfunandprofit.com/posts/understanding-parser-combinators/
Inspired by Elm Route Parser: http://package.elm-lang.org/packages/etaque/elm-route-parser/2.2.1/
*)
[<AutoOpen>]
module Parsing =
open System
@mastoj
mastoj / Program.cs
Created September 9, 2016 09:42
Show the difference between multiple await and Task.WhenAll
using System;
using System.CodeDom;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AsyncDiff
{
type Time = int*int
type Day = int
type OpeningHour = Day*Time
type DayGroup =
{
Days: int list
Time: Time
}
let openingHour day startTime endTime = day,(startTime,endTime)
@mastoj
mastoj / paket.dependencies
Created February 3, 2017 08:04
VS Code/ionide error
source https://nuget.org/api/v2
nuget FSharp.Data framework: net45
nuget MySql.Data framework: net45