brew install node
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
(* | |
An incomplete implementation of a type-safe SQL query in F#. | |
The idea is that a query is built up clause by clause, by representing | |
each additional clause being added on to the query as a state transition | |
between different types of queries. We capture these different types as | |
phantom types to make sure that only valid transitions (query clause | |
additions) as defined by us can be carried out. | |
The final result is a 'total query' that can be converted to a string, |
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
let ParallelThrottledIgnore (startOnCallingThread:bool) (parallelism:int) (xs:seq<Async<_>>) = async { | |
let! ct = Async.CancellationToken | |
let sm = new SemaphoreSlim(parallelism) | |
let count = ref 1 | |
let res = TaskCompletionSource<_>() | |
let tryWait () = | |
try sm.Wait () ; true | |
with _ -> false | |
let tryComplete () = | |
if Interlocked.Decrement count = 0 then |
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
let timeoutNone (timeoutMs:int) (a:Async<'a>) : Async<'a option> = async { | |
let! ct = Async.CancellationToken | |
let res = TaskCompletionSource<_>() | |
use cts = CancellationTokenSource.CreateLinkedTokenSource ct | |
res.Task.ContinueWith (fun _ -> cts.Cancel ()) |> ignore | |
use timer = new Timer((fun _ -> res.TrySetResult None |> ignore), null, timeoutMs, Timeout.Infinite) | |
Async.StartThreadPoolWithContinuations ( | |
a, | |
(fun a -> res.TrySetResult (Some a) |> ignore), | |
(fun e -> res.TrySetException e |> ignore), |
This tutorial was created by Shopify for internal purposes. We've created a public version of it since we think it's useful to anyone creating a GraphQL API.
It's based on lessons learned from creating and evolving production schemas at Shopify over almost 3 years. The tutorial has evolved and will continue to change in the future so nothing is set in stone.
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
$userPath = $env:USERPROFILE | |
$pathExclusions = New-Object System.Collections.ArrayList | |
$processExclusions = New-Object System.Collections.ArrayList | |
$pathExclusions.Add('C:\Windows\Microsoft.NET') > $null | |
$pathExclusions.Add('C:\Windows\assembly') > $null | |
$pathExclusions.Add($userPath + '\AppData\Local\Microsoft\VisualStudio') > $null | |
$pathExclusions.Add('C:\ProgramData\Microsoft\VisualStudio\Packages') > $null | |
$pathExclusions.Add('C:\Program Files (x86)\MSBuild') > $null | |
$pathExclusions.Add('C:\Program Files (x86)\Microsoft Visual Studio 14.0') > $null |
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
// F<'a> is any type with member 'map' of type ('a -> 'b) -> F<'a> -> F<'b> | |
type F<'a> = QIL<'a> | |
and S<'a> = F<Q<'a>> | |
and Q<'a> = | |
private | |
| Step of Step<'a> | |
| Bind of IBind<'a> | |
with | |
static member lift (k : F<'a>) : Q<'a> = Step (Suspend (fun () -> S<_>.map (Yield >> Step) k)) |
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
#r @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.Solver.Foundation.dll" | |
module ZebraPuzzle = | |
open System | |
open Microsoft.SolverFoundation.Services | |
let solve() = | |
let context = SolverContext.GetContext() | |
let rootModel = context.CreateModel() | |
let person = rootModel.CreateSubModel("Person") |
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
var url = "http://localhost:8082/consumers/my_binary_consumer/instances/my_instance/topics/test"; | |
using (var client = new HttpClient()) | |
{ | |
client.Timeout = TimeSpan.FromMilliseconds(Timeout.Infinite); | |
var request = new HttpRequestMessage(HttpMethod.Get, url); | |
using (var response = await client.SendAsync( | |
request, | |
HttpCompletionOption.ResponseHeadersRead)) |
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
(* | |
Simulation of the Lorentz attractor, using Fable. | |
If you want to see this code in action, just copy this code into the Fable REPL: | |
https://fable.io/repl/ | |
*) | |
module App | |
open Elmish | |
open Elmish.React |