Skip to content

Instantly share code, notes, and snippets.

View fredeil's full-sized avatar
🎯
Focusing

Fredrik Eilertsen fredeil

🎯
Focusing
View GitHub Profile
@DamianEdwards
DamianEdwards / SKILL.md
Created February 15, 2026 22:03
C# File-based apps skill
name description
csharp-scripts
Run single-file C# programs as scripts for quick experimentation, prototyping, and concept testing. Use when the user wants to write and execute a small C# program without creating a full project.

C# Scripts

When to Use

  • Testing a C# concept, API, or language feature with a quick one-file program
@karpathy
karpathy / microgpt.py
Last active February 15, 2026 23:12
microgpt
"""
The most atomic way to train and inference a GPT in pure, dependency-free Python.
This file is the complete algorithm.
Everything else is just efficiency.
@karpathy
"""
import os # os.path.exists
import math # math.log, math.exp
@Thorium
Thorium / Client.fsx
Created September 29, 2025 10:45
ModelContextProtocol with FSharp (MCP with F#)
#r "nuget: ModelContextProtocol,0.4.0-preview.1"
open ModelContextProtocol.Client
open ModelContextProtocol.Protocol
open System
open System.Threading.Tasks
module McpClient =
let clientTransport =
StdioClientTransport(
StdioClientTransportOptions(
@AndrewDongminYoo
AndrewDongminYoo / email_validation_strategy.dart
Created April 12, 2025 11:15
Dart class that uses a strategy pattern to check the validity of an email
/// Written with “powerful” inspiration from the https://pub.dev/packages/email_validator.
/// An abstract strategy for validating objects of type [T].
///
/// Implementations of this class define specific validation rules
/// for a given type, allowing flexible and reusable validation logic.
abstract class ValidationStrategy<T, E extends Exception> {
/// Validates the given [value] of type [T].
///
/// If the validation fails, an exception of type [E] is thrown.
@davidfowl
davidfowl / Example.cs
Last active June 6, 2023 08:10
An implementation of MessagePipe. Something like a channel but with buffer management so you can peek and advance the message that was read.
using System.Buffers;
using System.Net.WebSockets;
var builder = WebApplication.CreateBuilder(args);
var app = builder.Build();
app.MapGet("/ws", async (HttpContext context) =>
{
const int MaxMessageSize = 1024 * 1024;
@jhewlett
jhewlett / HttpClient.FSharp.fs
Last active October 1, 2025 10:26
Functional wrapper around System.Net.Http.HttpClient. Inspired in part by Http.fs (https://github.com/haf/Http.fs) and FSharp.Data (https://fsharp.github.io/FSharp.Data/library/Http.html)
namespace HttpClient.FSharp
open System
open System.Net.Http
type HttpMethod =
| Post
| Put
| Delete
| Get
[StructLayout(LayoutKind.Sequential, Size = 256)]
public unsafe struct Bitset
{
public void Set(int bitIndex) => ((int*) Unsafe.AsPointer(ref Unsafe.AsRef(this)))[(bitIndex & ~7) >> 5] |= 1 << (bitIndex & 7);
public void Unset(int bitIndex) => ((int*)Unsafe.AsPointer(ref Unsafe.AsRef(this)))[(bitIndex & ~7) >> 5] ^= 1 << (bitIndex & 7);
public void SetAll() => Unsafe.InitBlock(Unsafe.AsPointer(ref Unsafe.AsRef(this)), 0xff, (uint) Unsafe.SizeOf<Bitset>());
public void UnsetAll() => Unsafe.InitBlock(Unsafe.AsPointer(ref Unsafe.AsRef(this)), 0x00, (uint) Unsafe.SizeOf<Bitset>());
}
@arthurrump
arthurrump / FakeGitVersioning.fsx
Last active August 14, 2019 10:35
How to use FAKE to automatically set version numbers based on your Git history. https://www.arthurrump.com/2019/07/19/git-based-versioning-using-fake
#r "paket:
nuget Fake.Core.SemVer
nuget Fake.Core.Target
nuget Fake.DotNet.Cli
nuget Fake.Tools.Git //"
#load "./.fake/build.fsx/intellisense.fsx"
open Fake.Core
open Fake.DotNet
open Fake.Tools
@swlaschin
swlaschin / effective-fsharp.md
Last active November 27, 2025 00:18
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