Skip to content

Instantly share code, notes, and snippets.

View jkone27's full-sized avatar
🦔
Back soon

gparmigiani jkone27

🦔
Back soon
View GitHub Profile
@odytrice
odytrice / RecordProvider.fs
Created May 24, 2020 21:55
Simple F# Type Provider for Mutable Records
namespace TestProvider.Provided
open System.Reflection
open FSharp.Core.CompilerServices
open ProviderImplementation.ProvidedTypes
open System.Collections.Generic
open Microsoft.FSharp.Quotations
[<TypeProvider>]
type SampleProvider(config) as this =
@nasser
nasser / python.fsx
Last active November 30, 2020 20:54
Python from F#
// make sure codegen.py (https://github.com/CensoredUsername/codegen/blob/master/codegen.py) is in the same folder
// and you've added the IronPython package
open System.IO
open IronPython.Hosting
open IronPython.Runtime
open Microsoft.FSharp.Reflection
let engine = Python.CreateEngine()
@jhewlett
jhewlett / pure-di-with-lifetimes.fs
Created January 27, 2020 06:21
Pure DI in F# ASP.NET Core Web API, with examples of how to handle singleton and per-request disposables
namespace PureDI
open Microsoft.AspNetCore.Builder
open Microsoft.Extensions.Configuration
open Microsoft.Extensions.DependencyInjection
open Microsoft.AspNetCore.Mvc
open Microsoft.AspNetCore.Mvc.Controllers
open Microsoft.Extensions.Logging
open Microsoft.AspNetCore
open Microsoft.AspNetCore.Hosting
@minhhungit
minhhungit / 101-rx-samples.md
Created December 28, 2019 13:31 — forked from omnibs/101-rx-samples.md
101 Rx Samples in C#

101 Rx Samples in C#

This was taken from http://rxwiki.wikidot.com/101samples, because I wanted to be able to read it more comfortable with syntax highlighting.

Here's the unedited original, translated to Github Markdown glory:

101 Rx Samples - a work in progress

@mbuhot
mbuhot / FSharpConverters.fs
Last active November 5, 2023 20:16
System.Text.Json converters for F# Option, List and Map types
namespace System.Text.Json
open System
open System.Collections.Generic
open System.Text.Json.Serialization
// Converts Option<T> to/from JSON by projecting to null or T
type OptionValueConverter<'T>() =
inherit JsonConverter<'T option>()
@swlaschin
swlaschin / FsCsInterop.md
Last active May 23, 2025 09:37
F# to C# interop tips

Tips on exposing F# to C#

Api and Methods

I suggest that you create one or more Api.fs files to expose F# code in a C# friendly way.

In this file:

  • Define functions with PascalCase names. They will appear to C# as static methods.
  • Functions should use tuple-style declarations (like C#) rather than F#-style params with spaces.
@mrange
mrange / README.md
Last active April 21, 2025 06:50
[F#] Implementing Coroutines (async/await) using continuations

[F#] Implementing Coroutines (async/await) using continuations

Coroutines or async/await is not a new concept as it was named in 1958 by Melvin Conway. Coroutines had support in languages such as Simula(1962), Smalltalk(1972) and Modula-2(1978) but I think one can argue that coroutines came into mainstream with C# 5(2012) when Microsoft added async/await to C#.

The problem with subroutines

A thread can only execute a single subroutine at a time as a subroutine starts and then runs to completion. In a server environment subroutines can be problematic as in order to service connections concurrently we would usually would start a thread per connection, this was the idiom a few years ago. A thread depending on the operating system and settings needs about 1 MiB of user stack space meaning 1,024 threads needs 1 GiB of for just user stack space. In addition there's the cost of kernel stack space, book-keeping and scheduling of threads. This drives cost of VM/hardwa

@swlaschin
swlaschin / effective-fsharp.md
Last active June 16, 2025 06:53
Effective F#, tips and tricks

Architecture

  • Use Onion architecture

    • Dependencies go inwards. That is, the Core domain doesn't know about outside layers
  • Use pipeline model to implement workflows/use-cases/stories

    • Business logic makes decisions
    • IO does storage with minimal logic
    • Keep Business logic and IO separate
  • Keep IO at edges

@rodripf
rodripf / elastic-search-v6.5.4-rest-api-swagger.json
Last active July 28, 2019 03:43
Swagger Open API documentation generated for the Elastic Search v6.5.4 rest API. Generated with this kindly shared project https://github.com/digipolisantwerp/elastic-swagger-generator_aspnetcore . Gist is truncating the file because of its length, please download using the RAW button.
Download the full version from https://mega.nz/#!7kJCBCpL!Ay4lfoUvshqDIM6dRh0oGCtihlxcY0lO-IDNDcMyi-A
{
"swagger": "2.0",
"info": {
"title": "ElasticSearch",
"description": "ACPaaS ElasticSearch Logging Engine API.",
"termsOfService": "?",
"contact": {
@jwill9999
jwill9999 / README.md
Last active June 4, 2025 10:19
ASP.NET Razor Cheat Sheet