Skip to content

Instantly share code, notes, and snippets.

View Dzoukr's full-sized avatar
:octocat:
Hacking F#

Roman Provazník Dzoukr

:octocat:
Hacking F#
View GitHub Profile
@Dzoukr
Dzoukr / Declarative.cs
Last active February 16, 2021 14:14 — forked from rarous/1.cs
Imperative vs Declarative
static Maybe<string> TryGetErrorMessage(XElement html)
{
return html.GetElementsByClassName("ErrorMessage").MaybeFirst().
Where(x => !x.Attributes("style").Any()
|| !x.Attribute("style").Value.Contains("visibility:hidden")).
Or(html.GetElementsByClassName("ErrorText").MaybeFirst()).
Select(x => x.Value.Trim());
}
@Dzoukr
Dzoukr / pre-request.js
Created August 10, 2020 18:16 — forked from landy/pre-request.js
Load Bearer token on each postman request
//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 June 12, 2020 12:30 — forked from aspnetde/App.fs
Feliz – MVU with React Function Components
module App
open Elmish
type State =
{ CurrentUser: string option }
type Msg =
| SignIn of string
| SignOut
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 / Dapper.fs
Created August 3, 2017 09:53 — forked from vbfox/Dapper.fs
Minimal dapper in F#
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 =