Skip to content

Instantly share code, notes, and snippets.

View Varriount's full-sized avatar

Clay Sweetser Varriount

View GitHub Profile
# builder.nim, line 746 (nimbuild repo)
proc hubConnect(state: PState, reconnect: bool) =
echo("hubConnect")
state.sock = AsyncSocket()
state.sock.handleConnect = proc (s: PAsyncSocket) = handleConnect(s, state)
state.sock.handleRead = proc (s: PAsyncSocket) = handleHubMessage(s, state)
state.reconnecting = reconnect
state.sock.connect(state.cfg.hubAddr, TPort(state.cfg.hubPort))
state.dispatcher.register(state.sock)
@Varriount
Varriount / dmp.nim
Last active December 25, 2015 21:58
DiffMatchPath Bug
from times import epochTime
#import ropes
type
NaturalFloat = range [0.0 .. Inf]
TDMPSettings = object
diffTimeout: NaturalFloat ## Number of seconds to map a diff before
## giving up (0 for infinity).
# Old, C-Sharp code
string longtext = text1.Length > text2.Length ? text1 : text2;
string shorttext = text1.Length > text2.Length ? text2 : text1;
#New, nimrod code.
var longText = textOne
var shortText = textTwo
if len(textOne) > len(textTwo):
swap(longText, shortText)
proc delete*[T](s: var seq[T], first, last: int) =
## Deletes in `s` the items at position `first` .. `last`. This modifies
## `s` itself, it does not return a copy.
var i = first
var j = last+1
var newLen = len(s)-j+i
while i < newLen:
s[i].shallowCopy(s[j])
inc(i)
inc(j)
@Varriount
Varriount / gist:7079279
Created October 21, 2013 05:59
I present to you... Nimrod-Sharp
/*
* Copyright 2008 Google Inc. All Rights Reserved.
* Author: [email protected] (Neil Fraser)
* Author: [email protected] (Matthaeus G. Chajdas)
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
Bootstrapping!
[New Thread 7448.0x1794]
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 7448.0x1794]
0x0000000000454b79 in getbigchunk_30616 (a=0x301120, size=12288) at c:/64/nimrod/lib/system/alloc.nim:490
490 if result.size == size:
C:\common\Nimwrappers>nimrod compile helloworld.nim
c:\64\nimrod\config\nimrod.cfg(36, 2) Hint: added path: 'C:\Users\Clay\.babel\pkgs\' [Path]
Hint: used config file 'C:\64\nimrod\config\nimrod.cfg' [Conf]
Hint: system [Processing]
Hint: helloworld [Processing]
gcc.exe -c -w -IC:\64\nimrod\lib -o c:\common\nimwrappers\nimcache\nimwrappers_helloworld.o
gcc.exe -c -w -IC:\64\nimrod\lib -o c:\common\nimwrappers\nimcache\nimrod_system.o c:\common
gcc.exe -o c:\common\nimwrappers\helloworld.exe c:\common\nimwrappers\nimcache\nimrod_sys
Hint: operation successful (7828 lines compiled; 3.338 sec total; 13.133MB) [SuccessX]
#mangle "'_'{.*}" "$1"
#mangle "'__'{.*}" "$1"
// Copyright (c) 2013 Marshall A. Greenblatt. All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
//
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
@Varriount
Varriount / gist:7275618
Created November 2, 2013 04:44
Comparison of imports in nimrod
import table # You can use anything declared public in the table module
from table import TTable # You can ONLY reference TTable, none of its methods
from table import TTable, len, [], mget, hasKey, []=, add, del, initTable, toTable, $, pairs, mpairs, keys, values, mvalues # Now we can use everything associated with TTable
type
Wrapper[T] = object of TObject
iter: # The iterator procedure
args: # Arguments of the iterator