Skip to content

Instantly share code, notes, and snippets.

@tonogram
tonogram / extensions.json
Last active April 19, 2022 16:20
All of the domain name extensions currently available on porkbun.com (with some choice exclusions)
[
"abogado",
"ac",
"academy",
"accountant",
"accountants",
"actor",
"adult",
"ae.org",
"agency",
# https://twitter.com/fermatslibrary/status/1385957963429515266
import tables
from strutils import toLower
const PrimeNumbers = toTable [
('a', 2),
('b', 3),
('c', 5),
('d', 7),
@tonogram
tonogram / Q_rsqrt.nim
Created March 8, 2021 19:57
Nim implementation of Q_rsqrt using inline C/C++
proc Q_rsqrt*(number: float): float =
{.emit: """long i;
float x2, y;
const float threehalfs = 1.5F;
x2 = number * 0.5F;
y = number;
i = * ( long * ) &y;
i = 0x5f3759df - ( i >> 1 );
y = * ( float * ) &i;
@tonogram
tonogram / getName.nim
Created June 10, 2020 04:59
Get name of Nim enum with attached string
from macros import toStrLit
type myEnum = enum
Example = "Hello, world!"
macro getName(x: enum): string =
x.toStrLit()
assert $Example == "Hello, world!" # $ (toString) gets attached string of enum
assert Example.getName() == "Example" # getName gets name of enum