Skip to content

Instantly share code, notes, and snippets.

var source = Ints();
await foreach (var item in Debounce(source, TimeSpan.FromSeconds(0.5)))
{
Console.WriteLine($"{DateTime.Now} {item}");
}
static async IAsyncEnumerable<int> Ints()
{
for (int i = 0; i < 80; i += 5)
@Ilchert
Ilchert / Throttle.cs
Last active May 29, 2025 18:25
Throttle
await using var limiter = new FixedWindowRateLimiter(new FixedWindowRateLimiterOptions() { Window = TimeSpan.FromSeconds(1), PermitLimit = 1, AutoReplenishment = true, QueueLimit = 1 });
var source = Ints();
await foreach (var item in Debounce(source, limiter))
{
Console.WriteLine($"{DateTime.Now} {item}");
}
static async IAsyncEnumerable<int> Ints()
{
@Ilchert
Ilchert / HttpClinetConfig.cs
Created March 18, 2025 17:23
HttpClinetConfig
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHttpClient();
builder.Services.AddSingleton<ICertificateProvider, CertificateProvider>();
builder.Services.AddSingleton<IPostConfigureOptions<HttpClientFactoryOptions>, ConfigureHttpClientFactory>();
var app = builder.Build();
var factory = app.Services.GetRequiredService<IHttpClientFactory>();
app.MapGet("/{clientId}", async (string clientId) =>
1. Create c:\1.restore.json
2. msbuild c:\1.csproj -target:GenerateRestoreGraphFile -property:RestoreGraphOutputPath="c:\1.restore.json" -property:RestoreRecursive=false -property:RestoreDotnetCliToolReferences=false
3. dotnet nuget package add --package Litedb c:\\1.csproj --dg-file c:\1.restore.json
using System;
using System.Collections.Generic;
using System.Linq;
// define BowlingGame Class in a new file
// define Frame Class in a new file
class MainClass
{
static void Main()
static class RSAParametersHelper
{
public static RSAParameters FromPem(string pem)
{
using var rsa = new RsaPem();
rsa.ImportFromPem(pem);
return rsa.ExportParameters();
}
class RsaPem : RSA
public class Container
{
private SortedDictionary<int, int> _storage = new();
private int _count = 0;
public Container()
{
// write your code here
}
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Options;
public class Programm
{
static int _idCounter = 0;
interface IService
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
var services = new ServiceCollection();
services.AddSingleton<RootService>();
services.AddSingleton<IService, RootService>();
PluginImplementation.Configure(services);
using var rootSp = services.BuildServiceProvider();
var pluginRegistration = rootSp.GetRequiredService<IOptionsMonitor<PluginRegistration>>()
//solution2("...xxx..x....xxx.", 7);
//solution("aaAbcCABBc");
static int solution2(string S, int B)
{
if (B < 2 || S.Length == 0)
return 0;
var potholes = new List<int>();
var count = 1;