Skip to content

Instantly share code, notes, and snippets.

View AngelMunoz's full-sized avatar
🏠
Working from home

Angel D. Munoz AngelMunoz

🏠
Working from home
View GitHub Profile
@AngelMunoz
AngelMunoz / falco-text
Created April 12, 2022 01:17
F# Http Frameworks from zero
cd repos; dotnet new webapi -lang F# -o FalcoSample
cd FalcoSample; dotnet add package Falco
code -r .
open System
open Microsoft.AspNetCore.Http
open Falco
open Falco.Routing
open Falco.HostBuilder
@AngelMunoz
AngelMunoz / Extensions.fs
Created March 13, 2022 21:54
Scriban + HTMX F# extensions for Giraffer
namespace Extensions
open System
open System.Runtime.CompilerServices
open System.IO
open System.Threading.Tasks
open Microsoft.AspNetCore.Antiforgery
open Microsoft.AspNetCore.Http
open Microsoft.Extensions.DependencyInjection
open Microsoft.Extensions.Primitives
@AngelMunoz
AngelMunoz / install-perla.ps1
Created October 1, 2021 16:27
Install Perla in windows machines
Param($version = "latest")
$baseUrl = "https://api.github.com";
$releasesUrl = "$baseUrl/repos/AngelMunoz/Perla/releases";
$releasesLatestUrl = "$releasesUrl/latest";
$releasesByTagUrl = "$releasesUrl/tags/v";
$outDir = "$Env:USERPROFILE\.perla";
@AngelMunoz
AngelMunoz / index.html
Last active December 3, 2022 11:14
Implement SSE with F# and Saturn
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<script>
@AngelMunoz
AngelMunoz / LitExtensions.fs
Created September 10, 2021 18:13
Bindings for LitElement
module Lit.Extensions
open Fable.Core
open Fable.Core.JsInterop
open Lit
[<Interface>]
type ReactiveController =
abstract member hostConnected : unit -> unit
@AngelMunoz
AngelMunoz / dev-to-sitefi.fsx
Created August 15, 2021 03:45
Convert Dev.to articles into markdown files with site-fi front matter
#r "nuget: FSharp.SystemTextJson, 0.17.4"
#r "nuget: Ply, 0.3.1"
open System.IO
open System.Text.Json
open System.Text.Json.Serialization
open System
open System.IO
// each case is kind of a "label"
// active patterns are limited to 7 choices though so keep that in mind
let (|IsNet50|Else|EndsWithSlash|) (path: string) =
if path.EndsWith("net5.0") then
IsNet50
else if path.EndsWith('/')then
EndsWithSlash
else Else path
@AngelMunoz
AngelMunoz / interpolation.fsx
Last active March 31, 2021 17:29
string interpolation in F#
// string interpolation in F# can be type safe
// specifying the data type you need in the "hole" of that string
// or you can fallback to the "ToString" one
$"Frank is %i{10} years old"
$"That'ts not %b{true}"
$"Bet' you can't print a list %A{[1;2;3;4]}"
$"Yeah but do tou need to specify data type? %{false}"
// or the equivalent in older versions which is good to use as well
@AngelMunoz
AngelMunoz / http.fsx
Created March 12, 2021 05:59
http request that fetches users in json, reads the content as text and prints the contents to the console
#r "nuget: FsHttp"
// uses https://github.com/ronaldschlenker/FsHttp
open FsHttp
http {
GET "https://jsonplaceholder.typicode.com/users"
Accept "application/json" // Accepts Header
}
@AngelMunoz
AngelMunoz / media.service.ts
Created February 17, 2021 21:42
a simple typescript class that deals with the HTML Media API for camera stuff
export interface ISwitchCameraArgs {
deviceId?: string
}
export interface IStartCameraArgs {
constraints?: MediaStreamConstraints;
retryCount?: number;
}
export interface ICameraDevice extends MediaDeviceInfo {