code snippet review: truncate string while preserving words

2021-01-14 Thread Hlaaftana
I would do something like this: from strutils import Whitespace proc truncate*(s: string, truncAt: int, suffix = "..."): string = var at = -1 var i = 0 for i, c in s: if i < truncAt or at < 0: if c in Whitespace: if i <= truncAt: at

NiGUI: Custom widgets

2021-01-14 Thread michy
Shouldn't your 'handleDrawEvent' method have the same signature as the example?

NiGUI: Custom widgets

2021-01-14 Thread lotzz
I am not sure where else to ask this question. I am trying to not bother the person who works on this package: [NiGUI](https://github.com/trustable-code/NiGui/tree/07225b1737d56e8f93c8b5500f2c76f5ea7936cb). I am trying to make a custom widget similar to the one described in this example here. .

"This Month With Nim"- A Community Showcase

2021-01-14 Thread ElegantBeef
Well I've decided to try to be the ["some has to do it"](https://github.com/nim-lang/website/pull/253)

"This Month With Nim"- A Community Showcase

2021-01-14 Thread halloleo
I am working on a little CLI command which extracts given tags from an OPF file to a given eBook. - My first Nim project!

Any way to access the Documentation Comment of a procedure?

2021-01-14 Thread halloleo
That's pretty cool. Works well. Thanks! (Though I'm _[slightly](https://forum.nim-lang.org/postActivity.xml#slightly) surprised there's nothing like this built in.)

code snippet review: truncate string while preserving words

2021-01-14 Thread dogwater
What's the most efficient way to truncate a string to a given character count while preserving words? I implemented the below using tokenize(). But given that this will run on a dozens of elements to render a page, looking to minimize overhead. proc truncate*(s: string, truncAt: in

Google Summer of Code, Feb 19, 2021

2021-01-14 Thread bpr
Yup, I call that stuff "academic abandonware". It's certainly common. You can take a look at pages like / to see what people have achieved before. Working on hard advanced, stuff requires a bright student and an ac

nlvm update 2020

2021-01-14 Thread Araq
This is excellent news. I hoped it would support ARC/ORC given that most of the implementation is done as an AST transformation. But not a big issue, maybe you should skip 1.4 altogether, 1.6 has many internal changes already in preparation for IC and IC could change how nlvm's code base looks l

nlvm update 2020

2021-01-14 Thread arnetheduck
Not much time for `nlvm` unfortunately, but I was able to spend some time on it over new year, meaning a few bugfixes made it in there at least! * llvm updated to v11.0 - nice perf boost, latest wasm updates etc * nim updated to 1.2.6 - this took quite a few changes, but support for 1.2 is n

What's the preferred way to compile nim to WebAssembly?

2021-01-14 Thread treeform
I have a step by step Emscripten Nim tutorial: Maybe it can help you out?

Google Summer of Code, Feb 19, 2021

2021-01-14 Thread Stefan_Salewski
> Incremental Compilation, Concepts, Async: Continuations So a student, generally unexperienced in Nim, often without much CS knowledge, shall solve these task on which the brightest Nim devs work since years? Some years ago I saw a female student working on improving a Gnome game or converting

Google Summer of Code, Feb 19, 2021

2021-01-14 Thread bpr
So, what would some ideas be? Looking at the old page, current RFCs, and git/forum activity, here are a few unfinished/contentious directions in Nim space that look interesting to me Nim Compiler * Incremental Compilation (IC) * Concepts: (the technology of tomorrow, always has been, always

memberProc macro

2021-01-14 Thread ElegantBeef
No I was only showing the construct file as it works for `distinct`, `ref`, and normal `objects`.

How to serialize/deserialize my data type with options and DateTime

2021-01-14 Thread treeform
Looking at date time more, I don't think DateTime is a good candidate for serializing because it contains pointers to functions that determine timezone. How do you want to handle the timezones? I would recommend just stocking with unix epoc (seconds from 1970) if you don't want to make your life

How to serialize/deserialize my data type with options and DateTime

2021-01-14 Thread treeform
I tried deser_json and I get the same errors. I fixed hasCustomPragma with `import macros` but then I get `m.tokens[pos].kind == JSMN_OBJECT` ... I don't know how to get around that one. If you want to use json (for easier debugging or compatibility) take a look at these libraries they pass my

Admin for web app

2021-01-14 Thread jasonfi
What are the features you're looking for? I'm working on something like this, but it's too early to release anything. Is it the CRUD views?

Admin for web app

2021-01-14 Thread vinyll
Prologue would probably be a more appropriate framework for constructing such a large feature. I'll have a deeper look. I had a look at a while ago and I guess it could be the closest to combine and get a full admin with Prologue, Jester or others

memberProc macro

2021-01-14 Thread chaemon
Thanks! I am reading the code. Is the following code example of member proc?

Any way to access the Documentation Comment of a procedure?

2021-01-14 Thread lqdev
You can do so by creating a macro that inspects the syntax tree of your procedure and extracts doc comments from it: import std/macros import std/strutils # the parameter has to be `typed` because we need to access the proc's # implementation macro doc(procedure:

Back on Nim: Understanding nimble

2021-01-14 Thread jackhftang
If you are writing packages for other packages, it is better to use range requires "foo >= 0.1.2 & < 0.2.0" requires "bar >= 1.3.1 & < 2.0" Run Also, be more considerate on Nim verison, don't be too aggressive using the latest one requires "nim >= 1.

Any way to access the Documentation Comment of a procedure?

2021-01-14 Thread halloleo
When I have a procedure like this proc solver:string = ## Solves all the problems of the world return 42 Run How can I access the Documentation Comment " _Solves all the problems of the world_ " in the code following the procedure. Looking for something lik

Silly scope shadowing question

2021-01-14 Thread halloleo
Thanks. That's a lot simpler!

Admin for web app

2021-01-14 Thread geotre
There is currently no Django-admin equivalent in Nim that I know of, besides building your own two options could be: * Use django for models and admin, use Nim to connect to database and serve API/pages * Use a Nim ORM and web framework, and use an admin framework that is designed to run di

Back on Nim: Understanding nimble

2021-01-14 Thread dom96
Note that eventually we hope Nimble will gain lockfiles support, so these pinned versions will not belong in the .nimble file. For now you can certainly pin it in .nimble though and I do that a lot myself.

Nim interact with Windows .NET Frameworks

2021-01-14 Thread Aiesha_Nazarothi
I did something strange again: Unsure, if this ever gonna be completed, yet it's may be good idea to _eventually_ write full replacement for stdlib using `CLR` binding.

"This Month With Nim"- A Community Showcase

2021-01-14 Thread enthus1ast
Good idea, but the thing is, someone has to do it.

Back on Nim: Understanding nimble

2021-01-14 Thread ynfle
Check out [https://github.com/nim-lang/nimble#dependencies](https://forum.nim-lang.org/postActivity.xml#httpscolonslashslashgithubdotcomslashnimminuslangslashnimble-dependencies)

"This Month With Nim"- A Community Showcase

2021-01-14 Thread jasonfi
I'm working on a todo manager: . What's online now is the MVP, but I plan to add many more features.

"This Month With Nim"- A Community Showcase

2021-01-14 Thread ElegantBeef
I have mentioned this idea multiple times in the realtime chat, inspired by [this](https://forum.nim-lang.org/t/6971) post. I think to encourage publicating/showcasing projects Nimions are working it would be benefical to have a monthly(Could be a larger window) blog post that users can submit t

memberProc macro

2021-01-14 Thread ElegantBeef
As much as I dislike the emulating of classes in Nim here is usable version for only `object` types. {.experimental.} import macros proc convertToMemberProc( procDefNode:NimNode, className:string ) = var formalParamsNode = procDefNode[3] formalParamsNode.exp

Google Summer of Code, Feb 19, 2021

2021-01-14 Thread adokitkat
If you got accepted I would love to try to join as a intern / student :)

Google Summer of Code, Feb 19, 2021

2021-01-14 Thread Araq
Even if we don't get accepted (as usual), it's a good idea to participate in order to write down ideas and goals for Nim in 2021.

Silly scope shadowing question

2021-01-14 Thread Araq
If your module is named `x` you can access the global via `x.verbose`, no need for a template workaround. The power of Nim -- it also works well without macros!

How to understand nimprof report?

2021-01-14 Thread Araq
I don't know... nimprof is pretty dead, I encourage you to use a real profiler instead. About the copying, expensive copies are done through helper procs so it would show up clearly in the profile.