Skip to content

Instantly share code, notes, and snippets.

View treeform's full-sized avatar

Andre von Houck treeform

View GitHub Profile
import streams
when hostOS == "windows":
proc wgetch(): char {. header: "<conio.h>", importc: "getch" .}
proc wgetche(): char {. header: "<conio.h>", importc: "getche" .}
# stdout.write("\e[2J") # clear screen
const promt = "quicki >>> "
proc pythonMod(n, M: int): int = ((n mod M) + M) mod M
assert pythonMod(1, -4) == -3
assert pythonMod(-1, 4) == 3
assert pythonMod(-1, -4) == -1
assert pythonMod(1, 4) == 1
#[
kiwi is a packed key value table/dictinary/associate-arrays like objects that is packed into a single buffer.
kiwis don't optimize key access, but its pretty fast to do a liner scan if your kiwi is less then 100 elements.
]#
type
Kiwi* = object
arr: seq[uint8]
Should I do?
if (`b`.length > `a`.length) {
return -`b`[`a`.length];
}
vs
if (`b`.length > `a`.length) {
return -1;
import json, strutils, algorithm
type
Mapping* = object
## mapping object that represents the line
generatedLine: int
generatedColumn: int
originalLine: int
originalColumn: int
source: string
import json
import strutils
type
Mapping = object
generatedLine: int
generatedColumn: int
originalLine: int
originalColumn: int
source: string
import macros
macro print*(n: varargs[typed]): untyped =
result = newNimNode(nnkStmtList, n)
for i in 0..n.len-1:
if n[i].kind == nnkStrLit:
# pure string literals are written diretly
result.add(newCall("write", newIdentNode("stdout"), n[i]))
else:
# other expressions are written in <expression>: <value> syntax
+---------+--------------------+-------+
| faction | avg | count |
+---------+--------------------+-------+
| MOD | 727.6 | 5 |
| AUTO | 614.6 | 20 |
| GBC | 593.6 | 5 |
| TKKA | 577.7368421052631 | 19 |
| CNCR | 517.7659574468086 | 47 |
| TOTO | 502.2 | 5 |
| STIX | 464.5 | 10 |
+---------+---------+
| faction | sum |
+---------+---------+
| N0V4 | 31424 |
| ELYS | 29525 |
| CNCR | 24335 |
| AI | 20686 |
| ISOI | 13966 |
| EVO | 12425 |
| AUTO | 12292 |
+------------------+------+
| name | rank |
+------------------+------+
| Godde | 2029 |
| Mode | 1972 |
| Pemtyu | 1843 |
| Apo11o | 1646 |
| raaar | 1639 |
| TheDefiantOne | 1621 |
| 514484 | 1608 |