Skip to content

Instantly share code, notes, and snippets.

Wojtek wklm

Block or report user

Report or block wklm

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View exc.fs
let parse (buffer : byte []) =
try
JsonSerializer.DeserializeAsync<'T>(IO.MemoryStream(buffer))
|> Async.AwaitTask
|> Some
with _ -> None
View gist:04351f6cb04c8f4e5494c0f69c2af921
module Socket
open Microsoft.AspNetCore.SignalR
open Microsoft.AspNetCore.SignalR.Client
open Microsoft.AspNetCore.Sockets
let x = HubConnectionBuilder()
.WithUrl("http://socket-stage.bittrex.com/signalr")
@wklm
wklm / WebSocketHelpers.fs
Created Nov 27, 2017 — forked from TheAngryByrd/WebSocketHelpers.fs
FSharpWebSocketHelpers
View WebSocketHelpers.fs
module WebsocketHelpers =
open System
open System.Net.WebSockets
open System.Threading
open Hopac
let readMessage messageType (stream : #IO.Stream) (socket : WebSocket) = job {
let buffer = new ArraySegment<Byte>( Array.create (1500) Byte.MinValue)
let rec readTillEnd' () = job {
let! (result : WebSocketReceiveResult) = socket.ReceiveAsync(buffer,CancellationToken.None)
View p.fs
module Bittrex
open Asset
open Bittrex.Net
open Deedle
let internal rest = new BittrexClient()
let internal webSockets = new BittrexSocketClient()
let marketHistory (pair : AssetPair) =
@wklm
wklm / checked.fs
Last active Nov 5, 2017
F# Checked arithmetic operator overloading example
View checked.fs
open System
let (+) x y = Checked.(+) x y
let number = Random().Next()
let rec guess (lower, upper) =
let x = (lower + upper) / 2
if number > x then
guess (x, upper)
View gist:8dcab36eea94b43a5a7fe0480ef59b37
wojtek@pcuds54:~/Desktop/smieci/fsharp/fsharponacci$ oc project test-ci-openshift-no-fim
Now using project "test-ci-openshift-no-fim" on server "https://openshift-dev.cern.ch:443".
wojtek@pcuds54:~/Desktop/smieci/fsharp/fsharponacci$
wojtek@pcuds54:~/Desktop/smieci/fsharp/fsharponacci$
wojtek@pcuds54:~/Desktop/smieci/fsharp/fsharponacci$ oc create sa other-admin
serviceaccount "other-admin" created
wojtek@pcuds54:~/Desktop/smieci/fsharp/fsharponacci$ oc policy add-role-to-user admin system:serviceaccounts:test-devforumci-preview:other-admin
role "admin" added: "system:serviceaccounts:test-devforumci-preview:other-admin"
wojtek@pcuds54:~/Desktop/smieci/fsharp/fsharponacci$ oc new-app --token=$(oc sa get-token other-admin) registry.access.redhat.com/dotnet/dotnet-20-rhel7~https://gitlab.cern.ch/wkulma/devforum
--> Found Docker image 9c4630d (2 weeks old) from registry.access.redhat.com for "registry.access.redhat.com/dotnet/dotnet-20-rhel7"
View gist:51e314d26ccad5526438b35b09210285
wojtek@pcuds54:~/Desktop/smieci/fsharp/fsharponacci$ oc project test-devforumci-preview
Now using project "test-devforumci-preview" on server "https://openshift-dev.cern.ch:443".
wojtek@pcuds54:~/Desktop/smieci/fsharp/fsharponacci$ oc create sa other-admin
serviceaccount "other-admin" created
wojtek@pcuds54:~/Desktop/smieci/fsharp/fsharponacci$ oc policy add-role-to-user admin system:serviceaccounts:test-devforumci:other-admin
role "admin" added: "system:serviceaccounts:test-devforumci:other-admin"
wojtek@pcuds54:~/Desktop/smieci/fsharp/fsharponacci$ oc new-app --token=$(oc sa get-token other-admin) registry.access.redhat.com/dotnet/dotnet-20-rhel7~https://gitlab.cern.ch/wkulma/devforum
--> Found Docker image 9c4630d (2 weeks old) from registry.access.redhat.com for "registry.access.redhat.com/dotnet/dotnet-20-rhel7"
.NET Core 2.0
View gist:084ca4917030f9ed97f4f441a754bf3f
wojtek@pcuds54:~/Desktop/smieci/fsharp/fsharponacci$ oc status
In project test-devforumci on server https://openshift-dev.cern.ch:443
You have no services, deployment configs, or build configs.
Run 'oc new-app' to create an application.
wojtek@pcuds54:~/Desktop/smieci/fsharp/fsharponacci$ oc get sa
NAME SECRETS AGE
builder 2 2d
default 2 2d
deployer 2 2d
@wklm
wklm / fib.fs
Last active Sep 24, 2017
fibonacci async
View fib.fs
let rec fib = function
| 0L | 1L as n -> n
| n -> (fib (n - 1L) + fib (n - 2L))
let memoize f =
let memo = ref Map.empty
fun arg ->
if Map.containsKey arg !memo then Map.find arg !memo
else
let result = f arg
@wklm
wklm / silicon-valley.fs
Last active Sep 14, 2017
Suave + Chrion nested jsons simple example
View silicon-valley.fs
module Program
open Chiron
open Suave
open Suave.Filters
open Suave.Json
open Suave.Operators
open Suave.Successful
You can’t perform that action at this time.