This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Azure.Core; | |
using Azure.Identity; | |
using System.Net.Http.Headers; | |
using System.Net.Http.Json; | |
using System.Text.Json; | |
using System.Text.Json.Serialization; | |
var apiMap = new Dictionary<string, (string ApiVersion, string ResourceIdFormatString)> { | |
{ "subnets", ("2022-11-01", "Microsoft.Network/virtualNetworks/{0}/subnets/{1}") }, | |
{ "virtualMachines", ("2023-03-01", "Microsoft.Compute/virtualMachines/{0}") }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Buffers; | |
using System.Numerics; | |
using System.Runtime.CompilerServices; | |
using System.Runtime.InteropServices; | |
using System.Security.Cryptography; | |
namespace Ouroboros.Maths; | |
public static class BinaryIntegerConstants<T> where T : IBinaryInteger<T> | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var decode = 4188287251U; // 4238739751U; // 4265539247U; | |
var encode = 4160962843U; // 4236695191U; // 2130976847U; | |
var sw = Stopwatch.StartNew(); | |
for (var i = 1U; i <= (uint.MaxValue / 2); i += 4) { | |
var ei0 = unchecked((i + 0) * encode); | |
var ei1 = unchecked((i + 1) * encode); | |
var ei2 = unchecked((i + 2) * encode); | |
var ei3 = unchecked((i + 3) * encode); | |
var ipi0 = IpAddressV4.New(value: ei0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static T SetLeastSignificantBits<T>(this T value) where T : IBinaryInteger<T>, IUnsignedNumber<T> { | |
var x = (value | (value >> 1)); | |
x |= (x >> 2); | |
x |= (x >> 4); | |
if (BinaryIntegerConstants<T>.Size > T.CreateChecked(value: 8UL)) { | |
x |= (x >> 8); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var detectorSize = 37; | |
do { | |
var detector = new ulong[detectorSize]; | |
while (!detector.Any(x => (0 != x))) { } | |
Console.WriteLine("Cosmic ray detected."); | |
} while (true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Name: ByteTerrace Delimited Record (BTDR) | |
Description: A compact file format for storing structured data. | |
Glossary: | |
Delimiter: A symbol that represents the boundary between two values. | |
Escape Sentinel: A symbol that signals either the beginning or end of a binary sequence. | |
Field Separator: A symbol that represents a delimiter for fields. | |
Record Separator: A symbol that represents a delimiter for records. | |
Specification: | |
Consistent OverheadByte Stuffing (COBS): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Known Issues: | |
0) Joining to the same table results in circular references. | |
1) Joining to any table results in the loss of all type information. | |
*/ | |
interface Array<T> { | |
toBtSqlTable(keySelector: IndexKeySelector<T>): TableWithOperators<T>; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// define a container for information relevant to each row | |
public sealed class SqlResultSetRow : IEnumerable<(string fieldName, Type fieldType, object fieldValue)> | |
{ | |
private readonly (string fieldName, Type fieldType, object fieldValue)[] m_fields; | |
public int ResultSetIndex { get; } | |
public SqlResultSetRow((string, Type, object)[] fields, int resultSetIndex) { | |
m_fields = fields; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/dependency-injection | |
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/host/generic-host | |
https://docs.microsoft.com/en-us/azure/azure-app-configuration/ | |
https://docs.microsoft.com/en-us/dotnet/architecture/microservices/multi-container-microservice-net-applications/background-tasks-with-ihostedservice | |
*/ | |
using Azure.Identity; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.Configuration.AzureAppConfiguration; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class ShaderHelpers | |
{ | |
private static readonly Vector3 m_normal_xxx = new Vector3(1f, 1f, 1f); | |
private static readonly Vector3 m_normal_xyy = new Vector3(1f, -1f, -1f); | |
private static readonly Vector3 m_normal_yxy = new Vector3(-1f, 1f, -1f); | |
private static readonly Vector3 m_normal_yyx = new Vector3(-1f, -1f, 1f); | |
public static float Clamp(float value, float x, float y) { | |
if (x > y) { | |
var z = x; |