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; | |
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); |
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 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)); | |
} |
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); |
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
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 |
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
.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 |
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 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; |
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
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 |
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
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 |
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; | |
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; |