Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
I may be slow to respond.

Dexter skynode

💭
I may be slow to respond.
  • Amsterdam, The Netherlands
View GitHub Profile
@skynode
skynode / TaskExt.Delay.cs
Created Aug 6, 2022 — forked from noseratio/TaskExt.Delay.cs
Implementing Task.Delay using a custom awaiter and unmanaged CreateTimerQueueTimer
View TaskExt.Delay.cs
using System;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
namespace ConsoleApplication
{
// by noseratio - stackoverflow.com/users/1768303/noseratio
class TaskExt
{
@skynode
skynode / effective-fsharp.md
Created May 27, 2022 — forked from swlaschin/effective-fsharp.md
Effective F#, tips and tricks
View effective-fsharp.md

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

@skynode
skynode / README.md
Created May 26, 2022 — forked from mrange/README.md
# F# Advent 2021 Dec 08 - Fast data pipelines with F#6
View README.md

F# Advent 2021 Dec 08 - Fast data pipelines with F#6

Thanks to Sergey Tihon for running F# Weekly and F# Advent.

Thanks to manofstick for trying out the code and coming with invaluable feedback. Cistern.ValueLinq is very impressive.

TLDR; F#6 enables data pipelines with up to 15x less overhead than LINQ

There were many interesting improvements in F#6 but one in particular caught my eye, the attribute InlineIfLambda.

View ConcurrentDictionaryExtensions.cs
using System;
using System.Threading.Tasks;
namespace System.Collections.Concurrent
{
public static class ConcurrentDictionaryExtensions
{
/// <summary>
/// Provides an alternative to <see cref="ConcurrentDictionary{TKey, TValue}.GetOrAdd(TKey, Func{TKey, TValue})"/> that disposes values that implement <see cref="IDisposable"/>.
/// </summary>
@skynode
skynode / Example.cs
Created May 20, 2022 — forked from davidfowl/Example.cs
An implementation of MessagePipe. Something like a channel but with buffer management so you can peek and advance the message that was read.
View Example.cs
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;
@skynode
skynode / MinimalAPIs.md
Created May 3, 2022 — forked from davidfowl/MinimalAPIs.md
Minimal APIs at a glance
View MinimalAPIs.md
@skynode
skynode / combining-git-repositories.md
Created May 3, 2022 — forked from msrose/combining-git-repositories.md
How to combine two git repositories.
View combining-git-repositories.md

Combining two git repositories

Use case: You have repository A with remote location rA, and repository B (which may or may not have remote location rB). You want to do one of two things:

  • preserve all commits of both repositories, but replace everything from A with the contents of B, and use rA as your remote location
  • actually combine the two repositories, as if they are two branches that you want to merge, using rA as the remote location

NB: Check out git subtree/git submodule and this Stack Overflow question before going through the steps below. This gist is just a record of how I solved this problem on my own one day.

Before starting, make sure your local and remote repositories are up-to-date with all changes you need. The following steps use the general idea of changing the remote origin and renaming the local master branch of one of the repos in order to combine the two master branches.

View MathF.Sin.cs
// This is a port of the amd/win-libm implementation provided in assembly here: https://github.com/amd/win-libm/blob/master/sinf.asm
// The original source is Copyright (c) 2002-2019 Advanced Micro Devices, Inc. and provided under the MIT License.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this Software and associated documentaon 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:
//