Skip to content

Instantly share code, notes, and snippets.

View andersstorhaug's full-sized avatar

Anders Storhaug andersstorhaug

View GitHub Profile
@andersstorhaug
andersstorhaug / EventStoreClientEx.cs
Last active July 30, 2021 22:22
`IAsyncEnumerable` catch-up subscription with EventStore gRPC v21.2.0 API
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using EventStore.Client;
namespace Example
{
@andersstorhaug
andersstorhaug / NugetReferencesResolver.cs
Last active July 15, 2021 16:00
Roslyn scripting with NuGet references
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Dotnet.Script.DependencyModel.Environment;
using Dotnet.Script.DependencyModel.Logging;
using Dotnet.Script.DependencyModel.ProjectSystem;
using Microsoft.CodeAnalysis;
using NuGet.Commands;
using NuGet.Configuration;
@andersstorhaug
andersstorhaug / m2input.md
Last active February 3, 2021 15:23
M2 emulator `.input` files

M2 Emulator binary .input files

Each 4 bytes correspond to an input, in display-order for a specific game.

The file ends with 8 bytes of 00 or 01 flags.
These signify whether an analog input in display-order is enabled.

Keyboard

For keyboard keys, the first byte corresponds to a DirectInput scan code, and bytes 2-4 are 0.

using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Xml.Linq;
namespace Namespace
{
public class FixedManifestEmbeddedAssembly : Assembly
@andersstorhaug
andersstorhaug / EventStoreEx.cs
Last active June 25, 2020 00:53
EventStore TCP catch-up subscription with `IAsyncEnumerable<ResolvedEvent>`
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using EventStore.ClientAPI;
namespace Example
{
public static class EventStoreEx
@andersstorhaug
andersstorhaug / ManyInnerJoin.cs
Last active April 24, 2020 23:13
DynamicData `ManyInnerJoin`
internal class ManyInnerJoin<TLeft, TLeftKey, TRight, TRightKey, TDestination>
{
private readonly IObservable<IChangeSet<TLeft, TLeftKey>> _left;
private readonly IObservable<IChangeSet<TRight, TRightKey>> _right;
private readonly Func<TLeft, TRightKey> _rightKeySelector;
private readonly Func<TLeft, TRight, TDestination> _resultSelector;
public ManyInnerJoin(IObservable<IChangeSet<TLeft, TLeftKey>> left,
IObservable<IChangeSet<TRight, TRightKey>> right,
Func<TLeft, TRightKey> rightKeySelector,