xmonader / nimdays Goto Github PK
View Code? Open in Web Editor NEWNim days book
Home Page: https://xmonader.github.io/nimdays/
Nim days book
Home Page: https://xmonader.github.io/nimdays/
Nimibook is a Nim version of mdbook with a great benefit of executing all Nim code and embedding its output into the output.
when copy&pasting your code, i get an IndexError. The problem starts here:
proc decode(this: Decoder, source: string) : (BencodeType, int) =
var curchar = source[0]
var idx = 0
while idx < source.len:
curchar = source[idx]
case curchar
of 'i':
let pair = this.decode_i(source[idx..source.len])
let obj = pair[0]
let nextobjpos = pair[1]
idx += nextobjpos
return (obj, idx)
of 'l':
let pair = this.decode_l(source[idx..source.len])
let obj = pair[0]
let nextobjpos = pair[1]
idx += nextobjpos
return (obj, idx)
of 'd':
let pair = this.decode_d(source[idx..source.len])
let obj = pair[0]
let nextobjpos = pair[1]
idx += nextobjpos
return (obj, idx)
else:
let pair = this.decode_s(source[idx..source.len])
let obj = pair[0]
let nextobjpos = pair[1]
idx += nextobjpos
return (obj, idx)
source.len must give that error on string slicing, it should be len(source)-1. If i change that, the testcode compiles and works ... it seems.
The next problem is, that the decode_s method is only working, when len(source) < 10, otherwise:
testObjects[BencodeType(kind: btString, s:"this is a test")] = "14:this is a test"
I saw the Forwarder is defined like this:
type Forwarder = object of RootObj
options*: ForwardOptions
and then there is a constructor proc:
proc newForwarder(opts: ForwardOptions): ref Forwarder =
result = new(Forwarder)
result.options = opts
and then Forwarder can be passed into processClient and serve with type ref Forwarder
and as I'm quite new to nim, I was confused with defining Fowarder in ref object, and the whole code like this:
type Forwarder = ref object of RootObj
options*: ForwardOptions
.
.
proc newForwarder(opts: ForwardOptions): Forwarder =
result = new(Forwarder)
result.options = opts
.
.
proc serve(this: Forwarder) {.async.} =
...
the code is ok to be compiled, but I don't know if it's ok to do that, and the difference between the two way of defining object.
I did try almost all of the examples, and none would compile. I was wondering for 'finalized' source code so I can see what I am doing wrong. I also did try the 'shorturl' program, (created a new NIM file) then created shorturl.c in a directory, then 'nim c' and only found that I got :
Hint: used config file '/usr/local/Cellar/nim/1.0.0/nim/config/nim.cfg' [Conf]
Hint: system [Processing]
Hint: widestrs [Processing]
Hint: io [Processing]
Hint: shorturl [Processing]
/Users/tmunn/src/nim/shorturl/shorturl.nim(4, 8) Error: cannot open file: jester
when I click on the repo link at the end of the page, I go to https://xmonader.github.io/nimdays/github.com/xmonader/nim-parsec but it should redirect me to https://github.com/xmonader/nim-parsec
in HTML view the code snippets can be longer than the textarea
Make sure a complete version of the code available as link to a repo or gist file.
CLI options parser does not work without parseopt2
that I could not find using nimble
.
Please provide a substitution for this command-line options parser.
mkdir dmidecode
nimble init
AFAIK should be
mkdir dmidecode
cd dmidecode
nimble init
I tried the code with forwarding to a http server, I first get the page displayed in browser, after several seconds I got the following error:
/nim-1.0.0/lib/pure/asyncfutures.nim(383) read
]#
Exception message: index out of bounds, the container is empty
Exception type: [IndexError]
Publish.sh uses mdbook, assumes it is installed at PATH. I think it needs a mention in Readme or in script comment, what do you think?
Is this a correct link?
Any reason you don't write tests?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.