Skip to content

Instantly share code, notes, and snippets.

[<RequireQualifiedAccess>]
module Async =
let map handler work = async {
let! work = work
return handler work }
(* QUEUES
https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.queue-1
*)
// 1.0 Basic queue - hand-rolled
let q = System.Collections.Generic.Queue<string>()
q.Enqueue "Hello"
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"resources": [
{
"apiVersion": "2016-08-01",
"dependsOn": [
"sites_omg_backend_name-plan"
// Change this to your profile folder for nuget packages
#I @"C:\Users\Isaac\.nuget\packages\"
#r @"XPlot.GoogleCharts\2.0.0\lib\netstandard2.0\XPlot.GoogleCharts.dll"
#r @"Newtonsoft.Json\12.0.3\lib\netstandard2.0\Newtonsoft.Json.dll"
#r @"Google.DataTable.Net.Wrapper\4.0.0\lib\netstandard2.0\Google.DataTable.Net.Wrapper.dll"
open System
open XPlot.GoogleCharts
/// Executes an asynchronous workflow and provides some simple statistics on the results.
let x =
[| 1 .. 10 |]
|> Array.map(fun n -> async {
printfn "Starting %d" n
do! Async.Sleep 1000
printfn "Done %d" n
return n * 1000
})
let x2 = Async.Parallel(x, 1) |> Async.RunSynchronously
module Async =
let Bind continuation wf = async {
let! wf = wf
return! continuation wf
}
let Map continuation = Bind (continuation >> async.Return)
// e.g.
let workflow = async { return 10 }
let (|Mod|_|) div value =
if value % div = 0 then Some() else None
let fizzBuzz = function
| Mod 3 & Mod 5 -> "FizzBuzz"
| Mod 3 -> "Fizz"
| Mod 5 -> "Buzz"
| n -> string n
[ 1 .. 100 ]
@isaacabraham
isaacabraham / sample.json
Created November 22, 2019 14:48
Invalid ARM template for app service on linux
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"resources": [
{
"apiVersion": "2016-08-01",
"dependsOn": [
"mysuperwebappisaac-plan",
let x = "TEST".Split ", " |> Array.item 1
Unhandled exception. System.AggregateException: One or more errors occurred. (Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.)
---> System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
---> System.ComponentModel.Win32Exception (258): The wait operation timed out.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParserStateObject.ThrowExceptionAndWarning(Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParserStateOb