Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:
Hacking F#

Roman Provazník Dzoukr

:octocat:
Hacking F#
View GitHub Profile
@Dzoukr
Dzoukr / pre-request.js
Created Aug 10, 2020 — forked from landy/pre-request.js
Load Bearer token on each postman request
View pre-request.js
//add this as pre-request script on postman collection
const moment = require("moment")
const {
apiRoot,
authPath,
username,
password,
bearerTokenValidUntil
} = pm.variables.toObject();
@Dzoukr
Dzoukr / App.fs
Created Jun 12, 2020 — forked from aspnetde/App.fs
Feliz – MVU with React Function Components
View App.fs
module App
open Elmish
type State =
{ CurrentUser: string option }
type Msg =
| SignIn of string
| SignOut
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)
@Dzoukr
Dzoukr / View.fs
Last active Apr 2, 2020
Feliz.Bulma button (minimal example)
View View.fs
Bulma.button [
button.isPrimary
prop.children [
Html.i [ prop.className "fas fa-user"; prop.style [ style.marginRight 5 ] ]
Html.text "Hello Feliz.Bulma"
]
]
@Dzoukr
Dzoukr / Dapper.Extensions.fs
Last active Oct 4, 2019
F# extensions for Dapper
View Dapper.Extensions.fs
module Dapper.Extensions
open System
open System.Data.SqlClient
open Dapper
let extractValue (x:obj) =
match x with
| null -> null
| _ -> match x.GetType().GetProperty("Value") with
@Dzoukr
Dzoukr / Dapper.fs
Created Aug 3, 2017 — forked from vbfox/Dapper.fs
Minimal dapper in F#
View Dapper.fs
module DapperFSharp =
open System.Data.SqlClient
open System.Dynamic
open System.Collections.Generic
open Dapper
let dapperQuery<'Result> (query:string) (connection:SqlConnection) =
connection.Query<'Result>(query)
let dapperParametrizedQuery<'Result> (query:string) (param:obj) (connection:SqlConnection) : 'Result seq =
View Chiron.Extensions.fs
module Chiron.Extensions
let tryDeserializeWith (fromJson : Json<'a>) : Json -> Choice<'a, string> =
fun json ->
match fromJson json with
| JsonResult.Value x, _ -> Choice1Of2(x)
| JsonResult.Error err, _ -> Choice2Of2(err)
let tryDeserializeWithP (_, fromJson : Json<'a>) : Json -> Choice<'a, string> =
tryDeserializeWith fromJson
View FSharp.Rop.fs
module FSharp.Rop
let bind2 f x y =
match x, y with
| Ok xR, Ok yR -> f xR yR
| Error e, _ | _, Error e -> Error e
let apply resultF result =
match resultF with
| Ok f -> Result.map f result
@Dzoukr
Dzoukr / Dockerfile
Created Oct 2, 2015
F# on Mono docker file
View Dockerfile
FROM ubuntu:latest
MAINTAINER Roman Provaznik <dzoukr@dzoukr.cz>
ENV LANG C.UTF-8
RUN apt-get update && apt-get -y -q install mono-complete fsharp
ADD . app/
EXPOSE 8083
ENTRYPOINT ["mono", "/app/SuaveIO.exe"]