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 / 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
@AngelMunoz
AngelMunoz / inspect-music-properties.fsx
Last active June 6, 2020 05:00
Inspects the music properties of .mp3 files in the music directory
#r "nuget: Microsoft.Windows.Sdk.NET, 10.0.18362.3-preview"
open System
open Windows.Storage
let asyncGetFiles() =
async {
let! files = KnownFolders.MusicLibrary.GetFilesAsync().AsTask() |> Async.AwaitTask
return files |> Seq.take 5
}
@AngelMunoz
AngelMunoz / media-player.fsx
Last active June 6, 2020 12:19
uses the new #r "nuget: " directive coming in F# 5.0 plus the C#/WinRT projection to find at most 5 files from your music library and play them 100% natively on Windows 10
#r "nuget: Microsoft.Windows.Sdk.NET, 10.0.18362.3-preview"
open System
open Windows.Media
open Windows.Media.Core
open Windows.Media.Playback
open Windows.Storage
open Windows.Storage.FileProperties
@AngelMunoz
AngelMunoz / main.rs
Last active May 24, 2020 13:20
Small sample of the Rust/WinRT API projection https://github.com/microsoft/winrt-rs
winrt::import!(
dependencies
os
modules
"windows.foundation"
"windows.system.power"
);
use windows::system::power::*;
fn battery_status() -> std::string::String {