Skip to content

Instantly share code, notes, and snippets.

View TheAngryByrd's full-sized avatar
🐦
😠 🐦

Jimmy Byrd TheAngryByrd

🐦
😠 🐦
View GitHub Profile
<#
.SYNOPSIS
Continuously kills dotnet.exe processes.
.DESCRIPTION
Runs in a loop, checking every second for dotnet.exe processes and killing them.
Optionally filters processes by their command line arguments.
.PARAMETER ArgumentFilter
Optional filter to match against the command line arguments of dotnet.exe processes.
@TheAngryByrd
TheAngryByrd / DifferentTFMsAndRuntimeAssemblies.fs
Last active December 16, 2025 14:55
Showing different runtime values
let ifDefRuntime =
#if NET8_0
"This is .NET 8.0"
#endif
#if NET9_0
"This is .NET 9.0"
#endif
#if NET10_0
"This is .NET 10.0"
@TheAngryByrd
TheAngryByrd / Seq.fs
Last active August 7, 2025 15:49
F# TryGetNonEnumeratedCount helper
module Seq =
open System.Linq
/// Attempts to determine the number of elements in a sequence without forcing an enumeration.
let inline tryLength (xs : seq<_>) =
match Enumerable.TryGetNonEnumeratedCount xs with
| true, count -> ValueSome count
| _ ->
match xs with
// F# list implements IReadOnlyCollection/IReadOnlyList
@TheAngryByrd
TheAngryByrd / DotEnv.fs
Last active June 11, 2025 14:20
Basic .env file reader in F#
namespace FsToolkit.Build
module DotEnv =
open System
open System.IO
let private parseLine (line: string) =
match line.Split('=', StringSplitOptions.RemoveEmptyEntries) with
| args when args.Length = 2 -> Environment.SetEnvironmentVariable(args.[0], args.[1])
| _ -> ()
@TheAngryByrd
TheAngryByrd / Ignores.fs
Last active May 19, 2025 16:08
F# Ignore Explicity
[<AutoOpen>]
module Ignore =
[<RequiresExplicitTypeArguments>]
let inline ignore<'a> (x: 'a) : unit = ignore<'a> x
type Async =
[<RequiresExplicitTypeArguments>]
static member inline Ignore<'a>(x: Async<'a>) : Async<unit> = FSharp.Control.Async.Ignore<'a> x
@TheAngryByrd
TheAngryByrd / why-corecompile.fsx
Created March 6, 2025 14:53
Figure out why CoreCompile was run
// This is used to quickly diagnose why a rebuild happened in a large solution
// It reads a binlog file and finds all the CoreCompile targets that were triggered by a file being newer than the output file
// It then prints out the project and the messages that caused the rebuild
// to create a binlog you can refer to https://learn.microsoft.com/en-us/visualstudio/ide/msbuild-logs?view=vs-2022#provide-msbuild-binary-logs-for-investigation
// CLI: dotnet build -bl:mybinlog.binlog
// or in `.build/build.fs` add `BuildParameter.enableBinLog "mybinlog.binlog"` to the `build'` target.
// Use https://msbuildlog.com/ to diagnose further
#r "nuget: MSBuild.StructuredLogger"
@TheAngryByrd
TheAngryByrd / LogMetaData.fs
Last active August 21, 2025 14:17
F# Collecting logging metadata like namespace, function name, filepath, and line number
open System.Runtime.CompilerServices
type Log() =
static member inline GatherLogMetaStackFrame
(?name_space: string, [<CallerMemberName>] ?cmb: string, [<CallerLineNumber>] ?cln: int, [<CallerFilePath>] ?cfp: string)
=
let name_space =
match name_space with
| Some ns -> ns
| _ ->
@TheAngryByrd
TheAngryByrd / CyclomaticComplexity.fsx
Created January 8, 2025 13:52
CyclomaticComplexity.fsx
#r "nuget: FSharp.Compiler.Service, 43.8.300"
open FSharp.Compiler.Syntax
open FSharp.Compiler.SyntaxTrivia
open FSharp.Compiler.Xml
open FSharp.Compiler.CodeAnalysis
open System.IO
type Node =
{ Data : Data
@TheAngryByrd
TheAngryByrd / ResultChoiceCE.fs
Created December 24, 2024 16:59
Choice Combining Result CE
type ResultBuilder () =
member inline _.Return (x) = Ok x
member inline _.Bind(x,f) =
match x with
| Ok x -> f x
| Error e -> Error <| e
@TheAngryByrd
TheAngryByrd / graph-based-parser.fsx
Last active December 3, 2024 14:58
f# graph based parser
open System
open System.IO
open System.Collections.Generic
let root = __SOURCE_DIRECTORY__
let srcDir = Path.Combine(root, "src")
// Add <OtherFlags>$(OtherFlags) --test:GraphBasedChecking --test:DumpCheckingGraph --times:timings.csv</OtherFlags> to the .fsproj or Directory.Build.props