Skip to content

Instantly share code, notes, and snippets.

View gradha's full-sized avatar

Grzegorz Adam Hankiewicz gradha

View GitHub Profile
@gradha
gradha / stdlib_cpuinfo.c
Created December 3, 2014 17:13
cpuinfo as module compiled with 0.9.6 compiler in debug mode
/* Generated by Nimrod Compiler v0.9.6 */
/* (c) 2014 Andreas Rumpf */
/* The generated code is subject to the original license. */
/* Compiled for: MacOSX, amd64, clang */
/* Command for C compiler:
clang -c -w -I/private/tmp/back/Nimrod/lib -o /private/tmp/back/Nimrod/nimcache/stdlib_cpuinfo.o /private/tmp/back/Nimrod/nimcache/stdlib_cpuinfo.c */
#define NIM_INTBITS 64
#include "nimbase.h"
#include <string.h>
INFO global: Vagrant version: 1.7.1
INFO global: Ruby version: 2.0.0
INFO global: RubyGems version: 2.0.14
INFO global: VAGRANT_EXECUTABLE="/opt/vagrant/bin/../embedded/gems/gems/vagrant-1.7.1/bin/vagrant"
INFO global: VAGRANT_INSTALLER_EMBEDDED_DIR="/opt/vagrant/bin/../embedded"
INFO global: VAGRANT_INSTALLER_VERSION="2"
INFO global: VAGRANT_DETECTED_OS="Darwin"
INFO global: VAGRANT_INSTALLER_ENV="1"
INFO global: VAGRANT_INTERNAL_BUNDLERIZED="1"
INFO global: VAGRANT_LOG="debug"
#########################
# CODE INCLUDED BY BOTH
# COMPILATION UNITS.
# Trait definition
type DrawableVTable* = tuple[
drawType: int,
preDraw: proc(self: ref TObject): bool {.nimcall.},
draw: proc(self: ref TObject) {.nimcall.}
]
@gradha
gradha / nimparse.nim
Created January 14, 2013 22:13
Nimrod test case for parsing a big json
import json, times, strutils
when isMainModule:
echo "Loading and parsing json"
let t1 = epochTime()
let j = parseFile("nimrod_performance.json")
assert (j.kind == JObject)
let t2 = epochTime()
echo "Took ", formatFloat(t2 - t1, ffDecimal, 2)
@gradha
gradha / gist:4533999
Created January 14, 2013 22:12
Python test case for parsing a big json
#!/usr/bin/env python
import json
import time
print "Loading and parsing json"
t1 = time.time()
j = json.load(open("nimrod_performance.json", "rt"))
print j["pak_filename"]
t2 = time.time()
@gradha
gradha / nimepakoo.nim
Created January 20, 2013 21:39
The docstring for open_chunk contains a single ` which causes "nimepakoo.nim(153, 2) Error: '`' expected", but line 153 is in the getc proc, much later.
## Convenience wrapper around raw `nimepak <nimepak.html>`_ module.
##
## The usual operation with these procs is to create a Tepak var and call
## init() on it to use it. You can call is_valid() at any time on a Tepak to
## check its validity.
import nimepak
export nimepak.F_BUF_SIZE
export nimepak.F_PACK_MAGIC
@gradha
gradha / docstrings.nim
Created January 21, 2013 11:31
(25, 18) Error: '*' expected Error: unhandled exception: (25, 18) Error: '*' expected [ERecoverableError]
proc doc1*(text: string) =
## Blah blah blah the blah
##
## Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
## blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
## blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
## blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
## blah blah blah blah blah blah blah blah blah blah blah blah
##
## Blah blah blah blah blah blah blah blah blah blah blah blah blah blah blah
@gradha
gradha / except.nim
Created January 21, 2013 23:03
What echos do you get?
proc test1() =
raise newException(E_base, "Hey ho")
proc tester() =
except: echo "2. except block"
finally: echo "3. Finally block"
echo "1. Pre exception"
test1()
echo "NaN. Post exception"
@gradha
gradha / weird.nim
Created February 2, 2013 20:02
weird.nim(12, 9) Error: undeclared field: 'PK_INT'
type
TNodeKind = enum PK_EMPTY, PK_INT, PK_STRING
TNode = object
case kind: TNodeKind
of PK_EMPTY: nil
of PK_INT: int_val: int
of PK_STRING: str_val: string
template new_node(kind: TNodeKind, expr): TNode {.immediate.} =
@gradha
gradha / idetools.nim
Created February 3, 2013 17:07
Unexpected nimrod idetools behaviour on $data.str_val
type
Tparam_kind* = enum PK_EMPTY, PK_STRING
Tparsed_parameter* = object
case kind*: Tparam_kind
of PK_EMPTY: nil
of PK_STRING: str_val*: string
proc `$`*(data: Tparsed_parameter): string {.procvar.} =
case data.kind: