Skip to content

Instantly share code, notes, and snippets.

View Kittoes0124's full-sized avatar
🏠
Working from home

David Smith Kittoes0124

🏠
Working from home
View GitHub Profile
using System.Numerics;
using System.Runtime.CompilerServices;
var input = UInt128.MaxValue;
var v = ((byte)input).SquareRoot();
Console.WriteLine($"{v}");
var w = ((ushort)input).SquareRoot();
Console.WriteLine($"{w}");
var x = ((uint)input).SquareRoot();
using System.Numerics;
var w = BinaryIntegerFunctions.ComputeMagicConstant<ushort>();
Console.WriteLine($"{w} {Convert.ToString((long)w, 2)}");
var x = BinaryIntegerFunctions.ComputeMagicConstant<uint>();
Console.WriteLine($"{x} {Convert.ToString(x, 2)}");
var y = BinaryIntegerFunctions.ComputeMagicConstant<ulong>();
Console.WriteLine($"{y} {Convert.ToString((long)y, 2)}");
var z = BinaryIntegerFunctions.ComputeMagicConstant<UInt128>();
Console.WriteLine($"{z} {Convert.ToString((long)z, 2)}");
using Azure.Core;
using System.Text.Json;
namespace Sandbox;
public sealed class AzureIdentityHttpClient(HttpClient httpClient)
{
public async Task<T?> SendAsync<T>(
Func<HttpResponseMessage, JsonSerializerOptions, CancellationToken, ValueTask<T>> handler,
HttpMethod httpMethod,
using Azure.Core;
namespace Sandbox;
public sealed class AzureIdentityAuthenticationHandler(TokenCredential tokenCredential) : DelegatingHandler
{
public static HttpRequestOptionsKey<TokenRequestContext> TokenRequestContextKey => new(key: nameof(TokenRequestContext));
protected override async Task<HttpResponseMessage> SendAsync(
HttpRequestMessage httpRequestMessage,
namespace Sandbox;
public sealed class PropertyMetadata
{
private string m_name = string.Empty;
private Type m_type = typeof(void);
public string Name {
get => m_name;
set {
using CommunityToolkit.Diagnostics;
using System.ComponentModel.DataAnnotations.Schema;
using System.IO.Hashing;
using System.Numerics;
using System.Reflection;
using System.Reflection.Emit;
using System.Text;
using System.Text.Json.Nodes;
using System.Text.Json;
--[[ References:
https://breezewiki.com/wowpedia/wiki/Events
https://breezewiki.com/wowpedia/wiki/Global_functions
https://breezewiki.com/wowpedia/wiki/UIHANDLER_OnGamePadButtonDown
https://breezewiki.com/wowpedia/wiki/UIOBJECT_Button
https://breezewiki.com/wowpedia/wiki/UIOBJECT_Frame
https://breezewiki.com/wowpedia/wiki/UIOBJECT_Texture
https://github.com/Gethe/wow-ui-textures
/dump, /etrace, /fstack
@Kittoes0124
Kittoes0124 / StupidEncryption.cs
Created October 2, 2023 02:16
This silly implementation of an encryption algorithm uses a [Cunningham chain](https://en.wikipedia.org/wiki/Cunningham_chain) to obscure a 32-bit value.
public class StupidEncryption
{
private const string STREAM_VALUE_ERROR = "Stream offset must be a positive integer less than 2^31.";
private const uint STREAM_VALUE_MAX = ((1U << 31) - 1U);
public static uint Seed = 4125763933U;
public static uint PrimeModularInverse1 = (Seed - 2U); // 4125763931
public static uint Prime1 = PrimeModularInverse1.ModularInverse(); // 0920248019
public static uint Prime0 = (Prime1 >> 1); // 0460124009
public static uint Prime2 = ((Prime1 << 1) | 1U); // 1840496039
/*
create master key encryption by password = N'Tell me about the waters of your homeworld, Usul.';
go
create database scoped credential [https://<name>.azurewebsites.net]
with identity = N'Managed Identity'
, secret = N'{ "resourceId": "<application-registration-id>" }';
go
create database scoped credential [https://<name>.blob.core.windows.net]
with identity = N'Managed Identity'
, secret = N'{ "resourceId": "https://storage.azure.com" }';
/*
https://byteterrace.blob.core.windows.net/temp/Gödels.dat
https://byteterrace.blob.core.windows.net/temp/Primes.dat
*/
var buffer = new byte[10];
var cacheSize = 4096;
var numbersCache = new byte[cacheSize][];
var primeIndex = 0;
var recordSeparator = ((byte)Convert.ToChar(value: 30));