Skip to content

Instantly share code, notes, and snippets.

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

Yusuke Ito itn3000

πŸ€”
πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”πŸ€”
View GitHub Profile
@itn3000
itn3000 / ConfigurationFromEmbeddedPhysical.cs
Last active December 9, 2020 07:48
IConfiguration from embeddedresource or physical file
using System;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.FileProviders;
namespace cfgtest
{
class Program
{
static void Main(string[] args)
{
@itn3000
itn3000 / activitysourcesample.cs
Last active November 6, 2020 09:47
ActivitySource sample
using System;
using System.Diagnostics;
namespace activitysample
{
class Program
{
private static readonly ActivitySource _ActivitySource = new ActivitySource("actsrc1");
static void Main(string[] args)
@itn3000
itn3000 / DiagnosticSourceILogger.cs
Created October 21, 2020 07:08
DiagnosticSource output to MS.E.Logging.ILogger
using System;
using System.Diagnostics;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Console;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.Threading.Tasks;
using System.Threading;
using System.Collections.Generic;
@itn3000
itn3000 / eventpipeerrortest.cs
Created October 15, 2020 02:26
EventPipeEventSource callback error
using System;
using System.Threading.Tasks;
using Microsoft.Diagnostics.Tracing;
using Microsoft.Diagnostics.NETCore.Client;
using System.Diagnostics.Tracing;
namespace eventpipeerrortest
{
class Program
{
@itn3000
itn3000 / ReadFromEventPipe.cs
Created October 2, 2020 10:05
reading events from EventPipe example
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Text;
using Microsoft.Diagnostics.NETCore.Client;
using System.Diagnostics.Tracing;
using Microsoft.Diagnostics.Tracing.Parsers;
using Microsoft.Diagnostics.Tracing;
@itn3000
itn3000 / DiagnosticSourceBenchmark.cs
Created September 30, 2020 08:38
rough benchmark overhead of DiagnosticSource and ActivitySource
using System;
using System.Diagnostics;
using System.Collections.Generic;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Running;
namespace diagnosticbench
{
class ActivityTest
{
@itn3000
itn3000 / OpenPgpWithBc.cs
Created September 25, 2020 10:51
process OpenPGP data with bc-csharp
using System;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Org.BouncyCastle.Bcpg.OpenPgp;
using Org.BouncyCastle.Crypto.Parameters;
using Org.BouncyCastle.Crypto.Utilities;
using Org.BouncyCastle.Crypto.Generators;
using Org.BouncyCastle.Crypto;
using Org.BouncyCastle.Security;
@itn3000
itn3000 / ExecuteInterfaceDefaultMethod.cs
Last active July 7, 2020 07:35
execute interface default method in derived class
using System;
public interface IA
{
public void X()
{
Console.WriteLine("Hello world");
}
}
public class C : IA {
public void M() {
@itn3000
itn3000 / checksslcert.cs
Created June 23, 2020 08:37
check ssl server certification sample
using System;
using System.Net.Http;
using System.Security.Cryptography.X509Certificates;
using System.Threading.Tasks;
using System.Net.Security;
namespace chkcert
{
class Program
{
@itn3000
itn3000 / get-winsdktoolpath-100.ps1
Last active June 11, 2020 07:49
get windows sdk tool path
$basekey = [Microsoft.Win32.RegistryKey]::OpenBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, [Microsoft.Win32.RegistryView]::Registry32)
$key = $basekey.OpenSubKey("SOFTWARE\Microsoft\Windows Kits\Installed Roots")
if($key -ne $null)
{
# windows sdk 10
$wkit10root = $key.GetValue("KitsRoot10")
foreach($kitsver in $key.GetSubKeyNames())
{
$wkit10bin = Join-Path $wkit10root "bin" | Join-Path -ChildPath $kitsver
$wkit10result = Test-Path $(Join-Path $wkit81bin "signtool.exe")