Skip to content

Instantly share code, notes, and snippets.

View daiplusplus's full-sized avatar
💀

Dai daiplusplus

💀
View GitHub Profile
@daiplusplus
daiplusplus / gist:51070c45841ea6d022454d85e399f903
Created August 11, 2024 23:36
Microsoft.Media.Player.dll\NETNATIVEBUILDINFO
Build Type: ret
Tool chain:
ilc.exe : 2.2.31116.00 built by: PROJECTNREL
nutc_driver.exe : 2.2.31116.00 built by: PROJECTNREL
rhbind.exe : 2.2.31116.0 built by: PROJECTNREL
sg.exe : 2.2.31116.00 built by: PROJECTNREL
Framework:
Activators.Implementation.dll : 11.2406.13.0
# 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
daiplusplus / Farts.linq
Created May 5, 2023 04:35
Compound word finder for StackOverflow 76178746
// https://stackoverflow.com/questions/76178746/finding-compound-words-in-a-text-file-of-150-000-words
Trie trie = new Trie(); // From NuGet `rm.Trie`: https://www.nuget.org/packages/rm.Trie
Stopwatch sw = Stopwatch.StartNew();
// From https://github.com/dwyl/english-words/blob/master/words.txt
const String PATH = @".\english-words-400k.txt";
// Pass 1: Population.
@daiplusplus
daiplusplus / gist:52b9617919fb02e2fa9e4c39aad7fb03
Created April 25, 2023 20:58
This is why I dislike init properties in C#
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
daiplusplus / Countries.cs
Last active November 1, 2022 07:34
Countries-and-US-CA-subdivisions
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.name, t => t.country, StringComparer.OrdinalIgnoreCase );
this.CountriesByIso31661Alpha2 = Country.Countries.ToDictionary( c => c.Iso31661Alpha2, StringComparer.OrdinalIgnoreCase );
this.CountriesByIso31661Alpha3 = Country.Countries.ToDictionary( c => c.Iso31661Alpha3, StringComparer.OrdinalIgnoreCase );
@daiplusplus
daiplusplus / dbadmin.Collations2.sql
Last active October 21, 2022 13:39
Useful SQL Server objects and views
CREATE VIEW dbadmin.Collations2 AS
-- https://learn.microsoft.com/en-us/sql/t-sql/statements/windows-collation-name-transact-sql?view=sql-server-ver16
WITH withSubstrings AS (
SELECT
c."name" AS "Name",
c."description" AS "Description",
@daiplusplus
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
// 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
daiplusplus / refine.snippet
Created March 7, 2022 13:45
Refinement type struct snippet
<?xml version="1.0" encoding="utf-8"?>
<CodeSnippets xmlns="http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet">
<!--
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
GO
CREATE TABLE dbo.ReservedWords (
Word sysname NOT NULL
CONSTRAINT PK_ReservedWords PRIMARY KEY ( Word )
);
GO
@daiplusplus
daiplusplus / Type_properties_for_generics.linq
Last active November 25, 2021 14:18
System.Type's properties comparison for different kinds of generics
// This LinqPad 6 script is for https://stackoverflow.com/a/70111165/159145
<Query Kind="Program">
<IncludePredicateBuilder>false</IncludePredicateBuilder>
<UseNoncollectibleLoadContext>true</UseNoncollectibleLoadContext>
</Query>
class NormalClass { }
class Generic<T> { }