This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// dotnet add package Microsoft.Extensions.Hosting; | |
// dotnet add package System.Reactive; | |
using Microsoft.Extensions.Options; | |
using Microsoft.Extensions.Configuration; | |
using System.Reactive.Concurrency; | |
using System.Reactive.Subjects; | |
using System.Reactive.Linq; | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.CommandLine; | |
using System.CommandLine.Binding; | |
var opt1 = new Option<string>(new string[]{ "--opt1", "-o1" }, "this is option1"); | |
var opt2 = new Option<int>(new string[]{ "--opt2", "-o2" }, "this is option2"); | |
var rootcmd = new RootCommand("this is root"); | |
rootcmd.Add(opt1); | |
rootcmd.Add(opt2); | |
rootcmd.AddCommand(CreateCommand1()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// this works with linux | |
use std::fs; | |
use pelite::pe64::Pe; | |
use pelite::pe32::Pe as Pe32; | |
use pelite::Error as PeErrors; | |
use memmap2::Mmap; | |
fn output_ver_info(p: &std::path::Path) -> Result<(), anyhow::Error> { | |
{ | |
// let f = std::fs::File::open(p)?; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using FASTER.core; | |
using var x = Devices.CreateLogDevice("xlog"); | |
var flsetting = new FasterLogSettings("hoge"); | |
using var fl = new FasterLog(new FasterLogSettings("hoge") | |
// { | |
// FastCommitMode = true, | |
// LogCommitDir = "xlog-commits" | |
// } | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See https://aka.ms/new-console-template for more information | |
using System.Threading.RateLimiting; | |
using System.Diagnostics; | |
await Concurrency(); | |
// await TokenBucket(); | |
async Task Concurrency() | |
{ | |
await using var limiter = new ConcurrencyLimiter(new ConcurrencyLimiterOptions( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// TargetFramework: net6.0 | |
// this can be avoided if there is ctor with no "ref" or "in". | |
using System.Text.Json; | |
int z = 0; | |
var c1 = new C1(ref z); | |
try | |
{ | |
JsonSerializer.Serialize(c1); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using OpenTelemetry.Trace; | |
using OpenTelemetry.Resources; | |
using OpenTelemetry; | |
using FASTER.core; | |
using System.Text.Json; | |
using System.Buffers; | |
using System.Diagnostics; | |
using OpenTelemetry.Metrics; | |
namespace opentelemetryfltest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// you can run this code in Linux,macOS,Windows(10 April 2018 or later) | |
using Microsoft.Extensions.DependencyInjection; | |
using Microsoft.Extensions.Hosting; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using System; | |
using MessagePipe; | |
public class RemotePublisher : BackgroundService | |
{ | |
IDistributedPublisher<int, int> _Publisher; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using FASTER.core; | |
// all old files are deleted after truncating in same session | |
{ | |
using var device = Devices.CreateLogDevice("test.log", recoverDevice: true); | |
using var log = new FasterLog(new FasterLogSettings() | |
{ | |
LogDevice = device, | |
SegmentSizeBits = 20, | |
MemorySizeBits = 15, | |
PageSizeBits = 10, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections.Concurrent; | |
using System.Diagnostics.Metrics; | |
using System.Diagnostics.Tracing; | |
using var cts = new CancellationTokenSource(); | |
using var meter = new Meter("m1"); | |
using var counterCollector = new CounterCollector(MyEventSource.Log); | |
var c1 = meter.CreateCounter<int>("metric-counter"); | |
counterCollector.AddCounter(c1); |