Skip to content

Instantly share code, notes, and snippets.

View planetis-m's full-sized avatar
💭
Make everything from scratch. Hardcore Mode.

Antonis Geralis planetis-m

💭
Make everything from scratch. Hardcore Mode.
View GitHub Profile
proc sortObject(tree: var JsonTree, n: NodePos) =
var pairs: seq[(string, NodePos)]
for ch0 in sonsReadonly(tree, n):
let key = firstSon(NodePos ch0.pos).str
let value = NodePos(ch0.pos + 2)
pairs.add((key, value))
pairs.sort do (a, b: (string, NodePos)) -> int:
cmp(a[0], b[0])
type
EmbeddedImage* = distinct Image
EmbeddedWave* = distinct Wave
EmbeddedFont* = distinct Font
ShaderLocsPtr* = distinct typeof(Shader.locs)
proc `=destroy`*(x: var EmbeddedImage) = discard
proc `=dup`*(source: EmbeddedImage): EmbeddedImage {.nodestroy.} = source
proc `=copy`*(dest: var EmbeddedImage; source: EmbeddedImage) {.nodestroy.} =
<div id="ROOT">
<header>
<h2 class="font-light text-2xl md:text-4xl text-gray-600">Ancient Wisdom</h2>
</header>
<div class="mt-8">
<img src="blurred.jpg" alt="" class="absolute" width=1464>
<div class="bg-white rounded-md overflow-hidden shadow-xl relative">
<img src="portrait.jpg" alt="" width="512" height="512" class="">
<div class="">
import os, enum, shutil, subprocess
class CpuPlatform(enum.Enum):
arm = 1
arm64 = 2
i386 = 3
amd64 = 4
class DeviceOrientation(enum.Enum):
portrait = 1
@planetis-m
planetis-m / nim.cfg
Last active October 4, 2023 23:15
Top level nim.cfg
#cc = clang
--experimental:strictEffects
--experimental:strictFuncs
--experimental:strictDefs
--experimental:unicodeOperators
--experimental:overloadableEnums
--define:nimPreviewCstringConversion
--define:nimPreviewFloatRoundtrip
--define:nimStrictDelete
--define:nimUseLinenoise
@planetis-m
planetis-m / mybuildcmds.rst
Last active October 4, 2023 23:15
My build commands

Debug

nim c --cc:clang --mm:orc --panics:on --threads:on --threadanalysis:off --tlsEmulation:off -l:"-fuse-ld=mold" %f

Release

from typetraits import supportsCopyMem
const
maxEntities* = 10_000
type
Array*[T] = object
data: ptr array[maxEntities, T]
proc `=destroy`*[T](x: var Array[T]) =
# Compile with: nim c --gc:orc --panics:on --fieldChecks:on casevariants
# Compare with -d:emiDuplicateKey -d:emiLenient
import eminim, std/[parsejson, streams]
type
Fruit = enum
Banana, Apple
Bar = object
shared: int
import eminim, std/[parsejson, streams]
type
Fruit = enum
Banana, Apple
Bar = object
shared: int
kind: Fruit
bad: float
@planetis-m
planetis-m / csp.nim
Created January 19, 2021 00:47
Classic Computer Science Problems in Python
import tables, options, sugar
type
Constraint*[V, D] = ref object
# Base class for all constraints
variables*: seq[V] # The variables that the constraint is between
satisfied*: proc (assignment: Table[V, D]): bool
Csp*[V, D] = object
# A constraint satisfaction problem consists of variables of type V