Skip to content

Instantly share code, notes, and snippets.

View jkone27's full-sized avatar
🌴
On vacation

gparmigiani jkone27

🌴
On vacation
View GitHub Profile
@jkone27
jkone27 / fshttpSpectreImageDownload.fsx
Created January 22, 2024 11:29
download an image and display it in your console with fshttp and spectre.console packages in fsx F# script
#r "nuget: FsHttp"
#r "nuget: Spectre.Console.ImageSharp"
open FsHttp
open Spectre.Console
let imgUrl =
"https://banner2.cleanpng.com/20200525/frt/transparent-hero-image-hero-logo-cartoon-5ecc928ba8c9a0.2212187815904651636914.jpg"
@jkone27
jkone27 / expressGlutinumFable.fsx
Created January 1, 2024 23:36
express js from fable using glutinum from .fsx
// npm init type module, npm add express, dotnet tool install fable, dotnet fable express.fsx, node express.fs.js
#r "nuget: Glutinum.Express, 0.1.0-alpha-002"
#r "nuget: Glutinum.BodyParser"
#r "nuget: Glutinum.RangeParser"
#r "nuget: Fable.Core"
#r "nuget: Feliz.ViewEngine"
open Glutinum.Express
open Glutinum.ExpressServeStaticCore
open Fable.Core.JsInterop
@jkone27
jkone27 / di_ioc_fsharp_servicecollection.fsx
Created December 11, 2023 00:11
dependency injection in fsharp using servicecollection
#r "nuget: Microsoft.Extensions.DependencyInjection"
#r "nuget: Microsoft.Extensions.Logging.Console"
open Microsoft.Extensions.DependencyInjection
open Microsoft.Extensions.Logging.Console
open Microsoft.Extensions.Logging
type ITest =
abstract member Log : unit -> unit
type Test(logger: ILogger<Test>) =
@jkone27
jkone27 / SwaggerProviderPetsSampleWithLogs.fsx
Created December 2, 2023 20:45
Add and retrieve some pets using F# awesome SwaggerProvider
#r "nuget: SwaggerProvider"
#r "nuget: Microsoft.Extensions.Logging.Console"
#r "nuget: Microsoft.Extensions.DependencyInjection"
#r "nuget: Microsoft.Extensions.Http"
open System
open System.Net.Http
open SwaggerProvider
open System.Threading.Tasks
open System.Threading
@jkone27
jkone27 / checkApiStatusServerHyperScript.fsx
Created October 18, 2023 23:45
suave F# api using hyperscript, Suave and Feliz.ViewEngine to check and reload data from server at a regular interval
#r "nuget:FSharp.Data"
//#r "nuget:Plotly.NET"
#r "nuget:Feliz.ViewEngine"
#r "nuget:Suave"
open FSharp.Data
//open Plotly.NET
open Feliz.ViewEngine
open Suave
open Suave.Filters
open Suave.Operators
@jkone27
jkone27 / mlnetHousePricePrediction.fsx
Last active October 16, 2023 11:59
sample test of ml net library for house pricing regression prediction
#r "nuget:Microsoft.ML"
#r "nuget:Microsoft.ML.AutoML"
#r "nuget:Microsoft.ML.DataView"
#r "nuget:Plotly.NET"
#r "nuget:FSharp.Data"
open Microsoft.ML
open Microsoft.ML.Data
open Microsoft.ML.Transforms
open Microsoft.ML.Trainers
@jkone27
jkone27 / cover.fsx
Last active December 15, 2023 18:50
coverlet coverage fsc script using fli, creates a report and shows it in browser
#r "nuget: Fli"
open Fli
open System
open System
let isHelpRequested = fsi.CommandLineArgs |> Seq.contains "--h"
[<Literal>]
@jkone27
jkone27 / orderExample.fsx
Created September 30, 2023 13:39
fsharp test order oms example
#r "nuget: NodaMoney"
open NodaMoney
open System
open System.Threading.Tasks
module Products =
type Product =
| Shoes
| Skirt
@jkone27
jkone27 / JsonDiffPatchWrapper.cs
Last active August 22, 2023 19:26
JsonDiffPath wrapper for case insensitivity and ignoring fields
using System;
using System.Collections.Generic;
using System.Linq;
using JsonDiffPatchDotNet;
using Newtonsoft.Json.Linq;
public static class JsonDiffPatchWrapper
{
private static readonly JsonDiffPatch JsonDiff = new JsonDiffPatch();
@jkone27
jkone27 / learn-fsharp-in-one-go.fsx
Last active July 14, 2023 13:04
learn F# in one go
(*
module ---> like a static class in C#
open (like using or using static in C#) --> just open a namespace or module
let ----> like var but used both for varialbles and functions, any binding is done with let, last value in scope is the result
type ---> custom/user-defined types , records, classes, discriminated unions, interfaces ecc..
task ---> like async Task<T> in C#, let! is await, return! is return await, return is return
*)