Skip to content

Instantly share code, notes, and snippets.

View itn3000's full-sized avatar
🤔
🤔🤔🤔🤔🤔🤔

Yusuke Ito itn3000

🤔
🤔🤔🤔🤔🤔🤔
View GitHub Profile
@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);
@itn3000
itn3000 / splitstrtest.cs
Last active May 29, 2023 08:38
split string test
using System.Text;
// space(U+0020),tab(U+0009),fullwidth space(U+3000),linefeed(U+000a)
var str = "a b\tc d\n";
foreach(var x in str.Split(' '))
{
Console.WriteLine($"a: '{x}'");
}
foreach(var x in str.Split(null))
{
@itn3000
itn3000 / redblack_chatgptgenerated.cs
Created March 17, 2023 05:07
redblack tree code
using System;
public class RedBlackNode<T> where T : IComparable<T>
{
public T Data { get; set; }
public RedBlackNode<T> Left { get; set; }
public RedBlackNode<T> Right { get; set; }
public bool IsRed { get; set; }
}