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 / 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 {
@AngelMunoz
AngelMunoz / prepend-to-user-path.fsx
Last active December 12, 2020 20:34
An attempt to append an Environment Variable for the current user on windows
open System
open Spectre.Console
open System.Collections.Generic
open System.Linq
let sampleVar = "SAMPLE_VAR"
let path =
let mapped =
Environment
@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
@AngelMunoz
AngelMunoz / create.fsx
Last active July 27, 2021 22:39
These are Mondocks Samples
#r "nuget: Mondocks.Net"
open System
open Mondocks.Queries
type UserParams =
{ name: string; age: int; }
let insertModel<'T> (collection: string) (values: seq<'T>) =
insert collection {
documents values
@AngelMunoz
AngelMunoz / ObjectIdConverter.fs
Created November 25, 2020 07:19
Simple MongoDB ObjectId Converter for the System.Text.Json json serializer
type ObjectIdConverter() =
inherit JsonConverter<ObjectId>()
override _.Read(reader: byref<Utf8JsonReader>, typeToConvert: Type, options: JsonSerializerOptions) =
ObjectId.Parse(reader.GetString())
override _.Write(writer: Utf8JsonWriter, value: ObjectId, options: JsonSerializerOptions) =
writer.WriteStringValue(value.ToString())
@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 {
@AngelMunoz
AngelMunoz / suavefileexplorer.fsx
Last active December 5, 2021 19:52
A sample of the scripting capabilities of F# 5.0
#r "nuget: Suave"
// 👆🏽 this was added in F# 5.0
// if you are using the .NET 5.0 previews or RC run as follows
// dotnet fsi suavefileexplorer.fsx --langversion:preview
open System
open System.IO
open System.Threading
open System.Text
open Suave