Skip to content

Instantly share code, notes, and snippets.

// See https://aka.ms/new-console-template for more information
using System.Buffers.Binary;
using System.Buffers.Text;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Text;
var filePath = @"C:\projects\local\1brc-main\measurements.txt";
// See https://aka.ms/new-console-template for more information
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddSingleton<Service>();
@Ilchert
Ilchert / read14.cs
Last active October 10, 2023 21:05
// See https://aka.ms/new-console-template for more information
using System.Buffers.Binary;
var data = new byte[] {
100,
100,100,10,10,
11,11,11,11,
12,00,
4,
4,
@Ilchert
Ilchert / LayoutConHost.cs
Last active August 12, 2023 18:36
Conhost console search
// See https://aka.ms/new-console-template for more information
using System.Diagnostics;
using System.Runtime.InteropServices;
while (true)
{
var process = Process.GetCurrentProcess();
ulong cohost = 0;
int status;
status = NtQueryInformationProcess(process.Handle, 0x31, ref cohost, Marshal.SizeOf(typeof(ulong)), out _); // cohost
@Ilchert
Ilchert / FindLayout.cs
Created August 12, 2023 18:14
Find layout from console
using System.Diagnostics;
using System.Runtime.InteropServices;
while (true)
{
var pbi = new ParentProcessUtilities();
var process = Process.GetCurrentProcess();
int status;
while (true)
{
@Ilchert
Ilchert / TypeMagic.cs
Created July 16, 2023 09:16
TypeMagic.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text.RegularExpressions;
var data = new Bar(1, new Foo(2));
var d = new Derive_SumEverything<Bar>();
using System.Security.Cryptography;
using System;
using System.Text.Json;
using System.Text.Json.Serialization.Metadata;
var a = new A { ModeA = "A", ModeB = "B" };
JsonSerializerOptions optionsA = new()
{
TypeInfoResolver = new DefaultJsonTypeInfoResolver
// See https://aka.ms/new-console-template for more information
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
BenchmarkRunner.Run<Benchmarks>();
public class Benchmarks
{
@Ilchert
Ilchert / AspnetFilters.cs
Last active October 5, 2022 09:54
Aspnet minimal api filters
using Microsoft.AspNetCore.TestHost;
var builder = WebApplication.CreateBuilder(args);
builder.WebHost.UseTestServer();
var app = builder.Build();
var group = app.MapGroup("/");
group.AddEndpointFilter(async (efiContext, next) =>
{
var result = await next(efiContext);
@Ilchert
Ilchert / Modules.cs
Last active September 14, 2022 13:16
public static class ServiceCollectionExtensions
{
internal static readonly string ModulesKey = "Modules";
public static IServiceCollection AddModules(this IServiceCollection serviceCollection, HostBuilderContext builderContext)
{
var modulesSection = builderContext.Configuration.GetSection(ModulesKey);
foreach (var moduleName in modulesSection.GetChildren())
{
var type = Type.GetType(moduleName.Value, true, false);