Skip to content

Instantly share code, notes, and snippets.

@rogercloud
rogercloud / chantest.nim
Created September 1, 2015 03:52
Warning: use global iterator here is not a good practice.
import os, threadpool, macros
template spawnBackgroundJob(t: typedesc, chan:ptr TChannel[t], iter: expr): stmt {.immediate.}=
block:
proc threadFunc(channel: ptr TChannel[t]) {.thread.} =
echo "Thread is starting"
for i in iter:
echo "Sending ", i
channel[].send(i)
@rogercloud
rogercloud / gist:8160201
Created December 28, 2013 14:47
bittorrent download
import libtorrent as lt
import time
import sys
ses = lt.session()
ses.listen_on(6881, 6891)
info = lt.torrent_info(sys.argv[1])
h = ses.add_torrent({'ti': info, 'save_path': './'})
print 'starting', h.name()