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 interface ISecureRandom | |
{ | |
uint Next(uint x, uint y); | |
} | |
public sealed class SecureRandom : ISecureRandom | |
{ | |
private static readonly RandomNumberGenerator DefaultRandomNumberGenerator = new RNGCryptoServiceProvider(); | |
public static SecureRandom DefaultInstance => new SecureRandom(DefaultRandomNumberGenerator); |
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
COMMENT @ | |
C Interface: | |
extern char* Rfc4180_ReadRow(const char* bufferOffset, const char* bufferTail, long long isQuotedSequence); | |
Reference: | |
https://tools.ietf.org/html/rfc4180 | |
@ | |
;-----------------------------; (CONSTANTS) | |
CARRIAGE_RETURN = 00Dh |
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 bool IsApproximatelyEqual(Func<ulong, ulong> x, Func<ulong, ulong> y, Func<ulong> randomNumberGenerator) { | |
var result = true; | |
for (var i = 0UL; (i < 9223372036854775808UL); i = NextPowerOfTwo(i)) { // monotonic testing | |
var cube = NextCube(i); | |
var square = NextSquare(i); | |
for (var j = 1UL; (j < 11UL); ++j) { | |
var cubeA = (cube + j); | |
var cubeS = (cube - j); |
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
@page "/HexCoordinates" | |
<BECanvas Width="1200" Height="1200" @ref="m_canvasReference"></BECanvas> | |
@code { | |
/// <summary> | |
/// | |
/// </summary> | |
/// <remarks> | |
/// https://www.iquilezles.org/www/index.htm |
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; |
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 FigurateNumbers { | |
public static ulong NthHexagonal(ulong value) => checked((2UL * NthSquare(value)) - value); | |
public static ulong NthOblong(ulong value) => checked(value * (value + 1UL)); | |
public static ulong NthPentagonal(ulong value) => checked(((3UL * NthSquare(value)) - value) >> 1); | |
public static ulong NthPhiCubic(ulong value) => unchecked((1UL + CubeRoot(value)) >> 1); | |
public static ulong NthPhiSquare(ulong value) => unchecked((1UL + SquareRoot(value)) >> 1); | |
public static ulong NthTriangular(ulong value) => checked(((value * (value + 1UL))) >> 1); | |
} | |
public static bool IsApproximatelyEqual(Func<ulong, ulong> x, Func<ulong, ulong> y, Func<ulong> randomNumberGenerator) { | |
var result = 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
/* | |
Install-Package ByteTerrace.Native.Vulkan | |
*/ | |
using ByteTerrace.Native.Vulkan; | |
using ByteTerrace.Native.Vulkan.Enums; | |
using ByteTerrace.Native.Vulkan.Handles; | |
using ByteTerrace.Native.Vulkan.Structs; | |
using ByteTerrace.Native.Windows; | |
using System; |
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
// 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
/// <summary> | |
/// | |
/// </summary> | |
/// <remarks> | |
/// https://www.redblobgames.com/grids/hexagons | |
/// </remarks> | |
public readonly struct HexCoordinate | |
{ | |
private const double SquareRootOfThree = 1.7320508075688772d; | |
private const double SquareRootOfThreeHalved = (SquareRootOfThree * 0.5d); |