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
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);
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
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);
@page "/HexCoordinates"
<BECanvas Width="1200" Height="1200" @ref="m_canvasReference"></BECanvas>
@code {
/// <summary>
///
/// </summary>
/// <remarks>
/// https://www.iquilezles.org/www/index.htm
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;
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;
@Kittoes0124
Kittoes0124 / Vulkan - Hello Triangle.cs
Last active January 6, 2020 04:13
Uses the ByteTerrace.Native.Vulkan library to implement the code found in this guide: https://vulkan-tutorial.com/Drawing_a_triangle.
/*
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;
/*
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;
// 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;
/// <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);