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 / Htmx.kt
Created January 15, 2024 01:51
A few non exhaustive Htmx bindings and helpers for ktor and kotlin.html
package me.tunaxor.htmx
import io.ktor.server.application.*
import io.ktor.server.request.*
import io.ktor.server.response.*
import kotlinx.html.CommonAttributeGroupFacade
enum class HxSwap {
InnerHTML,
OuterHTML,
#r "nuget: TheBlunt"
open TheBlunt
module Common =
let RequiedMark =
pchar
(fun c -> c = '!')
(fun c -> $"$%c{c} is not a valid required mark.")
@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 {
@AngelMunoz
AngelMunoz / UrlParser.fs
Last active October 26, 2023 21:28
Parse the segments + query + hash from a url with fparsec
namespace Routerish
type QueryValue =
| String of string option
| StringValues of string list
type RoutePart =
| Segment of segment: string
| ParamSegment of paramname: string
| Query of query: Map<string, QueryValue>
@AngelMunoz
AngelMunoz / interfaces.ts
Created November 17, 2020 20:57
A small Typescript utility class to record/take pictures in a website
export interface ISwitchCameraArgs {
deviceId?: string
}
export interface IStartCameraArgs {
constraints?: MediaStreamConstraints;
retryCount?: number;
}
export interface ICameraDevice extends MediaDeviceInfo {
// differentiate the kind of payload you want to take
type AdditionPayload =
| Integers of int * int
| Strings of string * string
module Operations =
// handle your integers
let private addInts a b = a + b
// handle your strings
@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 / backup.fsx
Last active November 17, 2022 15:16
backup/restore files from a directory into mongodb gridfs
#!/usr/bin/env -S dotnet fsi
#r "nuget: MongoDB.Driver"
#r "nuget: MongoDB.Driver.GridFS"
#r "nuget: Mondocks.Net"
#r "nuget: Spectre.Console"
open System
open System.IO
open Spectre.Console
open MongoDB.Driver
module Commands =
open FSharp.SystemCommandLine
open FSharp.SystemCommandLine.Aliases
type RunConfiguration with
static member FromString(value: string) =
module MyFunctions
let add a b = a + b
let printValue value = printfn "%s" value