Skip to content

Instantly share code, notes, and snippets.

C:\Users\silvio\Documents\Dev\nim\eval>nim c -r --cc:tcc testing.nim
Hint: used config file 'C:\Dev\Nim-devel\config\nim.cfg' [Conf]
Hint: system [Processing]
Hint: testing [Processing]
CC: testing
CC: stdlib_system
In file included from c:/users/silvio/documents/dev/nim/eval/nimcache/testing.c:9:
C:/Dev/Nim-devel/lib/nimbase.h:227: error: include file 'limits.h' not found
In file included from c:/users/silvio/documents/dev/nim/eval/nimcache/stdlib_system.c:9:
C:/Dev/Nim-devel/lib/nimbase.h:227: error: include file 'limits.h' not found
#!/bin/sh
# SEE: http://lists.nongnu.org/archive/html/tinycc-devel/2016-10/msg00146.html
# Config
DEFAULT_DEST="win32/reprobuild" # relative to top source dir
TMP_DIR="_tmp" # dir for intermidiate files inside each output dir
# Builds one windows tcc distribution
# args: TARGET_DIR, CC, {I386|X86_64}, [LIBS_CC, LIBS_AR]
# Doesn't touch anything outside of $TARGET_DIR - which must not exist on entry.
# libtcc1 objects are compiled with CC_LIBS and joined into libtcc1.a with AR_LIBS
@stisa
stisa / localStorage.nim
Created January 31, 2017 18:10
Ugly js ffi example, the name of the module is important
proc setItem (item:cstring,to:cstring){.importc, exportc:"localStorage.$1"}
proc getItem (item:cstring):string{.importc, exportc:"localStorage.$1"}
proc log(x:string) = {.emit :"console.log(`x`);"}
localStorage.setItem("hi","world")
log localStorage.getItem("hi") #> world
@stisa
stisa / htmldsl.nim
Last active February 10, 2017 17:19
htmldsl in nim
import strutils
import macros except body
# TODO: avoid all the quasi-same macros.
# TODO: expand spec (links,style,img,src etc)
# TODO: allow specifying id, class
# TODO: render the ast to proper html, with proper indentation
# TODO: group similar kinds together, eg div,body,section,header,footer,etc are all containers.
# TODO: less verbose macros for a? also macro for id,class for other nodes
@stisa
stisa / jest.nim
Last active July 23, 2020 21:58
Static file server using jester, should be roughly equivalent to `python -m http.server`
import jester, asyncdispatch
from parseopt import getopt,CmdLineKind
from strutils import parseint,isDigit
from os import dirExists
proc usage():string = r"""
Usage: jest [<dir>][<port>][--host:<addr>]
addr : the address to serve to, default: 'localhost'
port : the port to serve to, default: 8000
@stisa
stisa / typedjson.nim
Last active March 13, 2017 09:09
Json -> SomeType conversion
import json
#TODO: handle ref,ptr,tuple
proc into[T](json:seq[JsonNode],b:var openarray[T]) =
## Seq of Omogeneous JsonNodes into an array or seq of type T
for i,el in json:
when T is bool:
b[i] = el.bval
elif T is SomeInteger:
@stisa
stisa / index.html
Created March 18, 2017 20:43
Nim js backend: input element
<html>
<body>
<input id="input" type="text" name="fname">
<script src="nimcache/t.js"></script>
</body>
</html>
@stisa
stisa / outc.txt
Last active March 22, 2017 14:52
repr test
a | 0
b | 0
c | 0.0
d | '\0'
e | eA
f | 0000000000000010""
g | {}
h | {}
i | [nil, nil, nil]
@stisa
stisa / nimonandroid.md
Created March 23, 2017 06:50
recompile nim on android

Install glob

Apt install libandroid-glob
Apt install libandroid-glob-dev

compiler/nim.cfg

First suggestion:

src/
  <pkgname>.nim
tests/
docs/
<pkgname>.nimble # with srcDir = "src"

library with single module