Skip to content

Instantly share code, notes, and snippets.

@to11mtm
to11mtm / YouDoNotBelongHere.cs
Last active October 1, 2025 21:34
Abstract Class Funpost
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
namespace derp;
class Program
{
static void Main(string[] args)
{
var obj = new object();
@to11mtm
to11mtm / JetStream.cs
Created September 29, 2025 17:45
Nats Alpakka DSL WIP
using System.Text;
using System.Threading.Tasks.Dataflow;
using Akka;
using Akka.Streams;
using Akka.Streams.Dsl;
using Akka.Streams.Implementation.Fusing;
using Akka.Util;
using JetBrains.Annotations;
using NATS.Client.Core;
using NATS.Client.JetStream;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Linq2Db.EfCore.Samples.Tests.Microsoft.EntityFrameworkCore.Infrastructure;
using LinqToDB.Data;
using LinqToDB.EntityFrameworkCore;
using LinqToDB.Mapping;
@to11mtm
to11mtm / TrashUnfoldAsyncFlowStageWIP.cs
Created March 5, 2025 23:31
WIP/POC for an akka streams unfoldasync stage in the middle of a flow.
//// THIS IS PROBABLY NOT QUITE WORKING IN A FEW WAYS, JUST A CONVERSATION STARTER AT THIS POINT
/// <summary>
/// INTERNAL API
/// </summary>
/// <typeparam name="TIn">TBD</typeparam>
/// <typeparam name="TOut">TBD</typeparam>
[InternalApi]
public sealed class UnfoldAsync<TIn, TUnfoldState, TOut> : GraphStage<FlowShape<TIn, TOut>>
{
@to11mtm
to11mtm / wat.cs
Last active March 2, 2025 23:23
Reddit EF Repository pattern stuff
public static class WatCache<T> where T : class
{
private static ConcurrentDictionary<object, Action<T,Guid>> _cache = new();
public static Action<T, Guid> Get(Expression<Func<T, object>> selector) => _cache.GetOrAdd(selector, sel =>
{
var expr = (Expression<Func<T, object>>)sel;
var member = expr.Body as MemberExpression;
var prop = member!.Member as PropertyInfo;
var ep = Expression.Parameter(typeof(T), "entity");
@to11mtm
to11mtm / IHttpClientAsyncLoggerHackery.cs
Last active February 19, 2025 01:10
HttpClientAsyncLogger Impl via Jetbrains AI
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Extensions.Http.Logging;
using Microsoft.Extensions.Logging;
namespace httplogging
{
@to11mtm
to11mtm / ByteString.CS
Created January 30, 2025 22:38
Akka Bytestring ReadOnlySequence WIP/example
public class ByteStringReadOnlySequenceSegment : ReadOnlySequenceSegment<byte>
{
public ByteStringReadOnlySequenceSegment(ReadOnlyMemory<byte> memory, long runningIndex)
{
Memory = memory;
RunningIndex = runningIndex;
}
public static (ByteStringReadOnlySequenceSegment first, ByteStringReadOnlySequenceSegment last) Create(ByteString bs)
{
var bArr = bs.Buffers;
@to11mtm
to11mtm / NatsKVStoreSplittedAsyncGetEntryExample.cs
Created December 6, 2024 17:49
NatsKVStore Example for Split GetEntryAsync
public class NatsKVStore : INatsKVStore
{
public ValueTask<NatsKVEntry<T>> GetEntryAsync<T>(string key, ulong revision = default, INatsDeserialize<T>? serializer = default, CancellationToken cancellationToken = default)
{
ValidateKey(key);
serializer ??= JetStreamContext.Connection.Opts.SerializerRegistry.GetDeserializer<T>();
var request = new StreamMsgGetRequest();
var keySubject = $"$KV.{Bucket}.{key}";
@to11mtm
to11mtm / DispatcherSandbox.cs
Last active November 24, 2024 04:35
Just some crazy POC for dispatchers
/*
MIT License
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:
@to11mtm
to11mtm / eww.cs
Created September 18, 2024 18:29
so gross
using System.Configuration;
using System.IO;
using Microsoft.Extensions.Configuration;
using ConfigurationBuilder = Microsoft.Extensions.Configuration.ConfigurationBuilder;
using OldConfigurationManager = System.Configuration.ConfigurationManager;
namespace JsonConfigBridge
{
public class Class1
{