Skip to content

Instantly share code, notes, and snippets.

View TheAngryByrd's full-sized avatar
🐦
😠 🐦

Jimmy Byrd TheAngryByrd

🐦
😠 🐦
View GitHub Profile
@baronfel
baronfel / c-vs-p.fsx
Last active February 27, 2023 21:32
concurrency/parallelism using Asyncs
#r "nuget: Nito.AsyncEx, 5.1.2"
open System.Threading
open System.Threading.Tasks
open Nito.AsyncEx
let work x y =
async {
do! Async.Sleep 1
return 1 + 2
}
@pimbrouwers
pimbrouwers / Log.fsx
Last active April 18, 2022 20:48
Simple F# Logging Module
module Log =
open System
open System.IO
let private logDir = "logs"
let private log kind fmt =
Printf.kprintf (fun s ->
let now = DateTime.Now
let msg = sprintf "[%s] [%s] %s" (now.ToString("s")) kind s
@Aaronontheweb
Aaronontheweb / spec.md
Last active June 10, 2024 19:09
Technical Spec Template

Engineering Spec

💡 Use this template to help structure new engineering projects into specifications. Make sure you attach this spec to the right project - if it’s not a flagship technology then it goes under "Other Projects"

Abstract

Problem statement - what is the nature of the issue we’re going to try to solve with this specification?

@realvictorprm
realvictorprm / Didact.fsx
Last active February 6, 2022 15:08
F# port of the "Build your own react - Didact" tutorial
(*
F# port of https://github.com/pomber/didact
Copyright © 2022 Victor Peter Rouven Müller
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FRO
@michaeloyer
michaeloyer / srtp.fsx
Last active July 1, 2024 03:15
F# SRTP Example
// SRTP: Statically Resolved Type Parameters
// https://docs.microsoft.com/en-us/dotnet/fsharp/language-reference/generics/statically-resolved-type-parameters
// SRTP Allows for pulling members out of types that where the member is named and typed the same
// In this example SRTP will be used to pull out the 'First: string' and 'Last: string' members
// from different types
// One example of SRTP in the F# Base Class Library is the (+) operator.
// You'll see that it has this type signature:
@polytypic
polytypic / Zio.fsx
Last active January 16, 2023 14:42
Zio like monad in F#
// Computations with extensible environment, error handling, and asynchronicity
// I recently reviewed some F# code that turned out to be using
//
// Dependency Interpretation
// https://fsharpforfunandprofit.com/posts/dependencies-4/
//
// and got thinking about whether one could construct a usable Zio like monad
//
// https://zio.dev/
@baronfel
baronfel / Directory.Build.targets
Created August 6, 2021 16:13
Targets to discover and set README and PackageIcon based on Item metadata
<!--
If no PackageReadmeFile is present and there's a _PackageFiles with the metadata node `PackageReadmeFile="true"` set,
use its resolved PackagePath as the `PackageReadmeFile`
eg. <None Include="../../README.md" Pack="true" PackagePath="\" PackageReadmeFile="true" />
-->
<Target Name="_SetPackageReadmeFileByConvention"
DependsOnTargets="_GetPackageFiles"
BeforeTargets="GenerateNuspec"
Condition="'$(PackageReadmeFile)' == ''">
@baronfel
baronfel / Directory.Build.targets
Last active April 27, 2021 14:39
Build target for seamless signature file includes
<Project>
<PropertyGroup>
<!-- Provide an escape hatch/opt-in to this feature -->
<AutoIncludeExistingSignatures Condition="$(AutoIncludeExistingSignatures) == '' " >false</AutoIncludeExistingSignatures>
</PropertyGroup>
<Target Name="CollectFSharpSourcesAndSignatures" BeforeTargets="CoreCompile" Condition="$(AutoIncludeExistingSignatures)">
<ItemGroup>
<!-- Cache the current set of compile options -->
<_Sources Include="@(Compile)" />
<!-- clear out the Compile order because we need to insert the sigs before their associated source files -->