Skip to content

Instantly share code, notes, and snippets.

@jaykang920
jaykang920 / SignalHandler.cs
Created May 25, 2018 09:20
.NET Core: handling signals in console app
using System;
// Tested on .NET Core 2.1
class Program
{
static void Main(string[] args)
{
Console.CancelKeyPress += OnSigInt;
AppDomain.CurrentDomain.ProcessExit += OnSigTerm;
@jaykang920
jaykang920 / PseudoRandom.cs
Last active June 29, 2018 05:59
A fast thread-safe wrapper for the default pseudo-random number generator
// https://gist.github.com/jaykang920/8234457
using System;
using System.Security.Cryptography;
/// <summary>
/// A fast thread-safe wrapper for the default pseudo-random number generator.
/// </summary>
public static class PseudoRandom
{
@jaykang920
jaykang920 / Getopt.cs
Last active February 7, 2018 10:23
C# clone of the GNU C getopt
// https://gist.github.com/jaykang920/8234393
using System;
using System.IO;
using System.Reflection;
/// <summary>Getopt is a clone of the GNU C getopt.</summary>
public class Getopt
{
/// <summary>Indicates that the option does not take an argument.</summary>