Skip to content

Instantly share code, notes, and snippets.

Andreas Rumpf Araq

Block or report user

Report or block Araq

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View extract.nim
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]))
View moves.nim
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)
View owned_widgets.nim
import core / allocators
import system / ansi_c
type
Widget* = ref object of RootObj
drawImpl: owned(proc (self: Widget))
Button* = ref object of Widget
View wrongrefs.nim
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"]
View sysstr.nim
#
#
# Nim's Runtime Library
# (c) Copyright 2012 Andreas Rumpf
#
# See the file "copying.txt", included in this
# distribution, for details about the copyright.
#
# string & sequence handling procedures needed by the code generator
View error_msg.txt
..\src\tensor\display.nim(27, 27) template/generic instantiation of `disp4d` from here
..\src\tensor\private\p_display.nim(117, 30) Error: type mismatch: got <Tensor[system.string], Tensor[system.string], seq[string], axis: int literal(1)>
but expected one of:
proc concat[T](t_list: varargs[Tensor[T]]; axis: int): Tensor[T]
first type mismatch at position: 1
required type: varargs[Tensor[concat.T]]
but expression 'hbuffer[i]' is of type: Tensor[system.string]
proc concat[T](seqs: varargs[seq[T]]): seq[T]
first type mismatch at position: 1
required type: varargs[seq[T]]
View parser_generator_ideas.nim
# The 'lexer' macro generates not only the lexing proc but also
# the relevant 'Token' type, including a TokenKind enum that is
# extracted from the actions via the 'token Kind()' syntax.
# There are two special TokenKind values always available:
# Error and Eof.
# '_' refers to the matched string.
lexer:
"[A-Za-z][A-Za-z0-9]*":
# 'keywords' is a special construct. We want to map the pattern
View copying_gc.nim
type
PtrTable = ptr object
counter, max: int
data: array[0xff_ffff, (pointer, pointer)]
template hashPtr(key: pointer): int = cast[int](key) shr 8
template allocPtrTable: untyped =
cast[PtrTable](alloc0(sizeof(int)*2 + sizeof(pointer)*2*cap))
proc rehash(t: PtrTable): PtrTable =
View nimble_log.txt
nimble install nimfuzz
Downloading https://github.com/apense/nimfuzz using git
Verifying dependencies for nimfuzz@1.3.0
Installing nimfuzz@1.3.0
Building nimfuzz/nimfuzz.exe using c backend
Prompt: Build failed for 'nimfuzz@1.3.0', would you like to try installing 'nimfuzz@#head' (latest unstable)? [y/N]
Answer: y
Downloading https://github.com/apense/nimfuzz using git
Verifying dependencies for nimfuzz@#head
Installing nimfuzz@#head
View dont_include_in_0.19.2.txt
commit 33d38c072f164745f7adfd2a97dea8a550c1c02c
Author: PMunch <peterme@peterme.net>
Date: Wed Oct 31 22:14:29 2018 +0100
Quote do now works with result in block (#7343)
* Fix result not being able to use in quote do
This fixes the annoying issue of not be able to use result inside a
quote do block. It works by a simple trick. The quote do mechanic is
You can’t perform that action at this time.