Skip to content

Instantly share code, notes, and snippets.

include prelude
type
Node {.acyclic.} = ref object
le, ri: Node
proc checkTree(n: Node): int =
if n.le == nil: 1
else: 1 + checkTree(n.le) + checkTree(n.ri)
# Compile and run with 'nim c -r -d:useRealtimeGC -d:release main.nim'
import strutils
#import times
include "lib/system/timers"
const
windowSize = 200000
msgCount = 1000000
def main():
raiseEx = True
returnA = True
returnB = True
try: #A
try: #B
if raiseEx:
raise OSError()
return 3
template task*(name: untyped; description: string; body: untyped): untyped =
## Defines a task. Hidden tasks are supported via an empty description.
## Example:
##
## .. code-block:: nim
## task build, "default build is via the C backend":
## setCommand "c"
proc `name Task`*() =
setCommand "nop"
body
nimble install -y --verbose https://github.com/Araq/ormin
Reading config file at C:\Users\rumpf\AppData\Roaming\nimble\nimble.ini
Downloading https://github.com/Araq/ormin using git
Error: Could not read package info file in C:\Users\rumpf\AppData\Local\Temp\nimble_12672\githubcom_Araqormin\ormin.nimble;
... Reading as ini file failed with:
... Invalid section: .
... Evaluating as NimScript file failed with:
... Invalid field: C.
type
Stuff = object
proc bah {.tags: [Stuff].} =
discard
proc main =
bah()
echo "hi"
import os, std / varints
proc main =
let self = os.getAppFilename()
let content = readFile(self)
let origSize = int(uint32(content[^4]) shl 24u32 or uint32(content[^3]) shl 16u32 or
uint32(content[^2]) shl 8u32 or uint32(content[^1]))
when defined(nimOpMove):
proc `=move`[T](x, y: var seq[T]) =
mixin `=destroy`
if a.p != b.p:
var a = cast[ptr NimSeqV2[T]](addr x)
var b = cast[ptr NimSeqV2[T]](addr y)
if a.p != nil: `=destroy`(x)
import core / allocators
import system / ansi_c
type
Widget* = ref object of RootObj
drawImpl: owned(proc (self: Widget))
Button* = ref object of Widget
import json
var j = newJObject()
var i = newJString("23")
j["foo"] = i
j["bar"] = i
echo j["foo"]
j["bar"].str = "34"
echo j["foo"]