Skip to content

Instantly share code, notes, and snippets.

View Varriount's full-sized avatar

Clay Sweetser Varriount

View GitHub Profile
[GCASSERT] incRef: interiorPtr
Traceback (most recent call last)
builder.nim(916) builder
builder.nim(773) open
builder.nim(754) hubConnect
gc.nim(242) asgnRef
gc.nim(102) incRef
C:\64\Nimrod>.\tools\detect\detect.exe
CMD gcc -o testh.exe testh.c
testh.c:1:17: fatal error: aio.h: No such file or directory
#include <aio.h>
^
compilation terminated.
Not found: <aio.h>
CMD gcc -o testh.exe testh.c
testh.c:1:19: fatal error: dlfcn.h: No such file or directory
#include <dlfcn.h>
# Generated by detect.nim
const
E2BIG* = cint(7)
EACCES* = cint(13)
EADDRINUSE* = cint(100)
EADDRNOTAVAIL* = cint(101)
EAFNOSUPPORT* = cint(102)
EAGAIN* = cint(11)
EALREADY* = cint(103)
EBADF* = cint(9)
import os, sequtils
const doslike = defined(windows) or defined(OS2) or defined(DOS)
proc u2np(path: string): string =
return unixToNativePath(path)
proc testUnixToNativePath() =
# Have input and output example paths for each system.
# Depending on the system, run the input path and compare against
# the output path.
#
#
# osPlus.nim
#
# Enhancements and additional procedures for os.nim
#
import os
const
DirLike = {pkDir, pkLinkToDir}
FileLike = {pkFile, pkLinkToFile}
@Varriount
Varriount / removeDirs.nim
Created January 2, 2014 20:19
RemoveDir Implementations
## Original Implementation
proc removeDir*(dir: string) =
for kind, path in walkDir(dir):
case kind
of pcFile, pcLinkToFile, pcLinkToDir: removeFile(path)
of pcDir: removeDir(path)
rawRemoveDir(dir)
## New Implementation
from sublime_plugin import EventListener
COMMENT_SCOPE = "comment.line.number-sign.nimrod"
FAIL_TOLERANCE = 3
DEBUG = False
def debug(string):
if DEBUG:
print(string)
proc getFileInfo(path: string, followSymlinks:true): FileInfo =
## Retrieve the metadata associated with file system object pointed
## to by `path` .
when defined(Windows):
var openFlags = FILE_ATTRIBUTE_NORMAL
if followSymlinks:
openFlags = (openFlags or FILE_FLAG_OPEN_REPARSE_POINT)
var handle = createFileW(path, 0'i32, 0'i32, nil, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0)
# Current styles of generic procedures
# Generic
proc foo[T](a: int, b: T): T =
result = b
var i = 0
while i < a:
result = result+b
# Typedesc
# Normally, iterators must be passed all their arguments each time they are iterated over
iterator counter(start, stop:int): int {.closure.} =
var x = start
while x < stop:
yield x
inc(x)
var counterInstance = counter
echo(counterInstance(0,5))
echo(counterInstance(0,5))