This file contains hidden or 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
import posix, strformat, typetraits | |
proc duplicate*(oldHandle, newHandle: FileHandle) = | |
if dup2(oldHandle, newHandle) < 0: | |
raise newException( | |
ValueError, | |
fmt"Unable to duplicate file handle {oldHandle}." | |
) |
This file contains hidden or 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
import pegs, strformat, strutils, unicode | |
let grammer = peg""" | |
# Node Expressions | |
commandline <- seperated_cmd / simple_cmd | |
seperated_cmd <- simple_cmd WS SEPERATOR WS simple_cmd | |
simple_cmd <- ATOM ( WS ATOM )+ ( WS redirection )? | |
redirection <- REDIRECTOR ( ATOM ) | |
# Token expressions |
This file contains hidden or 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
import parseutils, strutils | |
template emitErrorIf(condition, errorString) = | |
if condition: | |
echo(errorString) | |
return 1 | |
proc execDefine(input: string): int = | |
var position, newPosition = 0 | |
This file contains hidden or 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
proc sequenceAssign[T](to: var seq[T], from: seq[T]) = | |
to = newSeq(len(from)) | |
for index in 0..high(to): | |
memcopy(addr to[index], addr from[index], sizeof(T)) |
This file contains hidden or 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
import tables, regex, osproc, os, strformat, sequtils, streams, posix | |
import lexer, parser, treeutils | |
# Low-level Constants/Procedures | |
when defined(windows): | |
proc c_fileno(f: FileHandle): cint {. | |
importc: "_fileno", header: "<stdio.h>".} | |
else: | |
proc c_fileno(f: File): cint {. |
This file contains hidden or 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
{.push, stdcall, dynlib: "Advapi32.dll".} | |
proc CryptReleaseContext*( | |
hProv: HCRYPTPROV; | |
dwFlags: culong | |
): cint {.importc: "CryptReleaseContext".} | |
proc CryptAcquireContextA*( | |
phProv: ptr HCRYPTPROV; | |
szContainer: cstring; | |
szProvider: cstring; |
This file contains hidden or 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
proc newAddress*(key: string): string = | |
#ase58 encoded version of the first 80 characters, and append the checksum of the key. | |
var keyHash = $digest(sha512, key) | |
keyhash.setLen(80) | |
result = Base58.convert(Hex.revert(keyhash)) | |
result.add(generateChecksum(key)) | |
while result.len < 57: | |
result.insert("0", 0) |
This file contains hidden or 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
type | |
RawSecp256k1Context* = distinct pointer | |
RawSecp256k1ScratchSpace* = distinct pointer | |
Secp256k1Context* = ref object | |
raw*: RawSecp256k1Context | |
Secp256k1ScratchSpace* = ref object | |
raw*: RawSecp256k1ScratchSpace |
This file contains hidden or 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
// #ifdef __cplusplus | |
// extern "C" { | |
// #endif | |
// #ifndef MAXMINDDB_H | |
// #define MAXMINDDB_H | |
/* Request POSIX.1-2008. However, we want to remain compatible with | |
* POSIX.1-2001 (since we have been historically and see no reason to drop | |
* compatibility). By requesting POSIX.1-2008, we can conditionally use |
This file contains hidden or 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
# This... | |
let nums = { | |
"0": "₀", | |
"1": "₁", | |
"2": "₂", | |
"3": "₃", | |
"4": "₄", | |
"5": "₅", | |
"6": "₆", | |
"7": "₇", |