Skip to content

Instantly share code, notes, and snippets.

View daiplusplus's full-sized avatar

Dai daiplusplus

View GitHub Profile
View gist:497d0d8c1841bacdb578b0193af509d2
# Main
L0000 push rdi
L0001 push rsi
L0002 push rbp
L0003 push rbx
L0004 sub rsp, 0x58
L0008 vzeroupper
L000b xor eax, eax
L000d mov [rsp+0x50], rax
daiplusplus / Farts.linq
Created May 5, 2023 04:35
Compound word finder for StackOverflow 76178746
View Farts.linq
Trie trie = new Trie(); // From NuGet `rm.Trie`:
Stopwatch sw = Stopwatch.StartNew();
// From
const String PATH = @".\english-words-400k.txt";
// Pass 1: Population.
daiplusplus / gist:52b9617919fb02e2fa9e4c39aad7fb03
Created April 25, 2023 20:58
This is why I dislike init properties in C#
View gist:52b9617919fb02e2fa9e4c39aad7fb03
using System;
using System.Globalization;
public static class Program
public static void Main()
AReddishColor pink = new AReddishColor( r: 244, g: 189, b: 224 );
Console.WriteLine( "pink: {0}", pink );
daiplusplus / Countries.cs
Last active November 1, 2022 07:34
View Countries.cs
public class AddressDatabase
public static AddressDatabase Instance { get; } = new AddressDatabase();
private AddressDatabase()
this.CountriesByAllNames = Country.Countries.SelectMany( c => c.AllNames.Select( n => ( country: c, name: n ) ) ).ToDictionary( t =>, t =>, StringComparer.OrdinalIgnoreCase );
this.CountriesByIso31661Alpha2 = Country.Countries.ToDictionary( c => c.Iso31661Alpha2, StringComparer.OrdinalIgnoreCase );
this.CountriesByIso31661Alpha3 = Country.Countries.ToDictionary( c => c.Iso31661Alpha3, StringComparer.OrdinalIgnoreCase );
daiplusplus / dbadmin.Collations2.sql
Last active October 21, 2022 13:39
Useful SQL Server objects and views
View dbadmin.Collations2.sql
CREATE VIEW dbadmin.Collations2 AS
WITH withSubstrings AS (
c."name" AS "Name",
c."description" AS "Description",
daiplusplus / DotNet System.Single IEEE-754 IsNormal IsSubnormal Etc Comparison Table.linq
Last active April 14, 2022 15:39
Generates a table that compares the output of .NET's IEEE-754 methods
View DotNet System.Single IEEE-754 IsNormal IsSubnormal Etc Comparison Table.linq
// Instructions: copy-and-paste this into Linqpad 6 or later (I used Linqpad 7).
void Main()
List<TestResult> results = Run( includeArithmeticResults: false ).ToList().Dump();
String markdownTable = GenerateMarkdownTable( results );
Util.WithStyle( data: markdownTable, htmlStyle: "font-family: monospace;" ).Dump();
daiplusplus / refine.snippet
Created March 7, 2022 13:45
Refinement type struct snippet
View refine.snippet
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="">
Usage/installation instructions:
1. Save to a file `refine.snippet` somewhere (e.g. in `C:\Users\You\Documents\Visual Studio {year}\Code Snippets\Visual C#\My Code Snippets`).
* If saved outside your `Visual Studio {year}` folder, or if it isn't detected, add it manually via <kbd>Tools > Code Snippets Manager...</kbd> (Tip: ensure the top "Language" drop-down says "CSharp" as it defaults to ASP.NET for some reason).
2. To try it out, open a .cs file and move your cursor/caret to inside a `namespace`, then type the word "`refine`" and IntelliSense should list it as a snippet in the completion-list popup.
* If it doesn't appear despite being recognized by Code Snippets Manager ensure VS is configured to list Snippets in the code completion list (Tools > Options > Text Editor > C# > IntelliSense > Snippets behavior > "Always include snippets").
3. Press <kbd>Tab</kbd> once or twice
View ReservedWords.sql
CREATE TABLE dbo.ReservedWords (
Word sysname NOT NULL
daiplusplus / Type_properties_for_generics.linq
Last active November 25, 2021 14:18
System.Type's properties comparison for different kinds of generics
View Type_properties_for_generics.linq
// This LinqPad 6 script is for
<Query Kind="Program">
class NormalClass { }
class Generic<T> { }
daiplusplus / Private_JsonConstructor.cs
Last active November 25, 2021 03:52
private JsonConstructor example
View Private_JsonConstructor.cs
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Linq;
using Newtonsoft.Json.Schema;
using Newtonsoft.Json.Serialization;
void Main()
HasPrivateCtor e = new HasPrivateCtor( "123" );