Skip to content

Instantly share code, notes, and snippets.

Avatar

Steffen Forkmann forki

View GitHub Profile
View wbsocket.fs
let inline websocket<'Data> =
FunctionComponent.Of(fun (props: {| url : string; retryTimeSpan : TimeSpan; onConnected: bool -> unit; onMessage: 'Data -> unit |}) ->
let mutable currentlyConnected = false
let mutable wasAlreadyConnected = false
let connected = Hooks.useState false
let mutable webservice = null
let connect() =
if currentlyConnected then () else
let ws = WebSocket.Create(props.url)
View socket.fs
FunctionComponent.Of(fun (props: {| url : string; retryTimeSpan : TimeSpan; onMessage: 'Data -> unit |}) ->
let connected = Hooks.useState(false)
let wasClosed = Hooks.useState(false)
let register() =
printfn "Trying to connect"
let ws = create props.url
ws.onclose <- unbox (fun _ ->
match ws.readyState with
View farmer.lol
Deploying ARM template (please be patient, this can take a while)...
Unhandled exception. System.Exception: Azure Error: DeploymentActive
Message: Unable to edit or replace deployment 'farmer-deploy-2997': previous deployment from '6/2/2020 9:53:26 AM' is still active (expiration time is '6/9/2020 9:53:25 AM'). Please see https://aka.ms/arm-deploy for usage details.
at Farmer.Deploy.execute(String resourceGroupName, FSharpList`1 parameters, Deployment deployment)
at <StartupCode$Infrastructure>.$Program.main@() in /home/gitlab-runner/builds/e76ee70f/0/products/eCarApp/infrastructure/Program.fs:line 86
View errormessage.txt
JSON parsing failed on {"sourceType":"module","body":[{"specifiers":[{"imported":{"name":"toFail","type":"Identifier"},"local":{"name":"toFail","type":"Identifier"},"type":"ImportSpecifier"},{"imported":{"name":"toText","type":"Identifier"},"local":{"name":"toText","type":"Identifier"},"type":"ImportSpecifier"},{"imported":{"name":"printf","type":"Identifier"},"local":{"name":"printf","type":"Identifier"},"type":"ImportSpecifier"},{"imported":{"name":"validateGuid","type":"Identifier"},"local":{"name":"validateGuid","type":"Identifier"},"type":"ImportSpecifier"},{"imported":{"name":"join","type":"Identifier"},"local":{"name":"join","type":"Identifier"},"type":"ImportSpecifier"}],"source":{"value":"../fable-library.2.9.0/String.js","type":"StringLiteral"},"type":"ImportDeclaration"},{"specifiers":[{"imported":{"name":"int16ToString","type":"Identifier"},"local":{"name":"int16ToString","type":"Identifier"},"type":"ImportSpecifier"},{"imported":{"name":"mapCurriedArgs","type":"Identifier"},"local":{"name":"mapCu
View conatiner.fs
let frontendService (operatorID:string) = webApp {
name (operatorID + "-frontend")
docker_image frontendImage frontendStartup
app_insights_off
link_to_service_plan appServicePlanName
setting "DOCKER_ENABLE_CI" "true"
setting "DOCKER_REGISTRY_SERVER_PASSWORD" dockerPassword
setting "DOCKER_REGISTRY_SERVER_URL" containerRegistryDomain
setting "DOCKER_REGISTRY_SERVER_USERNAME" containerRegistry
View currying.fs
let withdrawWithAudit = withdraw |> auditAs "withdraw" Auditing.fileSystem
let depositWithAudit = deposit |> auditAs "deposit" Auditing.fileSystem
while true do
let action =
Console.WriteLine()
printfn "Current balance is £%M" account.Balance
Console.Write "(d)eposit, (w)ithdraw or e(x)it: "
Console.ReadLine()
View paket.lock
GROUP AzureFunctions
STORAGE: NONE
RESTRICTION: == netcoreapp3.0
NUGET
remote: https://api.nuget.org/v3/index.json
Braintree (4.16)
Newtonsoft.Json (>= 9.0.1)
System.Xml.XPath.XmlDocument (>= 4.3)
ExcelDataReader (3.6)
FSharp.Core (4.7)
View paket.dependencies
group AzureFunctions
source https://api.nuget.org/v3/index.json
framework: netcoreapp3.0
storage: none
nuget FSharp.Core
nuget Microsoft.NET.Sdk.Functions
nuget Microsoft.Azure.WebJobs.Extensions.Storage
nuget Microsoft.AspNetCore.Mvc
nuget WindowsAzure.Storage
View myFun.fs
let myFun fmt =
Printf.ksprintf (fun text ->
text.Replace("1","one").Replace("2","two") // <- this is naive
) fmt
let newText = myFun "%d-%d" 1 2
printfn "%s" newText
View SocketStop.fs
module SocketStop
open Microsoft.Azure.WebJobs
open System.Net.Http
open FSharp.Control.Tasks.ContextInsensitive
open Microsoft.Azure.WebJobs.Extensions.Http
open Microsoft.Extensions.Logging
open Microsoft.AspNetCore.Mvc
[<FunctionName("SocketStop")>]