Re: Is there a command line one-line to start an HTTP server using Nim?

2020-05-27 Thread bung
[https://github.com/bung87/nimhttpd](https://github.com/bung87/nimhttpd) you can try my fork version httpd support serve file through file system, memory zip, file zip.

Re: Is there a command line one-line to start an HTTP server using Nim?

2020-05-27 Thread enthus1ast
i've build one, but it needs some love (especially the part where ip addresses are queried from the os) [https://github.com/enthus1ast/nimAsyncHttpTools/blob/master/src/simplehttpserver.nim](https://github.com/enthus1ast/nimAsyncHttpTools/blob/master/src/simplehttpserver.nim)

Is there a command line one-line to start an HTTP server using Nim?

2020-05-27 Thread kaushalmodi
Using python, one can trivially fire off an HTTP server to serve the files from the current directory using: python3 -m http.server Run Is there an equivalent one-liner for Nim?

Stream IO errors with -d:release flag

2020-05-27 Thread seves
The stream module seems strange to me. When I compile my avi demuxer with -d: release it throws IO errors, but not without: The same file is read in both release and debug mode. This is the part in which the error occurs: proc read_video_frame*(avi: Avi; vidbuf: ptr UncheckedArray

Re: VSCode debug: strings and booleans are ugly

2020-05-27 Thread aviator
Here's an how I set things up: [https://github.com/russpowers/nim-debug-example](https://github.com/russpowers/nim-debug-example) It uses python to customize the gdb output, which generally works pretty well. You still get a lot of junk variables, but the ones you care about are usually there.

Nim Cheatsheet PDF (English+Spanish+Latex)

2020-05-27 Thread juancarlospaco
* [https://www.overleaf.com/read/svnxffsjvscy](https://www.overleaf.com/read/svnxffsjvscy)

Re: Change Nim colour on GitHub

2020-05-27 Thread Yardanico
So my PR was merged - [https://github.com/github/linguist/pull/4866](https://github.com/github/linguist/pull/4866), but then reverted ([https://github.com/github/linguist/pull/4871](https://github.com/github/linguist/pull/4871)) because turns out some other language (Dafny) got a really similar

Re: Change Nim colour on GitHub

2020-05-27 Thread moigagoo
I think yellow is the way to go, just gotta find a different shade that passes the proximity test. Maybe more orange would do.

Re: Can I "prune" directories with walkDirRect?

2020-05-27 Thread cblake
And just to close out the example more fully for @chalybeum, since he said he was a beginning programmer, he could probably start from the code below (after a `nimble install 'cligen@#head'`) to do whatever it was he wanted to six months ago if he even stuck with programming, with Nim and/or thi

Re: Creating a seq or openarray on unmanaged memory

2020-05-27 Thread mratsim
Only Rust has memory safe zero-copy collection that can be stored in a type (their slice type). C++ and D can somewhat emulate that with ranges but I don't thing they have proper lifetime/escape analysis as you would need a borrow checker for that. Nim has openarray, but it cannot be stored, yo

Re: incorrect set-to-int conversion

2020-05-27 Thread mratsim
Nim sets and C flags have a different byte representation, use another type to distinguish between both. Example [https://github.com/numforge/laser/blob/d1e6ae61/laser/photon_jit/photon_osalloc.nim#L50-L61](https://github.com/numforge/laser/blob/d1e6ae61/laser/photon_jit/photon_osalloc.nim#L50-L

Re: incorrect set-to-int conversion

2020-05-27 Thread snej
> Note that enums with holes may become deprecated in future That would be silly IMHO — there are so many uses for enums that are non-consecutive. It seems like Nim's idea of enums is primarily "named ordered values you can make a set out of", and assigning specific numbers to them is considere

Re: Can I "prune" directories with walkDirRect?

2020-05-27 Thread cblake
I put various things that "might be useful" for Unix CLI utilities under `cligen/` so client code can just have `cligen` as a leaf/sole dependency. Directory tree recursion fits that pattern, and stdlib `walkDir*` never seemed quite right to me. There is already `cligen/posixUt.recEntries`, for

Re: Can I "prune" directories with walkDirRect?

2020-05-27 Thread kaushalmodi
Wow!.. why is it in **cligen** though? It looks like it can be a separate `find`-competition package :)

Re: Doc generation fails

2020-05-27 Thread kaushalmodi
I have reported this in issue [https://github.com/nim-lang/Nim/issues/14473](https://github.com/nim-lang/Nim/issues/14473) . Thanks for providing that minimal example.

Re: incorrect set-to-int conversion

2020-05-27 Thread Stefan_Salewski
Yes, that is well known, I discussed that behaviour with Araq 3 years ago related to gintro. I then added dummy zero flags when the gtk enums started not with 0. Note that enums with wholes may become deprecated in future, so we may have to add even dummy values for missing values. Araq sometime

Re: Creating a seq or openarray on unmanaged memory

2020-05-27 Thread snej
> Wrap the ptr UncheckedArray, len pair in an object I could do that, but this object would be a second-class citizen since it's neither an array nor seq nor string. I could implement `[]` and `len`, but it still wouldn't work with e.g. `sequtils`, right? I guess what I'm saying is that Nim doe

Re: Doc generation fails

2020-05-27 Thread kaushalmodi
I have seen a similar issue on nim devel too. I am trying to create a reproducible example for that. I also see runnableExamples trying to get executed from sequtils.. My Nim module does import sequtils, but there are no runnableExamples in it. Also, I think this issue happens when I have \--pa

Re: Doc generation fails

2020-05-27 Thread kaushalmodi
This happens on nim devel (the version should be 1.3.5). I see that you are using nim stable 1.2.0.

incorrect set-to-int conversion

2020-05-27 Thread snej
As part of bridging a set of bit-masks in a C API, I declared an enum and a set: type Flag = enum A = 4 B = 6 # ... more flags... Flags = set[Flag] Run After about half an hour of debugging an mysterious EINVAL return value from the

Re: Can I "prune" directories with walkDirRect?

2020-05-27 Thread cblake
Of course, that doesn't control recursive descent which was @chalybeum's driving use case but you did use a smiley. :-) Based on possible broader interest and a general trend lately of trying to be less abstract, I just added a template-based tree iteration to `cligen/dents.nim`: [https://gith

Re: Doc generation fails

2020-05-27 Thread jiro4989
hmm... I did not occured error. My environment is here. $ nim --version Nim Compiler Version 1.2.0 [Linux: amd64] Compiled at 2020-04-03 Copyright (c) 2006-2020 by Andreas Rumpf active boot switches: -d:release Run ⟩ cat /etc/os-release

Re: Doc generation fails

2020-05-27 Thread qqtop
Here a mini example which displays this error on nim-devel : #cxtimeb.nim import sequtils template doit():untyped = ## doit ## return output only toSeq([1,2,3,4,5]) echo doit() Run Output ok :

Re: Can I "prune" directories with walkDirRect?

2020-05-27 Thread juancarlospaco
... but walkPattern() does take a glob pattern. :)

Re: thiscall calling convention?

2020-05-27 Thread rgv151
FYI, [thiscall](https://github.com/nim-lang/Nim/commit/00fa7a57476ed6fe81fb2d9171ba902fad9b83d5) just get merged into dev branch

Re: Doc generation fails

2020-05-27 Thread qqtop
There are no runnableExamples in my module. The module imports sequtils The only way I found to circumvent this error in docgen is to add following line in my module : export sequtils Run I think this should not be required.

Re: Doc generation fails

2020-05-27 Thread jiro4989
I want to watch code of cxtimeb.nim.

Doc generation fails

2020-05-27 Thread qqtop
After most recent improvements to doc generation I see this error running nim doc : /home/lxuser/.cache/nim/cxtimeb_d/runnableExamples/cxtimeb_examples1.nim(15, 12) Error: undeclared identifier: 'toSeq' [runnableExamples] failed: generated file: '/home/lxuser/.cache/nim/cxtime

Re: Doc generation fails

2020-05-27 Thread jiro4989
Is there `import sequtils` in runnableExamples? runnableExamples: import sequtils echo toSeq(1..10) Run

Re: Can I "prune" directories with walkDirRect?

2020-05-27 Thread cblake
@chalybeum ..the feature being mentioned seems to be the `FilterDescend` predicate function of the referenced package. You would just load up a Nim `HashSet` from `sets` with to be skipped paths and pass some predicate like `path notin blacklist`, with `blacklist` probably being a captured closu

Re: How to implement observer (publish/subscribe) pattern?

2020-05-27 Thread Pixeye
How about more "reactive" observers ? [https://gist.github.com/PixeyeHQ/fbec35b25b667b847b4eac413a8539a5](https://gist.github.com/PixeyeHQ/fbec35b25b667b847b4eac413a8539a5) The idea is to subscribe for variable change. The proc you register will trigger every time this variable changes.

Re: Creating a seq or openarray on unmanaged memory

2020-05-27 Thread cdome
This proc from system you will need: proc toOpenArray*[T](x: ptr UncheckedArray[T]; first, last: int): openArray[T] {. magic: "Slice".} Run

Re: execProcess when spaces in directory path

2020-05-27 Thread timothee
> I'd like to use nim to execute something like "C:UsersMeAppDataLocalThe > AppTheApp.exe --uninstall --silent" or "bob" for short did you mean: "C:UsersMeAppDataLocalThe App\TheApp.exe --uninstall --silent" Run ? (you were missing the ) > execShellCmd(bob)

Re: How to implement observer (publish/subscribe) pattern?

2020-05-27 Thread Kosteg
I can do this but it's not convenient to have all the subscribers be of the same class

Re: Creating a seq or openarray on unmanaged memory

2020-05-27 Thread b3liever
Wrap the ptr UncheckedArray, len pair in an object and write custom =destroy and = procs. (= would be `proc `=`(self: var Foo; other: Foo) {.error.}` since you want to avoid copies. The destructor frees the memory using whatever function is provided by the C library.