Skip to content

Instantly share code, notes, and snippets.

@rogercloud
rogercloud / chantest.nim
Created Sep 1, 2015
Warning: use global iterator here is not a good practice.
View chantest.nim
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 Dec 28, 2013
bittorrent download
View gist:8160201
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()