Skip to content

Instantly share code, notes, and snippets.

@MangelMaxime
MangelMaxime / MapboxGL.fs
Created July 20, 2017 12:12
Fable MapboxGL bindings
namespace Fable.Import
open System
open System.Text.RegularExpressions
open Fable.Core
open Fable.Import.JS
open Fable.Import.Browser
module Mapboxgl =
type [<AllowNullLiteral>] [<Import("Map","mapboxgl")>] Map(?options: MapboxOptions) =
inherit Evented()
let keyboardCaptureHandler (keyboard: Keyboard.Record) =
match keyboard.Modifiers with
| { Control = true } ->
match keyboard.LastKey with
| Keyboard.Keys.O ->
window2.Closed <- false
true // Key has been captured
| _ -> false
| _ ->
match keyboard.LastKey with
@MangelMaxime
MangelMaxime / Example.fs
Created October 24, 2017 12:35
Fable.Helpers.ReactLeaflet
open Fable.Helpers.React
open Fable.Helpers.React.Props
module RL = Fable.Helpers.ReactLeaflet
let group =
let truckTracks =
zones.paths
|> Array.map(fun path ->
@MangelMaxime
MangelMaxime / App.fs
Created July 19, 2018 11:37
Example usage of vis.js with Fable
module Client
open Fable.Core
open Fable.Core.JsInterop
open Fable.Import
importSideEffects "vis/dist/vis.css"
[<Import("*", "vis")>]
@MangelMaxime
MangelMaxime / Async.hx
Last active May 13, 2024 09:43
Demonstrate how to use native async/await from JavaScript with haxe.
package async;
#if macro
import haxe.macro.Context;
#end
class Async {
public static macro function async(expr:haxe.macro.Expr) {
expr = Context.storeTypedExpr(Context.typeExpr(expr));
return macro untyped __js__("(async {0})", ${expr})();
@MangelMaxime
MangelMaxime / Http.fs
Created March 26, 2019 15:43
Http.fs - Demonstrate a way to retry fetching a new access token when old one expired
[<RequireQualifiedAccess>]
module Http
open Fable.Import
open Fable.PowerPack
open Fable.PowerPack.Fetch
open Thoth.Json
open Fable.Core.JsInterop
type User =
@MangelMaxime
MangelMaxime / Main.fs
Created May 16, 2019 09:16
Demontraste how to store a section of a JSON without decoding/validating it
module Tests.Main
open Expecto
open Util.Testing
open Thoth.Json.Net
let json =
"""
{
"name": "Test HTTP Scenario",
@MangelMaxime
MangelMaxime / fable-repl.css
Last active June 26, 2019 19:32
Showcase throttle on input from view
html,
body {
font-size: 16px;
}
.main-container {
display: flex;
width: 100%;
height: 100%;
justify-content: center;
@MangelMaxime
MangelMaxime / fable-repl.css
Created June 26, 2019 20:11
"Pure Elmish" implementation of TIME FLIES LIKE AN ARROW example
html,
body {
font-size: 16px;
}
.main-container {
display: flex;
width: 100%;
height: 100%;
justify-content: center;
@MangelMaxime
MangelMaxime / fable-repl.css
Created June 27, 2019 13:51
Drag & Drop using Elmish and React hooks
html,
body {
font-size: 16px;
}