Skip to content

Instantly share code, notes, and snippets.

View alfonsogarciacaro's full-sized avatar

Alfonso Garcia-Caro alfonsogarciacaro

View GitHub Profile
@alfonsogarciacaro
alfonsogarciacaro / Deploy.md
Last active March 3, 2023 09:50
Deploying an F# ASP.NET Core app (Giraffe) to Azure

Deploying an F# ASP.NET Core app to Azure

Last week I spent a lot of time trying to deploy an F# ASP.NET Core app (a Giraffe app, specifically) to Azure because the information to complete all the steps was scattered in several places. So I'm writing this hopefully it will save the pain to others :)

Preparation

The following steps are mostly taken from this guide and it's only necessary to do them once:

  1. Create an account in Azure (or use an existing one)
  2. Create a resource group (or use an existing one)
@alfonsogarciacaro
alfonsogarciacaro / ozmo.fs
Created December 8, 2017 08:59
Phillip Trelford's Ozmo Game for Fable REPL
module Program
module Keyboard =
open Fable.Import
let mutable keysPressed = Set.empty
let code x = if keysPressed.Contains(x) then 1 else 0
let arrows () = (code 39 - code 37, code 38 - code 40)
let update (e : Browser.KeyboardEvent, pressed) =
let keyCode = int e.keyCode
@alfonsogarciacaro
alfonsogarciacaro / stacktrace2.txt
Created March 25, 2017 14:13
Microsoft/visualfsharp #2682 Stack Trace 2
> Fable.Compiler.dll!Fable.FSharp2Fable.Patterns.|ForOf|_|(Microsoft.FSharp.Compiler.SourceCodeServices.FSharpExpr _arg1) Line 370 F#
Fable.Compiler.dll!Fable.FSharp2Fable.Compiler.transformExpr(Fable.FSharp2Fable.IFableCompiler com, Fable.FSharp2Fable.Context ctx, Microsoft.FSharp.Compiler.SourceCodeServices.FSharpExpr fsExpr) Line 82 F#
Fable.Compiler.dll!Fable.FSharp2Fable.Compiler.transformExpr(Fable.FSharp2Fable.IFableCompiler com, Fable.FSharp2Fable.Context ctx, Microsoft.FSharp.Compiler.SourceCodeServices.FSharpExpr fsExpr) Line 82 F#
FSharp.Core.dll!Microsoft.FSharp.Primitives.Basics.List.mapToFreshConsTail<Fable.AST.Fable.Expr, Microsoft.FSharp.Compiler.SourceCodeServices.FSharpExpr>(Microsoft.FSharp.Collections.FSharpList<Fable.AST.Fable.Expr> cons, Microsoft.FSharp.Core.FSharpFunc<Microsoft.FSharp.Compiler.SourceCodeServices.FSharpExpr, Fable.AST.Fable.Expr> f, Microsoft.FSharp.Collections.FSharpList<Microsoft.FSharp.Compiler.SourceCodeServices.FSharpExpr> x) Unknown
FSharp.Core.dll!Microso
@alfonsogarciacaro
alfonsogarciacaro / stacktrace.txt
Created March 23, 2017 17:26
Microsoft/visualfsharp #2682 Stack Trace
This file has been truncated, but you can view the full file.
[Managed to Native Transition]
mscorlib.dll!System.Globalization.CompareInfo.LastIndexOf(string source, string value, int startIndex, int count, System.Globalization.CompareOptions options) Unknown
mscorlib.dll!string.LastIndexOf(string value, int startIndex, int count, System.StringComparison comparisonType) Unknown
mscorlib.dll!System.RuntimeType.SplitName(string fullname, out string name, out string ns) Unknown
mscorlib.dll!System.RuntimeType.GetNestedType(string fullname, System.Reflection.BindingFlags bindingAttr) Unknown
FSharp.Core.dll!Microsoft.FSharp.Reflection.Impl.getUnionCaseTyp(System.Type typ, int tag, System.Reflection.BindingFlags bindingFlags) Unknown
FSharp.Core.dll!Microsoft.FSharp.Reflection.Impl.fieldsPropsOfUnionCase(System.Type typ, int tag, System.Reflection.BindingFlags bindingFlags) Unknown
FSharp.Core.dll!Microsoft.FSharp.Text.StructuredPrintfImpl.ReflectUtils.Value.GetValueInfoOfObject(System.Reflection.BindingFlags bindingFlags, object obj) Unknown
FSharp.Core.d
@alfonsogarciacaro
alfonsogarciacaro / deopt.txt
Created March 2, 2017 22:23
node --trace-deopt out/testapp/project > deopt.txt
[deoptimizing (DEOPT eager): begin 0000020D2B33EEE1 <JS Function ILInstr (SharedFunctionInfo 00000215DE3CEF71)> (opt #35) @3, FP to SP delta: 24, caller sp: 0x7d0c90bdc0]
;;; deoptimize at 76866: not a Smi
reading input frame ILInstr => node=41, args=6, height=2; inputs:
0: 0x20d2b33eee1 ; [fp - 16] 0000020D2B33EEE1 <JS Function ILInstr (SharedFunctionInfo 00000215DE3CEF71)>
1: 0x20d2b3c1b99 ; rax 0000020D2B3C1B99 <an ILInstr with map 00000218BAB68E31>
2: 0x2200000000 ; [fp + 48] 34
3: 0x20d2b3c18d1 ; [fp + 40] 0000020D2B3C18D1 <an ILBasicType with map 00000218BAB691F9>
4: 0x20d2b3c19f9 ; [fp + 32] 0000020D2B3C19F9 <an ILConst with map 00000218BAB69359>
5: 0x37dac704311 ; [fp + 24] 0000037DAC704311 <undefined>
6: 0x37dac704311 ; [fp + 16] 0000037DAC704311 <undefined>
@alfonsogarciacaro
alfonsogarciacaro / Test.fs
Created February 16, 2017 13:54
Implicit conversion for erased unions
type U2<'a,'b> =
| Case1 of 'a
| Case2 of 'b
static member op_Implicit(x:'a) = U2.Case1 x
static member op_Implicit(x:'b) = U2.Case2 x
let inline (!|) (x:^a) : ^b = ((^a or ^b) : (static member op_Implicit : ^a -> ^b) x)
let foo (arg: U2<string, int>) = ()
@alfonsogarciacaro
alfonsogarciacaro / Sudoku.fs
Created February 15, 2017 10:00
Sudoku solver in F# by Steffen Forkmann
module Sudoku
open System
open System.Collections.Generic
type Box = int
type Sudoku = Box array array
let rows = id
let cols (sudoku:Sudoku) =
var _fableCore = require("fable-core");
// let k1 = fun (x:'a) (y:'b) -> x
// let test() =
// let k2 = fun (x:'a) (y:'b) -> x
// let k1' = k1 (fun z -> z)
// let k1'' = k1 (fun z -> z) 2
// let k2' = k2 (fun z -> z)
// let k2'' = k2 (fun z -> z) 2
@alfonsogarciacaro
alfonsogarciacaro / launch.json
Created August 4, 2016 00:03
Configuration for test project compilation with Fable in VS Code
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch Mono",
"type": "mono",
"request": "launch",
"program": "${workspaceRoot}/build/fable/bin/Fable.Client.Node.exe",
"args": [
"--projFile", "src/tests/Fable.Tests.fsproj",
@alfonsogarciacaro
alfonsogarciacaro / tests.js
Last active July 25, 2016 09:45
Performance tests between native and Immutable Map
"use strict";
var _fableCore = require("fable-core");
var Immutable = require('immutable');
var count, msg;
// F# code
// let test count =
// let mutable m = Map.empty<int, int>
// for i = 0 to count do