Enabling compression on socket send/receive.

2024-08-22 Thread void09
Thank you Clonk, but like I said, I wanted to avoid the "ifs", and case is just an alternative if. Already know to implement it like this. My question was how I can implement it with storing the procs instead, like I said 3 times already :)

Enabling compression on socket send/receive.

2024-08-21 Thread void09
not sure what you mean there Araq. That is what I want to accomplish here, write 3 procs, sendUncompressed, sendGzip, sendDeflate, and when compression is enabled, just do client.sendProc = sendGzip or whatever. And all socket sends are handled by client.sendProc(data: string). I am stuck at thi

Enabling compression on socket send/receive.

2024-08-21 Thread void09
I am trying to write a NNTP client for nim, for some reason this basic ancient protocol is not implemented in any lib I could find. NNTP protocol allows for gzip or deflate compression. I know an if boolean for every send is not a big deal, but if it can be done better, by swapping assigned proc

Enabling compression on socket send/receive.

2024-08-18 Thread void09
Thank you, I guess that is an acceptable workaround while keeping the same syntax of nntp.sendProc(), but the reason I wanted to store the procedure as a field in the object, is to avoid the if compress: sendCompressed else: sendUncompressed. Would avoid extra code and runtime overhead for all t

Enabling compression on socket send/receive.

2024-08-17 Thread void09
bump. still no solution found yet

Enabling compression on socket send/receive.

2024-08-15 Thread void09
I tried to get a proc as field in my client object, so i can swap it at runtime without having if else everywhere. I have these definitions: proc sendProcU(nntp: NNTP | AsyncNNTP, data: string) {.multisync.} = await nntp.sock.send(data) NNTPClientBase*[SocketType]

Enabling compression on socket send/receive.

2024-08-12 Thread void09
already saw that example that is not relevant to the topic. if compression then send compress(string) else send string. I was looking for a more generic socket-centric solution.

Enabling compression on socket send/receive.

2024-08-11 Thread void09
What would be the most simple/elegant way to have (de)compression enabled on all data sent/received over a socket ? In go it appears that it's as simple as: .. code-block:: go > conn, err := net.Dial("tcp", "localhost:8080") > > `if err != nil ...` > > gzipWriter := gzip.NewWriter(conn) messag

Newbie Here! Can I have some feedback on my code?

2024-08-08 Thread void09
Since the strings use are constant, better to define them before the code, it's cleaner imho. You can use the contains proc with sets of letters, like this, instead of your loops: let shouting = phrase.contains({'A'..'Z'}) and not phrase.contains({'a'..'z'} This part is redundant " elif co

High level TUI framework (or wrapper of)

2023-09-25 Thread void09
Well, I decided I will learn rust and attempt my project there. Nim ecosystem (libs and potential manpower, as well as velocity of growth) too sparse for the job unfortunately. And also because my poor coding speed and knowledge can't make up for the lacking ecosystem. Will still use Nim for sim

High level TUI framework (or wrapper of)

2023-09-22 Thread void09
@oakes It would be great if you could provide a one widget example/template. Not sure how it would differ from illwillwidgets mentioned above.

High level TUI framework (or wrapper of)

2023-09-20 Thread void09
Thank you enthus1ast, somehow I missed that project. I believe it is enough to get me started on it in nim. Although everything is rather primitive, no auto sizing based on terminal resize, no scrollable list for table. Do you think you have time in the near future to make the table scrollable,

High level TUI framework (or wrapper of)

2023-09-19 Thread void09
I was under the impression that termbox/2 has some simple widgets, like a scrollable table, seeing made with it. But it seems it draws everything manually, and for that I could use the already existing nim lib illwill. So I can scratch the temrboxes from the l

High level TUI framework (or wrapper of)

2023-09-19 Thread void09
Already posted here (), but trying the forum as well for more visibility. I've been wanting to make a tui app for some time, planned on using nimwave, but on closer look I was surprised to see that there's basically no widgets implemented

Wishlist: Ideal UI library for Nim

2023-06-26 Thread void09
I believe the right approach for this is something like Lazarus' LCL, having a unified interface, with different platform-specific implementations of various wideget sets. Here is what they have working so far: I have found

nim merch

2023-06-22 Thread void09
I agree that we should have more or less nerdy nim t-shirts, caps etc. officially. So people of the nim almost secret by obscurity society can recognize each other. Would certainly be more useful stuff to buy than Araq's book.

Need suggestions for time scheduling async tasks

2023-06-02 Thread void09
Thank you for the suggestion, unfortunately the way it works is not clear to me, and how I should implement it for my use case. I realized the actual requests are done by a single procedure in my code, and I can calculate a sleep delay at the start of it, given the times previous requests were m

Need suggestions for time scheduling async tasks

2023-06-01 Thread void09
I am writing a client/crawler/scraper library for a certain website, hopefully my first nimble package. The site has some rate limiting which I haven't figure out exactly yet, but will try to do. Once I do, I want to have a request scheduler so that all requests (async) done to the website are a

Help with generics and typeclass problem

2023-05-21 Thread void09
You are right mratsim, it's the nim compiler that sigsegv.. which is obviously a bug, no doubt about it :) I will report it. Speaking of bugs and types, I almost forgot this little code snippet when I was trying to figure out concepts: Code behaves correctly

Help with generics and typeclass problem

2023-05-19 Thread void09
So I don't open another topic, I'd like to know if it's possible to use std/math ceilDiv inside a (generic) type definition, like here: this does not compile, even though const a = ceildiv(..) works, so ceildiv is good for compile time. If I write my own cei

Help with generics and typeclass problem

2023-05-17 Thread void09
mratsim that might be true in general, but I want to have user-pickable uint base type for the array/seq, so openArray[byte] won't do. Also I want to have max performance, and one extra proc call is not ideal.

Help with generics and typeclass problem

2023-05-16 Thread void09
type Units* = SomeUnsignedInt BitVecS*[S:static int, B:Units = uint] = object Base*: array[S div (sizeof(B) * 8) + int(S mod (sizeof(B) * 8) != 0), B] #8,16,32,64 BitVec*[B:Units] = object Base: seq[B] size: int AnyBitVec[S:static int, B:Units]

Question from a complete Newbie

2023-05-06 Thread void09
I tried your code and it works with both H and HH, and shows the correct result, according to the format: Don't see a problem, check your code again.

Optimise async request / code [For Beginners]

2023-04-26 Thread void09
As far as number of lines go, you can combine the creation of http client, request, and checking for content in one line. Also, although you made an async proc, you use waitFor in a for loop, for each future, which will make the program behave just like doing non async http requests, it will mak

What would be the bast way to get parsing and validation of parameters (option:value)

2023-01-11 Thread void09
Hm no, in this case I want to simply ensure the parameters that I get, from any external source, are valid in their context. They won't be used as parameters in a nim program, but to eventually execute an external binary. So cligen is not of any help. Araq's way, "default design procedural prog

What would be the bast way to get parsing and validation of parameters (option:value)

2023-01-10 Thread void09
Need to parse and validate user supplied parameters for video encoders, in the form of "\--option1:value --option2 --option3:value", which are unique for each encoder we have defined. option fields must be in a set of predefined such fields, while values have to be in a certain range for integer

Is flags={SocketFlag.Peek} buggy or am I missing something ?

2022-12-29 Thread void09
I have this code with asyncSocket on linux: while true: var msgSize = "" while msgSize.len == 0: try: msgSize = await asocket.recv(4, flags={SocketFlag.Peek}) await sleepAsync(200) except ... try: resp = await a

Looking for a pair programming partner / coach

2022-12-02 Thread void09
A coach is exactly what I have been hoping for ever since I restarted my programming hobby with nim (previously pascal). Have 3 awesome projects in mind, but currently working on a simple cli torrent client (and associated lib), which nim ecosystem is missing, and also a good scope for learning:

Any libraries for dictionary coding (compression) of array structures ?

2022-11-29 Thread void09
No, it's not at all the easiest way to go at it. I don't see what I can use from there, even conceptually. This is the barebones code I wrote for this - It has some shortcomings: The algorithm to generate it is probably not optimal, checking if each new entry

Any libraries for dictionary coding (compression) of array structures ?

2022-11-25 Thread void09
I have started my second project in nim, mostly for learning purposes, and in both I have encountered the need to save memory when storing sequential data with many repeating symbols. (storing unique/deduplicated value in a dictionary + an array w

Custom header values inside multi-part form ?

2022-09-05 Thread void09
Alright so constructing the http body by hand is not possible if you want to post a file, cause big files will take some time to load in memory, and eat that memory. I managed to implement a dirty hack in httpclient to insert my headers when building it. MultipartEntry* = object

Custom header values inside multi-part form ?

2022-09-04 Thread void09
A little update after getting the idea that I can easily debug with nc: curl "correct" request: --c6d4d41bf1581405 Content-Disposition: form-data; name="file"; filename="1.txt" Content-Type: text/plain Abspath: /home/sgm/1.txt 123

Custom header values inside multi-part form ?

2022-09-03 Thread void09
Trying to implement a few IPFS API calls, specifically this one: Basically I need to implement the "nocopy" option of the above linked API call, which in curl looks like this: curl '' -F 'file

How to draw images on collectionView elements (rects), with nimx ?

2022-08-19 Thread void09
I need help, issue described here: The documentation is too slim and I have no experience with guis at all. Please assist.

Wave: illegal capture ' ' because 'weaveParallelForSection' has the calling convention:

2022-08-16 Thread void09
Thank you for the comprehensive response ! I had wrongly assumed that the explicit capture is not needed because the code worked without it, if put outside proc. But since it didn't work with code in the proc, I should have thought something needs to be done different. The workflow here is simp

Wave: illegal capture ' ' because 'weaveParallelForSection' has the calling convention:

2022-08-16 Thread void09
Title should be "Weave: ". Reposting for readibility: So I have this piece of code that errors with: : illegal capture 'idsBuf' because 'weaveParallelForSection' has the calling convention: The same code runs fine if not in a proc. Don't know much about weave, read only so much as to put this

Wave: illegal capture ' ' because 'weaveParallelForSection' has the calling convention:

2022-08-15 Thread void09
So I have this piece of code that errors with: : illegal capture 'idsBuf' because 'weaveParallelForSection' has the calling convention: The same code runs fine if not in a proc. Don't know much about weave, read only so much as to put this together. I canno

How to get just the first N bytes with httpclient ?

2022-08-06 Thread void09
I also got this solution from someone in the community: Not sure which one is "better"

How to get just the first N bytes with httpclient ?

2022-08-04 Thread void09
I'd like a confirmation if that's really true or not. If so, my question changes to just "How to get the first N bytes.."

How to get just the first N bytes with httpclient ?

2022-08-02 Thread void09
How to get just the first N bytes with http(async?)client for a server that does not support range requests ? I did not find any obvious way to do it with httpclient methods. I'm thinking something like httpAsyncClient that closes the connection when the stream is > N bytes, with 0ms poll, but I