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;
using System.Runtime.ConstrainedExecution;
using System.Runtime.InteropServices;
using System.Security;
namespace ByteTerrace.Windows.Api
{
static class BitwiseHelpers
{
public static uint ConcatBits(ushort highPart, ushort lowPart) => ((((uint)highPart) << 16) | lowPart);
public sealed class Die
{
private readonly int m_numberOfSides;
private readonly IRandomNumberGenerator m_rng;
public Die(int numberOfSides, IRandomNumberGenerator rng) {
if (0 > numberOfSides) {
throw new ArgumentOutOfRangeException(actualValue: numberOfSides, message: "value must be greater than zero", paramName: nameof(numberOfSides));
}
/// <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);
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
COMMENT @
https://agner.org/optimize/instruction_tables.pdf
https://agner.org/optimize/microarchitecture.pdf
https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-createfilew
https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-getfilesizeex
https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-readfile
https://docs.microsoft.com/en-us/windows/desktop/api/fileapi/nf-fileapi-writefile
https://docs.microsoft.com/en-us/windows/desktop/api/handleapi/nf-handleapi-closehandle
https://docs.microsoft.com/en-us/windows/desktop/api/memoryapi/nf-memoryapi-createfilemappingw
https://docs.microsoft.com/en-us/windows/desktop/api/memoryapi/nf-memoryapi-mapviewoffileex
.code
Main proc
sub rsp, 28h ; align with 16 while simultaneously setting up the "home space"
; TODO: something useful here...
xor eax, eax ; set return value to zero
add rsp, 48h ; free all space that was reserved on the stack
ret ; end of main
Main endp
end
public class BinaryHeap<T>
{
private readonly IComparer<T> m_comparer;
private readonly IList<T> m_values;
private int m_offset;
public int Capacity => m_values.Count;
public int Count => m_offset;
select X = X.n
, [Circle] = [Circle].n
, [DxCircle] = X.n / NullIf(2. * Abs(X.n), 0)
, [Rectangle] = [Rectangle].n
, [Dx Rectangle] = 1. / Sqrt(4 * X.n + 1)
, [Square] = [Square].n
, [Dx Square] = 1. / NullIf(2. * Sqrt(X.n), 0)
, [Triangle] = [Triangle].n
, [Dx Triangle] = 2. / Sqrt(8 * X.n + 1)
, [Square Triangle] = [Square Triangle].n
A048597 "Very round numbers: reduced residue system consists of only primes and 1."
- finite (10)
- 1, 2, 3, 4, 6, 8, 12, 18, 24, 30
A000040 "The prime numbers."
- infinite
- 2, 3, 5, 7, 11, 13, 17, 19, 23, 29...
30:
- becomes 8 when passed through Euler's Totient Function
using System;
using System.Text;
namespace ByteTerrace.CSharp.Data
{
public struct AsciiString : IEquatable<AsciiString>
{
private readonly byte[] m_data;
private readonly uint m_length;
private readonly uint m_offset;