Skip to content

Instantly share code, notes, and snippets.

View in-async's full-sized avatar

inasync in-async

View GitHub Profile
ECCurve curve = ECCurve.NamedCurves.nistP256;
HashAlgorithmName hashName = HashAlgorithmName.SHA256;
// Generate ECC Key
byte[] x, y, d;
{
using ECDiffieHellman ecc = ECDiffieHellman.Create();
//using ECDsa ecc = ECDsa.Create();
ecc.GenerateKey(curve);
ECParameters ecParams = ecc.ExportParameters(includePrivateParameters: true);
@in-async
in-async / JsonMergePatch.cs
Last active March 26, 2021 04:19
JSON Merge Patch with Json.NET
#nullable enable
using System;
using Newtonsoft.Json.Linq;
namespace Commons {
/// <summary>
/// JSON Merge Patch (RFC 7396) を行うクラス。
/// <para>see https://tools.ietf.org/html/rfc7396</para>
namespace Inasync {
internal struct DirtableValue<T> {
private T _value;
public DirtableValue(T initial) : this() {
_value = initial;
}
public T Value {
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
namespace Commons {
public static class CsvSerializer {
public static CsvSerializer<T> Create<T>(IEnumerable<(string name, Func<T, object?> valueSelector)>? columns = null) {
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace Commons {
public class CsvReader : IDisposable {
private readonly TextReader _reader;
private readonly List<string> _record = new();
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Threading;
using System.Threading.Tasks;
namespace Commons {
using System;
using System.Threading.Tasks;
namespace Inasync {
public sealed class AsyncDisposable<T> : IAsyncDisposable {
private readonly Func<ValueTask> _disposeAsync;
public AsyncDisposable(T value, Func<ValueTask> disposeAsync) {
Value = value;
@in-async
in-async / IAsyncObservable.cs
Created September 16, 2020 07:09
サブスクライブの await とキャンセルが可能な Observable インターフェース。
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
namespace Commons {
/// <summary>
/// サブスクライブの <c>await</c> とキャンセルが可能な Observable インターフェース。
@in-async
in-async / TaskHelper.cs
Created September 14, 2020 05:25
TaskHelper.WheAll (...) waits asynchronously for the entire dynamic collection of tasks to finish.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Inasync {
public static class TaskHelper {
public static Task WhenAll(ICollection<Task> source) {
@in-async
in-async / ShardReader.cs
Created September 9, 2020 04:17
Amazon Kinesis Data Streams - ShardReader
using System;
using System.Collections.Concurrent;
using System.Linq;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Amazon.Kinesis;
using Amazon.Kinesis.Model;
namespace KinesisHelpers {