Skip to content

Instantly share code, notes, and snippets.

View itn3000's full-sized avatar
πŸ€”
πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”

Yusuke Ito itn3000

πŸ€”
πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”
View GitHub Profile
@itn3000
itn3000 / IntResourceApiHelper.cs
Last active April 4, 2025 08:11
CsWin32 Resource API Helper
using Windows.Win32;
using Windows.Win32.Foundation;
static class IntResourceHelper
{
public static string GetResourceIdOrName(PWSTR lpName)
{
unsafe
{
var addr = new IntPtr(lpName.Value);
@itn3000
itn3000 / testjsonreaderstate.cs
Last active December 5, 2024 15:23
test jsonreaderstate
using System.IO.Pipelines;
using System.Runtime.InteropServices;
using System.Text.Json;
using System.Text;
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
CreateJsonFile("abc.json", 10000000);
GC.Collect();
Console.WriteLine($"GC.TotalMemory = {GC.GetTotalMemory(false)}");
@itn3000
itn3000 / DeserializeJsonLines.cs
Last active October 25, 2024 05:58
Deserializing JSON Lines test
using System;
using System.IO;
using System.Text;
using System.Text.Json;
// need System.Text.Json 9.0 or later
namespace jsonserializertest
{
class Program
@itn3000
itn3000 / CS0173.netstd2.0.dynamic.cs
Created April 16, 2024 05:41
CS0173 in dotnet sdk 8.0.300pre3 and netstandard2.0
using System;
namespace a
{
public class Class1
{
public static void X()
{
dynamic x = GetDynamic();
// CS0173 with .NET SDK 8.0.300pre3 and netstandard2.0
@itn3000
itn3000 / garnetlabs.cs
Last active April 9, 2024 18:01
garnet sandbox codes
using System.Diagnostics;
using System.Text;
using Azure.Core.Pipeline;
using Garnet;
using Garnet.client;
using Garnet.server;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Console;
@itn3000
itn3000 / RetrieveInputKeyEventWithR3.cs
Last active April 28, 2024 21:23
how to retrieve input event with R3 and Stride3d
using System;
using Stride.Engine;
using Stride.Input;
using R3;
namespace RetrieveInputKeyEventWithR3;
public class RetriveKeyEventScript: StartupScript
{
public override Start()
@itn3000
itn3000 / NatsWithR3.cs
Last active March 5, 2024 16:06
NATS .NET Client-v2 + R3
using NATS.Client.Core;
using R3;
using System.Diagnostics;
await using var con = new NatsConnection();
await using var subscription = await con.SubscribeCoreAsync<string>("hoge");
using var cts = new CancellationTokenSource();
{
using var _ = Observable.CreateFrom<NatsMsg<string>, INatsSub<string>>(subscription, Generator)
@itn3000
itn3000 / ObservableFromEventTest.cs
Last active January 24, 2024 08:45
R3 Observable creation on event which requires two arguments.
using R3;
var a = new A();
using var x1 = Observable.FromEvent<A.PiyoHandler, int>(h => new A.PiyoHandler(h), h => a.PiyoEvent += h, h => a.PiyoEvent -= h)
.Subscribe(x => Console.WriteLine($"piyo: {x}"));
using var x2 = Observable.FromEventHandler<int>(h => a.MogeEvent += h, h => a.MogeEvent -= h)
.Subscribe(x => Console.WriteLine($"moge: {x}"));
using var x3 = Observable.FromEvent<A.HogeHandler, (object?, int)>(h => new A.HogeHandler((sender, arg) => h((sender, arg))), h => a.HogeEvent += h, h => a.HogeEvent -= h)
.Subscribe(x => Console.WriteLine($"hoge: {x}"));
// See https://aka.ms/new-console-template for more information
@itn3000
itn3000 / Dockerfile.zstdtest
Last active October 17, 2023 07:47
ZStdSharp.Port compression test code
FROM mono:6.12
COPY zstdtest /zstdtest
CMD ["mono","/zstdtest/zstdtest.exe"]
@itn3000
itn3000 / MultiTaskWithProcessorCount.cs
Created September 8, 2023 10:18
thread processor count conflict test
using System.Threading.Tasks;
using System.Threading;
using System.Linq;
using System;
await ThreadIdTest(100, 100);
async Task ThreadIdTest(int minThreads, int minCompletionNum)
{
ThreadPool.GetMinThreads(out var currentMinThreads, out var currentCompletionNum);