<< 22-06-2023 >>

00:02:41FromDiscord<millymox> In reply to @elegantbeef "`let result = result.strip`": says it still cant open for me
00:02:42FromDiscord<millymox> hm
00:03:11FromDiscord<millymox> sent a code paste, see https://play.nim-lang.org/#ix=4yMP
00:03:24FromDiscord<millymox> might just use external python code
00:03:29FromDiscord<millymox> use tkinter for now
00:04:01FromDiscord<elegantbeef> Jesus
00:04:46FromDiscord<elegantbeef> Yea that code works fine for me, are you sure you're not getting spurious characters?
00:05:12FromDiscord<elegantbeef> sent a code paste, see https://play.nim-lang.org/#ix=4yMQ
00:06:12FromDiscord<elegantbeef> Given that you're using zenity I'd suggest owlkettle
00:06:21FromDiscord<elegantbeef> It's a nice declarative Nim gui that does have a file dialog
00:06:41FromDiscord<elegantbeef> Though there is https://github.com/Patitotective/tinydialogs/tree/main
00:30:04FromDiscord<millymox> In reply to @elegantbeef "Yea that code works": interesting, im on macos, perhaps thats the issue?
00:35:04FromDiscord<elegantbeef> Perhaps
00:35:05FromDiscord<millymox> In reply to @elegantbeef "Yea that code works": the file has spaces in it, thats about it
00:35:09FromDiscord<millymox> shouldn't be an issue though
00:35:38FromDiscord<elegantbeef> You could do `echo result.toOpenArrayByte(0, result.len)`
00:35:46FromDiscord<elegantbeef> then ensure there are no odd characters
00:37:04FromDiscord<elegantbeef> `result.high`
00:37:44FromDiscord<millymox> still doesn't work
00:37:44FromDiscord<millymox> hm
00:38:01FromDiscord<elegantbeef> Well it's not going to make it work it's to ensure there are no wrong characters
00:38:14FromDiscord<elegantbeef> Well it's going to show you if there are no wrong characters
00:38:26FromDiscord<millymox> ah well yeah, even extrenal python code doens't work. Is there something wrong with open() on macos?
00:38:34FromDiscord<elegantbeef> Perhaps
00:38:35FromDiscord<millymox> i can't even open a txt called hey.txt
00:38:38FromDiscord<millymox> no spaces
00:38:52FromDiscord<elegantbeef> Perhaps it's a locale issue? I don't really know
00:39:12FromDiscord<elegantbeef> Do you not have permissions for the file you're attempting to open?
00:39:28FromDiscord<millymox> i should have permissions, its in download folder, perhaps try sudo?
00:41:35FromDiscord<millymox> escalating perms to sudo does not work
00:42:35FromDiscord<elegantbeef> so does `zenity` return an incorrect string?
00:42:43FromDiscord<elegantbeef> Might have some non printed characters
00:43:04FromDiscord<elegantbeef> oh wait you said you just did `open("test.txt")`?
00:43:44FromDiscord<millymox> hey.txt. It seems to be maybe an issue weith directory paths?? cuz i can do it if its in my directory bhut anything outside its a no
00:44:26FromDiscord<elegantbeef> This sounds a lot like some permission issue, but given you used sudo it's quite odd
00:44:49FromDiscord<millymox> yes i did sudo ./main
01:04:23FromDiscord<millymox> how to go about threacding in nim?
01:24:04FromDiscord<michaelb.eth> In reply to @millymox "how to go about": it depends on what you're trying to do, can be a pain-point with Nim
01:25:18FromDiscord<michaelb.eth> if you look back through the `#internals` channel on this discord you'll see there's been a lot of discussion in recent weeks+
01:25:29FromDiscord<michaelb.eth> related to multi-threading, I mean
01:59:29FromDiscord<millymox> sent a code paste, see https://play.nim-lang.org/#ix=4yN1
01:59:31FromDiscord<millymox> the second part of my code is not being reached
01:59:44FromDiscord<millymox> sent a code paste, see https://play.nim-lang.org/#ix=4yN2
01:59:48FromDiscord<millymox> echo checking never gets outputted
02:00:31FromDiscord<huantian> You might consider using async instead of threading if your task is io bound like http requests
02:00:34FromDiscord<elegantbeef> You don't return anything i read proxies
02:00:49FromDiscord<millymox> In reply to @huantian "You might consider using": example?
02:01:12FromDiscord<elegantbeef> implicit result
02:01:13FromDiscord<elegantbeef> sent a code paste, see https://paste.rs/FfIAg
02:01:21FromDiscord<elegantbeef> That's a much more idiomatic version and closes teh file handle
02:01:53FromDiscord<michaelb.eth> implicit result 😱
02:01:59FromDiscord<michaelb.eth> 🙀 even
02:02:07FromDiscord<elegantbeef> Yea people that don't work at status use them
02:02:15FromDiscord<michaelb.eth> anyway, mummy might be worth a look: https://github.com/guzba/mummy
02:02:22FromDiscord<michaelb.eth> for @millymox I mean
02:03:18FromDiscord<millymox> In reply to @michaelb.eth "anyway, mummy might be": can i send requests with it
02:03:21FromDiscord<millymox> or just routes?
02:03:58FromDiscord<michaelb.eth> I'm not sure, haven't used it myself, I just recall that the author had/has a focus on making it work well re: how threading works in Nim
02:05:06FromDiscord<millymox> In reply to @michaelb.eth "I'm not sure, haven't": ask far as i can see its just a library for handeling req, like backend stuff
02:05:10FromDiscord<millymox> ill take a look at the code though
02:05:17FromDiscord<elegantbeef> It's for backend
02:05:20FromDiscord<michaelb.eth> you want proxy middleware, that kind of thing?
02:05:37FromDiscord<michaelb.eth> ah yeah, duh, I see proxy in your code above
02:05:53FromDiscord<millymox> i just want a http library that isn't the standard library that supports proxies
02:06:23FromDiscord<elegantbeef> Why not the stdlib?
02:06:57FromDiscord<millymox> In reply to @elegantbeef "Nim has an implicit": Thank you but how do i return the proxies so i can use them?
02:09:08FromDiscord<millymox> its okay got it
02:10:50FromDiscord<elegantbeef> What do you mean how do you return them, it r eturns them
02:11:38FromDiscord<millymox> its why i said its okay i was being stupid
02:16:34FromDiscord<millymox> In reply to @elegantbeef "Why not the stdlib?": nothing im just in a shit mood lmao
02:16:49FromDiscord<millymox> Im loving nim so far though
02:19:39*oldpcuser quit (Remote host closed the connection)
02:20:25*oldpcuser joined #nim
02:21:00*oldpcuser quit (Remote host closed the connection)
02:21:26*oldpcuser joined #nim
02:24:04FromDiscord<millymox> sent a code paste, see https://play.nim-lang.org/#ix=4yN7
02:39:33FromDiscord<elegantbeef> You arent closing the client
02:39:39FromDiscord<elegantbeef> defer: client.close()
02:40:25FromDiscord<millymox> In reply to @elegantbeef "defer: client.close()": where am i too place this?
02:40:33FromDiscord<elegantbeef> After opening the client
02:40:41FromDiscord<elegantbeef> Like i showed with the file
02:40:44FromDiscord<millymox> https://media.discordapp.net/attachments/371759389889003532/1121268505673732186/Screenshot_2023-06-21_at_8.40.40_PM.png
02:40:58FromDiscord<millymox> i get the same error: Bad file descriptor
02:42:00FromDiscord<elegantbeef> Also you're using threads for no reason, this is an async problem
02:42:19FromDiscord<elegantbeef> How many proxies do you have, could be hiting a file descriptor limit
02:42:43FromDiscord<millymox> In reply to @elegantbeef "How many proxies do": 11k proxies
02:42:49FromDiscord<millymox> 11,000
02:47:50FromDiscord<elegantbeef> Yea you likely need to do fewer at once
02:50:39FromDiscord<michaelb.eth> I'd suggest trying it with chronos on a single thread
02:50:54FromDiscord<elegantbeef> any async solution 😄
02:50:59FromDiscord<elegantbeef> or CPS
02:51:09FromDiscord<michaelb.eth> the event loop may get bottled up, but you won't know until you try
02:51:18FromDiscord<michaelb.eth> (edit) "bottled" => "backed"
02:51:25FromDiscord<elegantbeef> I assume you'd still need to chunk it
02:51:30FromDiscord<millymox> In reply to @michaelb.eth "I'd suggest trying it": link?
02:51:34FromDiscord<huantian> Make like a queue system
02:51:35FromDiscord<millymox> to chrons
02:51:37FromDiscord<elegantbeef> 11k requests + async is likely to eat descriptions
02:51:39FromDiscord<millymox> chronoes
02:51:46FromDiscord<huantian> Or do what did and use callbacks in a omega jank way
02:52:10FromDiscord<michaelb.eth> https://github.com/status-im/nim-chronos↵you want apps/httpclient↵https://github.com/status-im/nim-chronos/tree/master/chronos/apps/http
02:52:22FromDiscord<michaelb.eth> (edit) "apps/httpclient↵https://github.com/status-im/nim-chronos/tree/master/chronos/apps/http" => "apps/http/httpclient, I think↵https://github.com/status-im/nim-chronos/tree/master/chronos/apps/http"
02:53:16FromDiscord<michaelb.eth> just note that chronos event loop and std/asyncdispatch event loop can't run in the same thread, i.e. don't try to mix and match chronos stuff with std/asyncdispatch stuff
02:53:53FromDiscord<millymox> okay thank you
02:55:07FromDiscord<huantian> Is there a reason to use chronos over stdlib async client
02:55:16FromDiscord<elegantbeef> Not really unless you care about cycles
02:55:21FromDiscord<elegantbeef> It also uses bearssl
02:55:25FromDiscord<elegantbeef> chronos that is
02:55:43FromDiscord<elegantbeef> Statically linked makes it easy to ship on winblows
02:55:54FromDiscord<michaelb.eth> In reply to @huantian "Is there a reason": well, chronos is being used in production at scale with a lot of $$ on the line, can the same be said of std/asyncdispatch?
02:56:17FromDiscord<elegantbeef> That's a pointless argument for "why"
02:56:23FromDiscord<michaelb.eth> not that that proves anything, just that it's an indicator that it's solid if it's being used correctly
02:59:04*pbsds quit (Quit: The Lounge - https://thelounge.chat)
02:59:38*pbsds joined #nim
03:22:25FromDiscord<michaelb.eth> eh, actually, malebolgia has a "crawler" test/example, maybe could work for you if you're okay using build of Nim's `devel` branch: https://github.com/Araq/malebolgia/blob/master/tests/tcrawler.nim
03:23:02FromDiscord<michaelb.eth> no async stuff, just malebolgia's approach to coordinating multi-threaded stuff
03:23:10FromDiscord<michaelb.eth> (edit) "multi-threaded stuff" => "multiple threads"
03:23:27FromDiscord<michaelb.eth> whoops, wrong chat context:D
03:57:26NimEventerNew thread by dwhall256: Nim merch, see https://forum.nim-lang.org/t/10291
04:10:52termerHow can I create a ref type for an array literal?
04:10:55termerI can't figure it out
04:25:42FromDiscord<elegantbeef> write a `proc new[T](val: sink T): ref T = new result; result[] = val`
05:18:21*ntat joined #nim
05:29:06*rockcavera quit (Remote host closed the connection)
05:35:56termeroh right
05:36:56*azimut quit (Ping timeout: 240 seconds)
06:07:17FromDiscord<acek7> Whats up everyone
06:21:37*PMunch joined #nim
06:39:27FromDiscord<huantian> Hello gamers
07:17:38termergood morning gamers
08:09:23FromDiscord<gogolxdong666> Anyone list nimbus in this comparing https://media.discordapp.net/attachments/371759389889003532/1121351210721611807/6622b625c34232f710156dbd39a757cc_.jpg
08:13:57*beholders_eye joined #nim
08:36:48*oldpcuser_ joined #nim
08:38:59*oldpcuser quit (Ping timeout: 240 seconds)
08:45:33FromDiscord<mratsim> In reply to @gogolxdong666 "Anyone list nimbus in": Thisbis a comparison of execution clients, Nimbus-eth1 (execution client) is not ready for prime time.↵↵Nimbus-eth2 (consensus client) is
09:07:30*oldpcuser_ quit (Ping timeout: 240 seconds)
09:33:31FromDiscord<fabricio> so I'm still a bit confused about the copying semantics in Nim for strings and seqs. if I pass a string/seq to a function as a value but I don't mutate it inside the function, will thedata be duplicated and a new string/seq will be created to be passed, or same data will the be reused
09:41:08FromDiscord<graveflo> looks like it doesn't copy when I try it
09:53:38PMunchfabricio, Nim is smart enough to know that if you pass a seq to a procedure which isn't allowed to mutate it it will be safe to do so by pointer. So under the hood it passes a pointer in
10:17:24FromDiscord<heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4yOd
10:17:58FromDiscord<heysokam> (edit) "https://play.nim-lang.org/#ix=4yOd" => "https://paste.rs/rxUSb"
10:22:30FromDiscord<heysokam> @demotomohiro know anything about this? ^↵i'm reading your guide on it, but it seems like the .py script is missing in my system 🤔
10:23:50FromDiscord<intellj_gamer> Are you using devel? The gdb script was recently moved↵Maybe choosenim hasn't updated that 🤔
10:24:17FromDiscord<heysokam> 1.6.12
10:24:28FromDiscord<intellj_gamer> oh weird,↵You could download this file and put it there https://github.com/nim-lang/Nim/blob/devel/tools/debug/nim-gdb.py
10:25:05FromDiscord<heysokam> thats very useful, ty!
10:44:24FromDiscord<heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4yOB
10:45:20FromDiscord<heysokam> (edit) "https://play.nim-lang.org/#ix=4yOB" => "https://play.nim-lang.org/#ix=4yOC"
10:53:59FromDiscord<heysokam> is there a better way to debug nim code than this?↵i cannot even find the variables i need to search for 😔
11:08:42FromDiscord<demotomohiro> In reply to @heysokam "well, maybe not. i": Did you ru nim-gdb or load nim-gdb.py with `source Nim/tools/debug/nim-gdb.py`?
11:09:01FromDiscord<heysokam> nim-gdb
11:09:41FromDiscord<heysokam> seems like the nim-gdb binary was in my system, but not the script
11:11:35FromDiscord<demotomohiro> If you set a value to a variable but didn't use it, Nim might remove that variable and you cannot find it on debugger.
11:12:11FromDiscord<heysokam> i tried with `break myfile.nim:num` and it didnt' find the file
11:12:34FromDiscord<heysokam> didn't even try setting a variable name, since i don't know exactly the variable name im looking for (or else i wouldn't need the debugger)
11:13:00FromDiscord<heysokam> usually, in C, i step through it close enough so that i can find where im going or how to stop it close enough
11:13:21FromDiscord<heysokam> but here i cannot find anything, because its all mangled 😦↵thought that the nim-gdb thing would help with that
11:13:34FromDiscord<odexine> Did you compile with debugger symbiks
11:13:37FromDiscord<odexine> Symbols
11:13:40FromDiscord<heysokam> of course
11:13:48FromDiscord<odexine> How did you do so exactly
11:13:51FromDiscord<demotomohiro> `--debugger:native`
11:14:12FromDiscord<heysokam> i believe i had that by default, but let me recheck in case i didn't
11:14:30FromDiscord<odexine> Nim doesn’t do that by default so I assume you mean you put it in a config file
11:14:45FromDiscord<heysokam> yeah i do it in my config
11:14:56FromDiscord<heysokam> it was commented out though ⚰️
11:17:19FromDiscord<heysokam> oh i can see the code now! ty, that was me being a dummy 🙏
11:45:20FromDiscord<fabricio> In reply to @PMunch "<@607600292086939696>, Nim is smart": okay but what if a function takes a large object as param by value that doesn't get mutated and I have a ref or a ptr to one of those objects. if I dereference that ptr/ref so I can pass it as a value to the function, will the compiler be smart enough to not do the deref and pass the ptr/ref directly under the hood
11:46:32PMunchThat's an interesting question, but I believe it should still pass that by reference (a pointer)
12:05:47FromDiscord<demotomohiro> In reply to @fabricio "okay but what if": If you care that, you can read generated C code in Nim cache directory.
12:06:10FromDiscord<jmgomez> Also `bycopy` and `byref` exists
12:16:04FromDiscord<fabricio> In reply to @jmgomez "Also `bycopy` and `byref`": oh cool didn't know that thanks
12:22:07FromDiscord<demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4yOP
12:23:54FromDiscord<jmgomez> demo, if you do `exportc` it will be easier to follow as it doesnt mangle
12:23:59FromDiscord<demotomohiro> You don't need to use `bycopy` or `byref` pragma unless you are calling C/C++ functions.↵Nim passes arguments optimal way and you don't need to optimize them yourself.
12:28:20FromDiscord<demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4yOR
12:29:28FromDiscord<demotomohiro> Anyway, there is no code that copy `BigObj`.
12:33:27FromDiscord<jmgomez> The type can also have it 😛
12:34:19FromDiscord<jmgomez> Yeah, IIRC `array[24, byte]` would be copied but `array[25, byte]` wouldnt
12:34:27FromDiscord<jmgomez> (in most platforms)
12:34:52PMunchThe magic size is 3*sizeof(float) IIRC
12:35:00FromDiscord<jmgomez> exactly
12:51:46PMunchHmm, I'm getting false for fileExists on files that definitely exists
12:53:21FromDiscord<demotomohiro> Maybe it doesn't have permission to access the file or parent directly?
12:53:52PMunchAh, never mind..
12:54:13PMunchI was pulling stuff from environment variables, and I had set them as strings in quotes..
12:54:21PMunchSo it wasn't looking for myfile it was looking for "myfile"
13:24:58*rockcavera joined #nim
13:34:22*beholders_eye quit (Ping timeout: 245 seconds)
13:53:41*beholders_eye joined #nim
14:08:21*PMunch quit (Quit: Leaving)
14:28:24FromDiscord<heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4yPn
14:55:52*azimut joined #nim
15:03:24FromDiscord<Andreas> i have smth very disturbing here : https://play.nim-lang.org/#ix=4yPw↵When run with `nim -d:useMalloc` the locations 4..6 get scambled ? When rin with `nim r` everything is fine ?
15:03:37FromDiscord<Andreas> (edit) "rin" => "run"
15:06:39FromDiscord<arnetheduck> In reply to @Andreas "i have smth very": switch to `allocShared` - `createShared(T, n)` = `malloc(sizeof(T)n)` and `sizeof(T) == 0` in your example
15:08:32*beholders_eye quit (Ping timeout: 240 seconds)
15:11:02*beholders_eye joined #nim
15:11:12FromDiscord<Andreas> In reply to @arnetheduck "switch to `allocShared` -": thx, that helps
15:19:46*rockcavera quit (Remote host closed the connection)
15:23:17*beholders_eye quit (Quit: WeeChat 3.6)
15:34:46arkanoidwhat is a c++ class from importcpp standpoint? an object type?
15:36:33FromDiscord<fabricio> In reply to @demotomohiro "Here is example code:": it is calling it with `(&(x)), x`, which answers my question that nim doesn't skip the dereference and pass the pointer directly, it is copying and passing the pointer of the copy
15:41:22FromDiscord<mratsim> In reply to @fabricio "it is calling it": hat should be optimized away by tghe C compiler
15:41:32FromDiscord<mratsim> (edit) "hat" => "that" | "tghe" => "the"
15:44:30FromDiscord<demotomohiro> In reply to @fabricio "it is calling it": `x` dereference the pointer but doesn't mean copy it.
15:48:58FromDiscord<ieltan> Probably a dumbass question:↵Are circular references "recursive" ? I have a case where I have T1 which is a ref type that has a field which is a table of T2 where T2 is a ref type that has a field which is T1
15:49:14FromDiscord<ieltan> That was a mouthful...
15:55:06FromDiscord<demotomohiro> sent a code paste, see https://paste.rs/zKw2x
15:55:22FromDiscord<demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4yPP
15:57:38FromDiscord<demotomohiro> So `var x` become rax on assembly code, `testProcCallee` is inlined inside `testProcCallee`.↵rax is just copied to rbx and rdi and stringified with `dollar_testproc_106`.
15:58:42FromDiscord<odexine> In reply to @ieltan "Probably a dumbass question:": what does recursive mean here
15:59:26FromDiscord<demotomohiro> https://en.wikipedia.org/wiki/X86_calling_conventions#System_V_AMD64_ABI↵In System V AMD64 ABI calling convention, Integer/Pointers are passed with register "RDI, RSI, RDX, RCX, R8, R9".
16:01:53FromDiscord<demotomohiro> In reply to @ieltan "Probably a dumbass question:": I think that can create circular references and `--mm:arc` doesn't work and you need `--mm:orc`.
16:02:29FromDiscord<ieltan> In reply to @odexine "what does recursive mean": Sorry it's the wrong word I think I figured it out
16:02:49FromDiscord<ieltan> In reply to @demotomohiro "I think that can": Yeah my bad sorry I got it now
16:06:17*rockcavera joined #nim
16:09:23FromDiscord<millymox> sent a code paste, see https://play.nim-lang.org/#ix=4yPV
16:09:39FromDiscord<odexine> nim does not have classes inbuilt
16:10:05FromDiscord<millymox> okay so what is the alternative?
16:10:12FromDiscord<millymox> what is the equivelent
16:10:21FromDiscord<odexine> discord crashed while i was typing
16:10:33FromDiscord<odexine> you need to install a 3rd party library like `classes`
16:10:35FromDiscord<millymox> oh lmao
16:10:43FromDiscord<millymox> nimble install classes?
16:11:27FromDiscord<millymox> oh my just took a look at it
16:11:31FromDiscord<millymox> thanks so much
16:11:31FromDiscord<millymox> lmao
16:11:43FromDiscord<jmgomez> but likely you wont need it
16:12:45FromDiscord<jmgomez> Nim has UFCS meaning the first argument can be treated as `self`
16:15:15FromDiscord<fabricio> In reply to @demotomohiro "Generated assembly code for": it's not really about the assembly, more about for the C codegen, trying to see if the nim compiler is smart enough to do what I asked, `x` is dereference and maybe it gets optimized by the C compiler, I was trying to see if the nim compiler would pass it directly as `x`, anyway thanks, I appreciate the effort
16:20:35FromDiscord<demotomohiro> In reply to @millymox "oh lmao": Nimmers just define object or ref object types and define procedures that take it as first parameter.
16:24:13FromDiscord<demotomohiro> sent a code paste, see https://play.nim-lang.org/#ix=4yPZ
16:24:54FromDiscord<millymox> In reply to @demotomohiro "Nimmers just define object": Thanks!
16:24:58FromDiscord<millymox> Yes im doing this
16:25:04FromDiscord<millymox> In reply to @jmgomez "Nim has UFCS meaning": I see okay okay
16:30:33*azimut quit (Remote host closed the connection)
16:30:36FromDiscord<odexine> most of us dont use the word "self" since theyre not bound to classes (it gets confusing real quick)
16:30:43FromDiscord<millymox> how do i add a json body to a req? using std lib
16:30:45FromDiscord<odexine> we use lowercased class name
16:31:00FromDiscord<millymox> In reply to @odexine "most of us dont": Ahhh
16:31:28FromDiscord<odexine> In reply to @millymox "how do i add": json body in what format? json module? make it a string with the $ proc `$theJson` and send that
16:32:19*azimut joined #nim
16:32:21*jmdaemon joined #nim
16:32:46FromDiscord<millymox> sent a code paste, see https://play.nim-lang.org/#ix=4yQ3
16:33:42FromDiscord<odexine> postContent 3rd argument is of type `string` so just put the json as a string, i am not sure what library you are using for json
16:34:33FromDiscord<millymox> In reply to @odexine "postContent 3rd argument is": i am not using a library for json i didn't know i needed one, completely new to this so i apologize for my ignorance
16:35:19FromDiscord<millymox> what library do you reccomend?
16:35:21FromDiscord<odexine> well some need one some dont, if you just want to simply send the json "{"api_key": "key"}" as is without needing to manipulate it you can always manually construct the string like this↵`"{\"api_key\": \"key\"}"`
16:36:01FromDiscord<odexine> you will want to set the headers `client.headers = newHttpHeaders({ "Content-Type": "application/json" })`
16:36:10FromDiscord<odexine> before sending the post
16:36:30FromDiscord<millymox> Thank you so much okay i got it!
16:38:45FromDiscord<millymox> In reply to @odexine "well some need one": {"balance":4.7868,"errorId":0,"errorCode":null,"errorDescription":null}↵↵how would i go about parsing the balance of this response?
16:39:00FromDiscord<odexine> okay so this is where the json library comes in
16:39:11FromDiscord<millymox> okay okay what do you suggest
16:39:18FromDiscord<odexine> https://nim-lang.org/docs/json.html is the basic standard library json library
16:39:28FromDiscord<odexine> there are others but i think for now you should start with this
16:39:39FromDiscord<odexine> see the docs for more information
16:39:46FromDiscord<odexine> it shouldnt be too difficult
16:41:24FromDiscord<millymox> awesome thank you taking a look right now
16:44:24FromDiscord<millymox> sent a long message, see http://ix.io/4yQ5
16:44:40FromDiscord<odexine> what are you trying to do?
16:44:45FromDiscord<odexine> like what is it you want to do
16:44:55FromDiscord<millymox> get the "balance" and assign it to a variable and echo it
16:45:11FromDiscord<millymox> get the value of the key balance and assign it to the balance variable and then echo balance
16:46:34FromDiscord<odexine> `let balance = jsonNode["balance"]` doesnt have the echo part, and this gives you a json node (you have to convert it to the appropriate primitive type like integer or string)
16:47:17FromDiscord<odexine> with the conversion `let balance = jsonNode["balance"].getFloat`
16:48:38FromDiscord<millymox> In reply to @odexine "with the conversion `let": Thank you this works, i appreciate the help
16:49:27FromDiscord<millymox> i see for some reason an unnecessary new line, anyway to get rid of this? https://media.discordapp.net/attachments/371759389889003532/1121482091473940570/Screenshot_2023-06-22_at_10.49.22_AM.png
16:51:47FromDiscord<michaelb.eth> In reply to @millymox "awesome thank you taking": there's also jsony: https://github.com/treeform/jsony↵↵as Rika said, std/json is a good place to start and figure things out; later, if you have a perf issue processions thousands of json concurrently (recalling from last night you're processing 10k+ requests or something like that), you can try switching to json for a perf boost
16:52:26FromDiscord<millymox> In reply to @michaelb.eth "there's also jsony: https://github.com/treeform/jso": Okay great thank you, i have to ask: who is treeform? I see a lot of things made by him, is this a company, or person or?
16:52:30FromDiscord<heysokam> In reply to @millymox "how do i assign": `assert condition, message` means:↵> hey computer, make sure that this condition im giving you is true, but fail and output the message when its false. also, ignore it in release mode`↵`doAssert condition, message` means the same, but it will be done even in release mode
16:52:46FromDiscord<heysokam> (edit) "In reply to @millymox "how do i assign": `assert condition, message` means:↵> hey computer, make sure that this condition im giving you is true, but fail and ... output" added "crash the application and"
16:53:17FromDiscord<michaelb.eth> In reply to @millymox "Okay great thank you,": just another Nim coder as far as I know
16:53:31FromDiscord<millymox> In reply to @heysokam "`assert condition, message` means:": can you give me an example? With numbers maybe so i can better visualize
16:53:38FromDiscord<millymox> In reply to @michaelb.eth "just another Nim coder": ahh okay
16:55:08FromDiscord<heysokam> In reply to @millymox "can you give me": search assert in here. there are a million and one examples all around the code examples for each section:↵https://nim-lang.org/docs/manual.html
16:55:09FromDiscord<millymox> sent a code paste, see https://play.nim-lang.org/#ix=4yQc
16:55:22FromDiscord<heysokam> In reply to @millymox "so like you can": yeah
16:55:41FromDiscord<heysokam> the condition is just any boolean you want
16:55:54FromDiscord<heysokam> In reply to @millymox "so like you can": well, actually, no thats not valid
16:55:59FromDiscord<heysokam> 4 + asdfasdf is not a boolean
16:56:23FromDiscord<heysokam> `doAssert 4+asdfwerlkjadf > 1, "failed"` would be a boolean
16:56:56FromDiscord<heysokam> `doAssert true, "failed"` is also valid code, that will of course never trigger
16:57:34FromDiscord<heysokam> (edit) ">" => "=="
17:00:40FromDiscord<millymox> Ahhhh okay i get it now
17:01:35FromDiscord<millymox> how to concatenate variables?↵↵ let res = req.post("https://api.capmonster.cloud/getBalance", "{\"clientKey\": \"{api_key}\"}")
17:01:40FromDiscord<millymox> let api_key = client.api_key
17:03:20FromDiscord<k0ts> if you want interpolation try strformat: https://nim-lang.org/docs/strformat.html
17:03:33FromDiscord<spotlightkid> You can watch some of his presentations from past Nim online conferences on the Nim YouTube channel.↵(@millymox)
17:19:49FromDiscord<heysokam> sent a code paste, see https://play.nim-lang.org/#ix=4yQh
17:20:07FromDiscord<Phil> Generally when it comes to strings I highly recommend strformat. It's equivalent to what f-strings are in python and template-strings in JS. I really like this kind of string interpolation.↵You can use either `&` or `fmt` (if & seems to cryptic)
17:20:15FromDiscord<Phil> (edit) "to" => "too"
17:20:41FromDiscord<heysokam> if you have two strings, you just do `string1 & string2`
17:31:14FromDiscord<voidwalker> https://github.com/nim-lang/Nim/blob/d137a3b52af1a83cd9617e47b63d7b3d6c4d935b/lib/pure/httpclient.nim#L1066 - can anyone explain where the user-agent header is set if not here ?
17:31:46FromDiscord<voidwalker> because I don't understand why it's lowercase in the request itself : `user-agent:`
17:31:50FromDiscord<Zoom> Don't forget there's also `&=`/`add` for in-place append to `var string`
17:39:00FromDiscord<voidwalker> same thing for `content-length`. maybe there's something that makes them lowercase?
17:42:22FromDiscord<odexine> yes
17:42:28FromDiscord<odexine> nim lowercases all headers
17:42:40FromDiscord<odexine> it is in http spec that headers are case insensitive
17:44:00FromDiscord<millymox> how to use strfomat for something like this?↵↵HcaptchaTaskProxyless
17:44:05FromDiscord<millymox> {{"clientKey": "{}", "task": {{"type":"HcaptchaTaskProxyless","websiteURL":"{}","websiteKey":"{}"}}}}
17:44:41FromDiscord<millymox> let payloadStr = "{\"clientKey\": \"{}\", \"task\": {\"type\":\"HcaptchaTaskProxyless\",\"websiteURL\":\"{}\",\"websiteKey\":\"{}\"}}"
17:49:00FromDiscord<Phil> What are the parts you want to have placeholder in?
17:53:17FromDiscord<ricky> In reply to @odexine "it is in http": that spec is cursed\r\n\r\n
17:56:35FromDiscord<odexine> In reply to @.rictus "that spec is cursed\r\n\r\n": yeah, but oh well
17:56:38FromDiscord<odexine> what can we do about it
17:57:22FromDiscord<demotomohiro> `strformat.fmt` allows to use ``openChar`` instead of '{' and ``closeChar`` instead of '}':↵https://nim-lang.org/docs/strformat.html#fmt.m%2Cstaticstring%2Cstaticchar%2Cstaticchar
17:59:44*rockcavera quit (Remote host closed the connection)
18:00:18FromDiscord<voidwalker> In reply to @odexine "nim lowercases all headers": where does this happen please ? I know they're case insensitive, but for some purposes this might matter (like fingerprinting)
18:00:34FromDiscord<voidwalker> I wanna pretend i'm wget, but I give wrongly cased headers, busted
18:03:01FromDiscord<jmgomez> sent a code paste, see https://play.nim-lang.org/#ix=4yQq
18:13:15FromDiscord<odexine> @voidwalker https://github.com/nim-lang/Nim/blob/version-1-6/lib/pure/httpcore.nim#L139
18:13:25*rockcavera joined #nim
18:13:27FromDiscord<odexine> you can set it to not
18:13:27FromDiscord<voidwalker> oh I was looking in the wrong file, thanks
18:13:49FromDiscord<odexine> well, "not"
18:13:52FromDiscord<voidwalker> btw, is there any way to order the http headers ?
18:14:08FromDiscord<odexine> In reply to @odexine "well, "not"": it wont keep the original format but it will title case it
18:14:15FromDiscord<odexine> In reply to @voidwalker "btw, is there any": not with httpcore
18:14:18FromDiscord<odexine> that info is lost
18:14:24FromDiscord<odexine> it uses a table after all
18:15:00FromDiscord<odexine> if you want to act exactly like wget its likely best to bind wget instead of acting
18:19:23FromDiscord<voidwalker> so it should use an ordered table to keep that info ?
18:23:40*oldpcuser joined #nim
18:26:33FromDiscord<odexine> you can patch the file with a custom version https://nim-lang.org/docs/nimscript.html#patchFile%2Cstring%2Cstring%2Cstring
18:26:40FromDiscord<odexine> In reply to @voidwalker "so it should use": you could do that yeah
18:30:59*oldpcuser quit (Ping timeout: 240 seconds)
18:36:39*jmdaemon quit (Ping timeout: 250 seconds)
18:42:18FromDiscord<JJ> why is `type A = object[x: int]` not supported?
18:42:31*jmdaemon joined #nim
18:44:30FromDiscord<Andreas> sent a code paste, see https://play.nim-lang.org/#ix=4yQF
18:46:36FromDiscord<odexine> i dont think theres a reason other than "araq thought not to support it"?
18:46:59*jmdaemon quit (Ping timeout: 246 seconds)
18:48:44FromDiscord<jmgomez> In reply to @omentic "why is `type A": What would differ from `type A[x: int] = object` ?
18:49:24FromDiscord<odexine> In reply to @jmgomez "What would differ from": i think it is meant to emulate how tuples can be defined
18:49:30FromDiscord<odexine> where the runtime fields go in []
18:50:19FromDiscord<JJ> yeah, pretty much
18:50:37FromDiscord<jmgomez> hmm what about ↵` RuntimeStruct = seq[(string, RuntimeField)]`
18:50:58FromDiscord<jmgomez> (without `string` if you dont want named pairs)
18:50:58FromDiscord<JJ> thinking about this wrt. the adts proposal basically. named tuples are good enough though
18:55:03FromDiscord<odexine> In reply to @jmgomez "hmm what about ": i mean runtime value fields, not runtime defined field
18:55:04FromDiscord<odexine> (edit) "field" => "fields"
19:43:26*oldpcuser joined #nim
20:33:10*xet7 quit (Ping timeout: 265 seconds)
20:46:09*Guest99 joined #nim
21:03:14FromDiscord<bostonboston> Is there a nice way to turn an enum into a list of strings, assuming the enum has holes
21:03:27FromDiscord<bostonboston> I want the strings to be the names not the values
21:07:07*xet7 joined #nim
21:07:38NimEventerNew thread by przemyslawo: Does Nim has the same features that D has when interfacing to Objective-C?, see https://forum.nim-lang.org/t/10292
21:11:05FromDiscord<Elegantbeef> Not really a Macro is pretty much the only way↵(@bostonboston)
21:11:21FromDiscord<bostonboston> Figured
21:12:01FromDiscord<Elegantbeef> There is `items` defined inside enumutils but it doesnt always work
21:12:26FromDiscord<millymox> In reply to @jmgomez "@mox you likely want": what library does this use?
21:12:38FromDiscord<Elegantbeef> `std/strutils`
21:12:40FromDiscord<Elegantbeef> whoops
21:12:43FromDiscord<Elegantbeef> `std/json`
21:12:51FromDiscord<Elegantbeef> `std/jsonutils`
21:13:16FromDiscord<millymox> attempting to call undeclared routine: 'jsonTo'↵expression '' has no type (or is ambiguous)
21:13:21FromDiscord<millymox> var foo = jsonStr.parseJson.jsonTo(Foo)
21:13:28FromDiscord<Elegantbeef> `impor std/[json, jsonutils]`
21:13:39FromDiscord<huantian> that's a lot of libraries beef
21:13:48FromDiscord<Elegantbeef> Yep
21:14:23FromDiscord<Elegantbeef> Atleast 2
21:16:08FromDiscord<millymox> sent a long message, see http://ix.io/4yR3
21:16:25FromDiscord<Elegantbeef> Make a typedef for your `task`
21:16:27*Guest99 quit (Quit: Client closed)
21:16:41FromDiscord<millymox> not sure what you mean
21:17:32FromDiscord<millymox> this
21:17:33FromDiscord<millymox> sent a long message, see http://ix.io/4yR5
21:17:41FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/W5V4T
21:18:34FromDiscord<Elegantbeef> then you can use `toJson` and `jsonTo`
21:21:50FromDiscord<millymox> sent a code paste, see https://play.nim-lang.org/#ix=4yR8
21:30:36FromDiscord<millymox> sent a code paste, see https://play.nim-lang.org/#ix=4yR9
21:31:17FromDiscord<Elegantbeef> either `import std/json` or `export json`
21:33:10FromDiscord<millymox> In reply to @Elegantbeef "either `import std/json` or": Thank you!
21:34:54*mad_toothbrush joined #nim
21:38:39FromDiscord<millymox> sent a code paste, see https://play.nim-lang.org/#ix=4yRb
21:39:08FromDiscord<millymox> sent a long message, see http://ix.io/4yRc
21:39:35FromDiscord<Elegantbeef> Of course cause it wants a `string`
21:39:44FromDiscord<millymox> how to turn to a string?
21:39:47FromDiscord<Elegantbeef> The runtime error is due to your json being empty
21:39:55FromDiscord<Elegantbeef> `$` the stringify operator
21:41:11FromDiscord<millymox> In reply to @Elegantbeef "The runtime error is": how is my json empty?
21:41:28FromDiscord<Elegantbeef> No clue something is nil
21:41:48FromDiscord<millymox> this is what i get when i echo payload↵↵{"clientKey":"gvHe","task":{"type":"HcaptchaTaskProxyless","websiteURL":"hey","websiteKey":"hey"}}
21:44:29FromDiscord<!&luke> sent a code paste, see https://play.nim-lang.org/#ix=4yRd
21:50:10FromDiscord<millymox> now i just get a segementation fault↵↵SIGSEGV: Illegal storage access. (Attempt to read from nil?)↵zsh: segmentation fault ./test
21:52:20FromDiscord<!&luke> How can I convert a string to cstring
21:54:47*ntat quit (Quit: Leaving)
21:55:17FromDiscord<Elegantbeef> `cstring myString`
21:56:53FromDiscord<Elegantbeef> That doesnt extend the string lifetime so if you need to extend the life time you need to do something else
21:59:12FromDiscord<huantian> In reply to @millymox "now i just get": what's your full code again?
21:59:29FromDiscord<millymox> sent a code paste, see https://play.nim-lang.org/#ix=4yRf
22:02:15FromDiscord<huantian> https://play.nim-lang.org/#ix=4yRj
22:02:16FromDiscord<huantian> seems to work
22:02:43FromDiscord<huantian> the nil access isn't from the json code
22:03:08FromDiscord<millymox> In reply to @huantian "the nil access isn't": i just removed the req code and it still giving me the error
22:03:08FromDiscord<ieltan> hmm... 🤔 https://media.discordapp.net/attachments/371759389889003532/1121561031991369908/image.png
22:03:20FromDiscord<huantian> is client nil?
22:03:40FromDiscord<millymox> No client is not nil
22:03:53FromDiscord<millymox> sent a long message, see http://ix.io/4yRk
22:04:10FromDiscord<millymox> sent a long message, see http://ix.io/4yRl
22:05:38FromDiscord<huantian> which line is the nil access on?
22:06:05FromDiscord<millymox> sent a long message, see http://ix.io/4yRm
22:07:25FromDiscord<huantian> ok so that means payload is nil I'd assume
22:08:08FromDiscord<huantian> can you echo what payload is again
22:08:17FromDiscord<huantian> (edit) "payload" => "foo" | "foois again ... " added "before you toJson"
22:09:19arkanoidNim manual expose how to sloppy import a c++ class within a namespace using header and importcpp pragma. I'm trying to upgrade it to non-sloppy importcpp (stripping away header pragma) but it fails to compile due to namespaces not declared
22:09:59*rockcavera quit (Ping timeout: 246 seconds)
22:10:15arkanoid"MyClass {.importcpp: "outer::inner::MyClass".} = object" does NOT work, but "MyClass {.header: "myheader.hpp", importcpp: "outer::inner::MyClass".} = object" works correctly
22:10:34FromDiscord<millymox> In reply to @huantian "can you echo what": The error goes away when i stop echoing taskjson not payload
22:12:05*xet7 quit (Ping timeout: 246 seconds)
22:18:58*rockcavera joined #nim
22:21:59NimEventerNew thread by giaco: How to importcpp a C++ class within namespaces in non-sloppy way, see https://forum.nim-lang.org/t/10293
22:35:12*lucasta joined #nim
22:35:41*lucasta quit (Remote host closed the connection)
22:36:28*lucasta joined #nim
22:57:05*mad_toothbrush quit (Ping timeout: 250 seconds)
22:59:16FromDiscord<JJ> sent a code paste, see https://play.nim-lang.org/#ix=4yRt
23:00:45FromDiscord<Elegantbeef> Yes
23:01:17*jmdaemon joined #nim
23:02:47FromDiscord<millymox> how to send asynchronous http requests?
23:06:46*xet7 joined #nim
23:11:26*xet7 quit (Remote host closed the connection)
23:11:55*xet7 joined #nim
23:25:17FromDiscord<millymox> whats the equivelent of sleep in nim?↵↵ sleep(1000)
23:25:31FromDiscord<Elegantbeef> `import std/os`
23:25:35FromDiscord<Elegantbeef> Also why are you sleeping
23:25:41NimEventerNew question by Lex: Nim SDL2 no window appears, see https://stackoverflow.com/questions/76536235/nim-sdl2-no-window-appears
23:25:45FromDiscord<Elegantbeef> You almost never want to actually sleep
23:30:40FromDiscord<millymox> In reply to @Elegantbeef "Also why are you": im setting a delay for requests, i send a requests every 1 - 2 seconds to wait for a specific response from the server
23:31:17FromDiscord<Elegantbeef> Ok well that might be fine, though it does freeze your thread
23:35:18FromDiscord<millymox> In reply to @Elegantbeef "Ok well that might": alright alright
23:35:25FromDiscord<millymox> can i ask why you show up as a bot sometimes?
23:35:41FromDiscord<Elegantbeef> I prefer using matrix but at times the bridge dies
23:36:37FromDiscord<jviega> I mean, the whole point of async is to let the async system resume your func easily where you left off when there's something to do. Explicitly waiting around for it isn't sensical if you're using async
23:36:37FromDiscord<millymox> Thank you to every nim coder that helped me with my idiotic questions today :nimGlow: https://media.discordapp.net/attachments/371759389889003532/1121584557842509935/Screenshot_2023-06-22_at_5.36.06_PM.png
23:36:57FromDiscord<millymox> In reply to @jviega "I mean, the whole": sorry for the lack of context, im not using async anymore
23:37:05FromDiscord<millymox> In reply to @Elegantbeef "I prefer using matrix": Ahhh okay i see
23:37:24FromDiscord<jviega> I don't like async, but then you should have a different model where you're polling to read w/ epoll and then dispatching to a handler
23:39:39FromDiscord<jviega> Basically, if you've got thousands of file descriptors because you're handling a lot of connections, idle threads wait for any descriptor to fire, and then go handle that. It scales far, far better than async and tends to be far less error prone / (easier to understand the control flow and debug) in the systems I've seen.
23:40:26FromDiscord<millymox> In reply to @jviega "Basically, if you've got": Ahhhh okay i see i understand
23:40:28FromDiscord<millymox> thank you
23:40:32FromDiscord<Elegantbeef> Eh they're mostly just moving through a list of proxies afaik, so there isnt much reason not to just use async 😄
23:41:11FromDiscord<Elegantbeef> Like yes you can just use selectors or similar, but for most cases async will be fine for this code
23:41:19FromDiscord<Elegantbeef> Atleast assuming it hasnt changed much
23:42:16FromDiscord<Elegantbeef> If you really want to go down the epoll method https://nim-lang.org/docs/selectors.html does exist
23:46:33FromDiscord<millymox> sent a long message, see http://ix.io/4yRC
23:47:09FromDiscord<Elegantbeef> `proc joinTaskResult[T](client: T)`
23:47:44FromDiscord<Elegantbeef> Nim has generics assuming the body is identical it'll suffice
23:47:45FromDiscord<Elegantbeef> If the body is not identical, nope
23:48:06FromDiscord<millymox> ahh that sucks, the body won't be indetical there will be a few small changes
23:48:18FromDiscord<millymox> like whats sent through the payload etc
23:49:08FromDiscord<Elegantbeef> sent a code paste, see https://paste.rs/Umt5h
23:49:11FromDiscord<Elegantbeef> You could also do full on generic code and just define procedures that do the parts that are different
23:49:49FromDiscord<Elegantbeef> That way you can make a basic interface and implement segments per type
23:51:26FromDiscord<millymox> Ahhh perhaps, some captchas differ largely from other, this method would work for recaptcha and hcaptcha but GeeTest and cloudflare turnstile are very different
23:52:26FromDiscord<millymox> So basically just have a generic create_task function, or join_task function and then have segements depending on the client
23:52:58FromDiscord<Elegantbeef> Operations can be their own procedures and then you could implement those procedures per types
23:53:04FromDiscord<Elegantbeef> It's a "generic interface"
23:53:15FromDiscord<millymox> can you give a visual example?
23:55:34FromDiscord<Elegantbeef> https://play.nim-lang.org/#ix=4yRE