Skip to content

Instantly share code, notes, and snippets.

@nojaf
nojaf / script.fsx
Created January 12, 2018 08:25
List of options to list of value
[Some 7; None; Some 6; Some 5]
|> List.choose id
// [7;6;5]
@nojaf
nojaf / main.fs
Created February 20, 2018 10:40
F# Cheatsheet
// Alias tuple
type XmlAddition =
| XmlElementAddition of parent: XPath * childNodeIndex:int * element: XElement
| XmlTextAddition of parent:XPath * textContent: string
| XmlAttributeAddition of node:XPath * attributeName:string * attributeValue:string
@nojaf
nojaf / console.js
Created March 1, 2018 21:39
Temptation Island
var vs = document.querySelectorAll("video"); for(let i = 0;i< vs.length;i++){ vs.item(i).playbackRate = 1.4; }
@nojaf
nojaf / App_1.fsx
Last active June 19, 2019 17:27
Fable Hello world in 2019
#load ".paket/load/main.group.fsx"
printfn "Fable compiled this"
@nojaf
nojaf / GraphQL.fs
Created July 15, 2019 12:29
Boilerplate for GraphQL F# implementation.
module GraphQL.Web
open Microsoft.AspNetCore.Http
open System.IO
open Ronnies.Server.Schema
open Microsoft.AspNetCore.Authentication.JwtBearer
open Microsoft.AspNetCore.Authentication
open FSharp.Data.GraphQL.Execution
open Newtonsoft.Json
open Newtonsoft.Json.Linq
module Hookrouter
open Fable.Core
open Fable.Core.JsInterop
open Fable.React
open Fable.React.Props
open System.Text.RegularExpressions
type InterceptedPath =
string option
// #Regression #NoMono #NoMT #CodeGen #EmittedIL
// Regression test for FSharp1.0:6389 - Nullary union cases improperly constrain generic type parameters
type Weirdo = | C
let f C = 0 // parameter name is C
let g () =
let C = 1
let f C = C // what is parameter name here? Do we even care?
()
@nojaf
nojaf / style.fsx
Created June 2, 2022 16:32
Compiling a Sass file using an F# script
#r "nuget: JavaScriptEngineSwitcher.ChakraCore.Native.win-x64"
#r "nuget: JavaScriptEngineSwitcher.ChakraCore, 3.18.2"
#r "nuget: DartSassHost, 1.0.0-preview7"
#r "nuget: FSharp.Control.Reactive, 5.0.5"
open System
open System.IO
open DartSassHost
open DartSassHost.Helpers
open JavaScriptEngineSwitcher.ChakraCore
[<Test>]
let ``compile FSharp.Core`` () =
let args = [|
@"-o:C:\Users\nojaf\Projects\fsharp\artifacts\obj\FSharp.Core\Debug\netstandard2.0\FSharp.Core.dll"
"-g"
"--debug:embedded"
@"--embed:C:\Users\nojaf\Projects\fsharp\artifacts\obj\FSharp.Core\Debug\netstandard2.0\FSCore.fs"
@"--embed:C:\Users\nojaf\Projects\fsharp\artifacts\obj\FSharp.Core\Debug\netstandard2.0\buildproperties.fs"
@"--embed:C:\Users\nojaf\Projects\fsharp\artifacts\obj\FSharp.Core\Debug\netstandard2.0\FSharp.Core.AssemblyInfo.fs"
@"--sourcelink:C:\Users\nojaf\Projects\fsharp\artifacts\obj\FSharp.Core\Debug\netstandard2.0\FSharp.Core.sourcelink.json"
@nojaf
nojaf / notes.md
Created September 21, 2022 14:39
The benefit of signature files in FCS FSharpChecker