jhass changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.1 | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
hightower2 has quit [Ping timeout: 240 seconds]
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 246 seconds]
f1refly has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 272 seconds]
avane has quit [Quit: ZNC - https://znc.in]
avane has joined #crystal-lang
<FromGitter> <mattrberry> Totally a niche thought, but has there been any consideration on adding support for functions like `r[]`, eg `def r[](idx : Int)` or `def r[]=(idx : Int, val : UInt32)`
<FromGitter> <mattrberry> I would think that it wouldn't be a huge addition in the compiler due to the way I understand existing [] and []= methods are implemented, but I could be totally wrong
<FromGitter> <3n-k1> @mattrberry how would that be used? if it's something like `obj.r[idx]`, you could just have a property `r` that implements the `#[]` method
<FromGitter> <mattrberry> I'll state again that it's very niche and not even necessary in those niche use cases, but here's my current use case: ⏎ I have a CPU class that has a list of registers on it, eg ⏎ ⏎ ```class CPU ⏎ getter r : Slice(UInt32) = Slice.new 16``` ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5fbb483fabf6a739a6aceac3]
<FromGitter> <3n-k1> core maintainers give us hygienic macros challenge ⏎ /s
<FromGitter> <3n-k1> allow us to create our *own* syntax uwu
<FromGitter> <3n-k1> ~~what'
<FromGitter> <3n-k1> ~~what's the worst that could happen~~
_whitelogger has joined #crystal-lang
<jhass> @mattrberry: just return a thin wrapper struct for r? `record @cpu : CPU do def []=(...) @cpu.@r[..] = ...; end end`
<jhass> in your proposal `a.b[c] = d` would be ambigous to be either `a.b.[]=(c, d)` or `a.b[]=(c, d)`
<oprypin> yes it'd basically turn Crystal into an undecidable grammar (communicating state from semantic back to the parser is a must) so probably not good, and the struct solution is indeed just how it should be done. if you check, maybe it has 0 performance effect. or maybe not. then just use r_get() 😅
incognitorobito has joined #crystal-lang
incognitorobito has quit [Ping timeout: 245 seconds]
psydroid has quit [Quit: Bridge terminating on SIGTERM]
return0e[m] has quit [Quit: Bridge terminating on SIGTERM]
erdnaxeli has quit [Quit: Bridge terminating on SIGTERM]
ryanprior has quit [Quit: Bridge terminating on SIGTERM]
return0e[m] has joined #crystal-lang
erdnaxeli has joined #crystal-lang
ryanprior has joined #crystal-lang
psydroid has joined #crystal-lang
repo has quit [Quit: WeeChat 2.9]
repo has joined #crystal-lang
_ht has joined #crystal-lang
<FromGitter> <j8r> Isn't tha strange tha Float32 // Int32 #=> Float32?
<FromGitter> <j8r> the result being floored, it can be an Int32
<FromGitter> <j8r> theoretically
<yxhuvud> no, it is perfectly normal that typeof(x/y) == typeof(x) forall x.
<FromGitter> <j8r> I don't know
<yxhuvud> hmm. no, that is not correct. but it seems to always propagate to float and never to int, at least
<FromGitter> <j8r> the definition of floor division is ⏎ ⏎ > the floor function is the function that takes as input a real number x {\displaystyle x} x, and gives as output the greatest integer less than or equal to x {\displaystyle x} x
[gnubie] has joined #crystal-lang
* [gnubie] waves
<FromGitter> <j8r> so, the greatest integer, logically should be of a `Int` type, not Float
<[gnubie]> i am trying to figure out the code snippet shared by Blacksmoke16 at https://gitter.im/crystal-lang/crystal?at=5fb86b5b477a8b480c0a06b3
<[gnubie]> on how can i add "data" with key=value pair when the CLIENT.post is executed
<[gnubie]> in the html form, it only asked for username and password.. now, i want to add data automatically added when CLIENT.post
<[gnubie]> if i translate the code snippet into a curl command, it will look like this: curl -k -d username=${username} -d password=${password} -X POST https://apidomain.com/api/path
<[gnubie]> now, i want to add another "data" automatically
<[gnubie]> in curl, it should now look like this:
<[gnubie]> curl -k -d username=${username} -d password=${password} -d client=curl -d scope=all -X POST https://apidomain.com/api/path
<[gnubie]> how should i POST the data: "client=curl" and "scope=all" in the https://gitter.im/crystal-lang/crystal?at=5fb86b5b477a8b480c0a06b3 ?
<[gnubie]> the html form will still retain asking the user with username and password. but once the user clicks the button, additional data will be added in the POST part
<[gnubie]> i've been searching similar objectives but i can't find one. i am trying to understand the crystal api reference but i still can't figure out
<[gnubie]> anyone can help?
<FromGitter> <Dan-Do> `response = client.post("/tcnnt/mstdn.jsp", form: {"client" => "curl", "scope" => "all})`
<[gnubie]> oh! so that's the syntax. i tried adding that form: but seems the syntax was wrong. let me try that..
<[gnubie]> seems that i cannot add the username and password to the form
<[gnubie]> CLIENT.post("/api/path", form: {"username" => "#{username}, "password" => "#{password}", "client" => "curl", "scope" => "all"})
<[gnubie]> i'm getting an error: undefined local variable or method 'username' for top-level
<FromGitter> <Daniel-Worrall> where are they coming from?
<FromGitter> <Daniel-Worrall> `params = HTTP::Params.parse(context.request.body.not_nil!.gets_to_end)` and then `params["username"]`
<[gnubie]> i'm sorry Daniel-Worrall. yes, i'm seeing that line but what do you mean?
<FromGitter> <Dan-Do> if the username comes from CLI, then use `"#{ARGV[1]}"`
<FromGitter> <Dan-Do> > *<[gnubie]>* i'm sorry Daniel-Worrall. yes, i'm seeing that line but what do you mean? ⏎ ⏎ ```CLIENT.post("/api/path", form: {"username" => "#{params["username"]}, "password" => "#{params["password"]}", "client" => "curl", "scope" => "all"})```
avane has quit [Ping timeout: 240 seconds]
<[gnubie]> thanks Dan-Do! it worked!
<[gnubie]> i'm getting excited here. i'm getting a json response. now, i want to parse the output in such a way that i will only get 2 k/v results out of 9 because only 2 k/v is what i'm interested to know.
<[gnubie]> currently in my shell script using curl, i use jq to pipe out the output
<[gnubie]> basically my jq command is: | jq -r '.token,.address'
avane has joined #crystal-lang
<FromGitter> <Daniel-Worrall> well how are you outputting it?
<[gnubie]> the output is json
<FromGitter> <Daniel-Worrall> Oh yeah, you're just serving it in a html body
<[gnubie]> i want to filter the json output in such a way that only 2 x k/v will be presented on the web browser
<FromGitter> <Daniel-Worrall> You can `json = JSON.parse(obj); "#{json["first_key"]}, #{json["second_key"]}"`
<FromGitter> <Daniel-Worrall> or you could define the json struct for serialising and just not include the other keys so it ignores them in parsing
<[gnubie]> is it on the block of the CLIENT.post or on the when "/submit" block?
<FromGitter> <Daniel-Worrall> you want to parse your response from your post
<[gnubie]> yes, i guess it should be outside
<[gnubie]> hi Daniel-Worrall and Dan-Do. thank you for the help. but i need to go now. i will be back later. thanks again! :)
* [gnubie] wishes there will be a book on crystal for newbies
[gnubie] has quit [Quit: Leaving]
<FromGitter> <Daniel-Worrall> Have you read the Reference?
<FromGitter> <Dan-Do> > **\* [gnubie]** wishes there will be a book on crystal for newbies ⏎ Here you go ⏎ https://crystal-lang.org/reference/https://crystal-lang.org/api/latest [https://gitter.im/crystal-lang/crystal?at=5fbbd3eab03a464f0829a9cb]
duane has quit [Ping timeout: 260 seconds]
duane has joined #crystal-lang
kreyren has joined #crystal-lang
<kreyren> Referencing https://github.com/iv-org/invidious/issues/1421 brainstorm appreciated.. i am trying to figure out how to handle scenario where crystal is deployed as a website that expects variable storing value based on deployed environment
<kreyren> namely this is using `HOST_URI` that is expected to change based on website deployed either on clearweb or as hidden service
<kreyren> where my current fix would be figure out what domain is being used to deploy the page and then interpret that in if statement to return HOST_URI?
<kreyren> the other option would be looking for onion-specific value somewhere around the page which is janky >.>
<kreyren> i was ideally thinking about something like `if domain is '.*\.onion' then return #{hidden_service} to store in HOST_URI
<FromGitter> <Blacksmoke16> And env vars wouldn't help?
<jhass> just ditch that in favour of the HTTP Host header and make sure your reverse proxy is always setting it correctly (so overriding any client supplied value)
<jhass> alternatively any other (custom) HTTP header set by the reverse proxy, but why if there's already one exactly for this purpose
<kreyren> Blacksmoke16, i don't know how would env var help assuming that this is not a constant
<kreyren> jhass, HTTP Host header? That is clear on hidden services i think
<kreyren> lemmeh check
<FromGitter> <Blacksmoke16> Ah I was under the assumption that one running instance would be one or the other. But it sounds like it should be able to handle both yea?
<kreyren> jhass, the HTTP header doesn't seem to be a viable option during the website initiation
<kreyren> Blacksmoke16, this is instance running on port e.g. 6912 that is providing the website to the clearweb, but the port is also mirrored to provide hidden_service
<kreyren> where the issue is that hidden_service refers to clearweb when it shoudn't e.g. login is not possible
<jhass> looking at https://manpages.debian.org/stretch/tor/torrc.5.en.html you could configure your hidden service to a different local port, have the reverse proxy listen to that and override the Host header or whatever for this case only
<kreyren> jhass, how would the host header helped in this situation? It doesn't seem to be available during the website initialization and the logic defines it as https://github.com/iv-org/invidious/blob/192d2b86b61f2212d1ae5423eba033deaf386c01/src/invidious.cr#L55 that is defined on https://github.com/iv-org/invidious/blob/192d2b86b61f2212d1ae5423eba033deaf386c01/src/invidious/helpers/utils.cr#L273 which depends on it being hard-codded
<jhass> Well, if you want your application be flexible in how it generates URL based on how it's accessed, you obviously cannot make this static global configuration
<jhass> it has to be per request
<kreyren> jhass, How could i do that in crystal then?
<kreyren> or what is your proposal in this case?
<jhass> to move this setting onto a per request basis
<kreyren> there is no request though.. the hidden service is available as a website that routes the POST/GET to the server or what do you mean?
<jhass> "flexible value per request" and "global constant value" are obivously contradictionary requirements
<jhass> It's a webapp, of course there's a HTTP request/response cycle
<kreyren> Like i think i understand what do you propose, but i don't see how that would be possible through crystal since it seems to need those hardcodded to expand for the HOST_URL that expects domain.tld
<kreyren> so basically if i can get domain.tld and dngjkasdng.onion in HOST_URI based on where the website is deployed that would solve the issue
<jhass> you're confusing invidious application structure with "Crystal"
<jhass> also just scroll down in the file you linked and notice the "before_all" hook which obviously runs for every request, wherever it is coming from
<kreyren> checking
<jhass> (I guess before_all is a kemal thing)
<kreyren> How would that help in determining where the website is deployed to store value in HOST_URI though?
<kreyren> or do you propose grabbing the HTTP Host header during that phase?
<jhass> You cannot use HOST_URI
<jhass> you have to replace it with a mechanism that works per request
<straight-shoota> what's HOST_URI anyway? AFAIK it's neither a kemal nor invidious thing
<kreyren> That shoudn't be a problem for me, but i don't understand the solution that you are proposing
<jhass> a standard Crystal constant
<jhass> straight-shoota: ^
<kreyren> HOST_URI is being used in the webapp to replace the domain.tld for links e.g. the generated RSS feed needs full name
<straight-shoota> Which webapp? I understood the discussion is about invidious? Can't find it there.
<kreyren> yes it's about invidious resolving https://github.com/iv-org/invidious/issues/1421
<kreyren> that doesn't work properly as hidden service
<kreyren> (using clearweb links, etc..)
<straight-shoota> So it's HOST_URL, not HOST_URI
<straight-shoota> That's why I couldn't grep it :D
<kreyren> yep HOST_URL :p
<kreyren> that is used all over the file to define `href` paths for example
<straight-shoota> Okay, so individous has a constant for configuring its external hostname
<kreyren> yep it has `domain` property in config that sets the HOST_URI variable
<jhass> which obviously is a flawed approach when there's more than one valid hostname
<straight-shoota> yepp
<kreyren> FWIW i was told that upstream didn't expect invidious being popular choice for hidden service so they set it up as hardcoded
<jhass> when upstream isn't interested to support this usecase it might become a quite hard to maintain patchset over time. It might be easier to just run two instances configured to the same DB (if any) locally
<kreyren> jhass, upstream is interested in supporting this configuration
<straight-shoota> IMO it's always a bad idea to make external host a static config value. For most web applications it shouldn't be necessary at all.
<kreyren> jhass, running two instances is not an option for management reasons
<kreyren> straight-shoota, true, but it supports running with `domain` property set as blank so i think i could expand login in that regard.. I don't know how to make the expression though
<kreyren> e.g. it should expand in invidious.snopyta.org on clearweb and in djdangjkangk.onion as hidden_service
<kreyren> (hidden url scrambled)
<straight-shoota> As jhass already mentioned, best solution is just to use the host header
<straight-shoota> no need for global configuration
<straight-shoota> Assuming reverse proxy is properly configured, you can trust that the value in the host header is what's available to the client
<straight-shoota> But I assume your issue is about cross-referencing between different hosts, right?
<straight-shoota> Or maybe not...
<kreyren> depends the webapp expects HOST_URI to be set depending on environment before it loads So i guess host header might be an option in before_all hook?
<kreyren> trying atm
<straight-shoota> I'm not sure what you need a before hook for to use that header
<straight-shoota> just use it in the request handler
<straight-shoota> instead of HOST_URL
<straight-shoota> HOST_URL needs to go. You can't have dynamic configuration with a constant. Replace every use of HOST_URL with a dynamic resolution based on host header
<kreyren> straight-shoota, it can't go because the webapp has features like RSS feed that require the value of HOST_URL to expand in valid feed
<jhass> an RSS feed is still fetched within a HTTP request/response cycle
<kreyren> or like how do you make sure that it generates correct paths assuming that things like RSS feed can't work with relative paths
<jhass> use the host header used to fetch the feed
<kreyren> The RSS feed has things like ` <link rel="self" href="/feed/channel/UCVls1GmFKf6WlTraIb_IaJg"/>` that needs to have domain in front of the `/feed` though
<kreyren> else the RSS feed is broken
<straight-shoota> So just use the host header: `<link rel="self" href="#{request.host}/feed/channel/UCVls1GmFKf6WlTraIb_IaJg"/>`
<kreyren> is #{request.host} set by default?
* kreyren wants to see if that fixes it in snopyta's environment
<straight-shoota> it's set to Host header
<straight-shoota> just note the code I posted was shortened for illustration
<jhass> which comes without a scheme so you need to prepend http:// or https://, likely dependent on the X-Forwarded-Proto header or such
<jhass> probably worth to add a little helper to determine the URI prefix from the Host and proto headers
<straight-shoota> yes
<kreyren> ^------
<kreyren> 1485 | xmlUrl = "#{request.host}/feed/channel/#{channel.id}"
<kreyren> Error: undefined local variable or method 'request' for top-level
<kreyren> O.o
<straight-shoota> at that location it's probably env.request
<kreyren> straight-shoota, eh that would be for environment variables no?
<straight-shoota> env is the handler's http context
<kreyren> eh so #{env.request.host} or something?
<kreyren> or just #{env.request} ?
<kreyren> as the env.request seems to be process the HTTP request not to return the expected data?
<straight-shoota> yes, you need env.request.host
<straight-shoota> plus scheme
<straight-shoota> This should help you: https://carc.in/#/r/9zme
<kreyren> scheme?
<straight-shoota> URI scheme
<straight-shoota> http or https
<kreyren> ah noted
<straight-shoota> call the helper method as `base_url(env.request)`
<straight-shoota> This helper method would be a nice addition to request type...
<jhass> straight-shoota: ah memories... https://github.com/jhass/carc.in/blob/master/src/web.cr#L98
<jhass> I bet there's as many standards for proto/scheme :D
<straight-shoota> yeah, it's really a jungle
<straight-shoota> which is even more reason to have a sophisticated solution in stdlib
<straight-shoota> so nobody needs to roll their own shitty one :D
<kreyren> straight-shoota, that stores blank when deployed on snopyta
<kreyren> ehhh
<straight-shoota> so maybe host header isn't set?
<jhass> straight-shoota: idk, the more "sophisticated" the stdlib solution the easier somebody can fool it because the reverse proxy doesn't filter all
<kreyren> straight-shoota, using curl -v the header for host is set
<jhass> maybe the reverse proxy or tor map thingy or whatever is in the pipeline filters it?
<kreyren> possible i guess
<kreyren> dunno how to verify as that is snopyta's config that i can request info from on demand
<kreyren> quotting: """nginx should forward the host `proxy_set_header Host $http_host;`"""
<jhass> probably worth to get a full dev setup locally for this tbh. So you can also locally curl each part of the pipeline explicitly
<jhass> and hack debug prints into stdlib, kemal and what not
<straight-shoota> or write specs where you can exactly control the request data
<kreyren> jhass, i am working on dev setup atm but i want to make sure that my solution works on snopyta
<straight-shoota> make sure that it runs in dev first
<straight-shoota> The production environment needs to provide you the requested host name somehow. If it doesn't it must be reconfigured.
deimos_ has joined #crystal-lang
<kreyren> How can i get shards on debian?
<kreyren> or are they part of crystal now?
<straight-shoota> shards is typically distributed with the crystal package
<kreyren> not distributed on my end O.o well using devuan. but that is using debian's package for crystal-lang
<kreyren> https://packages.debian.org/en/sid/amd64/crystal-lang/filelist yep not packaged with debian.. probably bug for crystal then right
<kreyren> using the crystal-provide drepo
<kreyren> *provided
<oprypin> Blacksmoke16, you really gotta declutter the documentation for Athena. just the API docs won't do. i almost skipped it because of that
<FromGitter> <munjalpatel> Hello, ⏎ ⏎ I am trying to make `https` calls to a service that is using a `self-signed` cert. ⏎ I have the `ca.pem` of that cert. ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5fbc10b7f5849839adec5fad]
deimos_ has quit [Remote host closed the connection]
deimos_ has joined #crystal-lang
<FromGitter> <Blacksmoke16> oprypin: declutter in what regard?
deimos_ has quit [Client Quit]
<oprypin> Blacksmoke16, present to the user only what matters for the base usage. sort by use case.
<FromGitter> <Blacksmoke16> would that not be the getting started section?
<FromGitter> <Blacksmoke16> goes thru basics, points out other things with links to more info
<oprypin> yea it's actually not bad. but my eyes jumped to the nav on the left and i got scared
<oprypin> and, well, the "getting started" thing itself has no nav
<FromGitter> <Blacksmoke16> WTB TOC for crystal doc :p
<FromGitter> <Blacksmoke16> i suppose i could just make one manually
<oprypin> Blacksmoke16, well u can follow the progress of https://github.com/oprypin/mkdocstrings-crystal
<oprypin> example of what it can do now is https://oprypin.github.io/crsfml-mkdocstrings/ but the API docs part of it is super half-baked
<FromGitter> <Blacksmoke16> oh neat, pretty slick
<FromGitter> <Blacksmoke16> i really like the idea of keeping the docs with the code. I feel its easy for dedicated external docs to get outdated
<oprypin> the thing that it does very nicely is that the textual docs are the king, and you can freely intersperse API definitions into it
<oprypin> well u can keep it in the same repo. and you really should; i think it's a mistake whenever people split it
<FromGitter> <Blacksmoke16> even if you have to go to another dir to update docs on a method i would think thats easy to forget
<FromGitter> <Blacksmoke16> i did/have plans to, do more with the `wiki` page
<FromGitter> <Blacksmoke16> like use that for general documentation, like how things are architected and such that don't really need updated too often. then keep API docs for more of the usage of things
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <Blacksmoke16> but im happy to see you're checking it out 😉 got a project in mind or something?
<oprypin> Blacksmoke16, with that attitude you're gonna end up writing an entire book with its source file having to be prefixed with `# ` in its entirety ಠ_ಠ
<oprypin> yea i have a project. i'll publish it if it works out
<FromGitter> <Blacksmoke16> 🙈 ha
<FromGitter> <Blacksmoke16> nice, any questions/issues etc feel free to ping me
<oprypin> ah but the api docs themselves seem stellar
<FromGitter> <Blacksmoke16> ❤️
<FromGitter> <j8r> I'm incrementing a x value to a given step float, until y. ⏎ I have ideas, but you, how would you do to know when y is reached or exceeded?
<FromGitter> <j8r> all values can be negative or positive, and mixed
<oprypin> j8r, ?? `0.0.step(by: 0.2, to: 100.0) do |x|`
<FromGitter> <j8r> I can't do that
<oprypin> but also why?
<FromGitter> <j8r> I'll see its implementation
<FromGitter> <j8r> Or maybe the iterator version
<oprypin> yes that'll work but it's still wrong
<FromGitter> <j8r> That's because that's on a game context
<oprypin> last number is `99.80000000000088` not `100.0`
<oprypin> for this implementation
<FromGitter> <j8r> the Main Loop make the entity move
<oprypin> j8r, are start and stop points integers by chance?
<FromGitter> <j8r> and call a method to increment its x/y
<oprypin> what framewrok is the game based on? ;)
<FromGitter> <j8r> None ;)
<oprypin> D:
<FromGitter> <j8r> I do the server side, and the client is JS
<oprypin> aha ok
<oprypin> i still don't see what the problem is. you increment `x` by `d` until it >= `y` (or <= for negative delta)
<FromGitter> <j8r> there is no problem, just wandering of a simpler solution :)
<oprypin> j8r, i recently noticed you're number one at https://opencollective.com/crystal-lang. wow. thank you.
<FromGitter> <j8r> ha?
<FromGitter> <j8r> ha, at individuals, thanks :)
<oprypin> and only opencollective i guess lol. bountysource has larger ones
<oprypin> doesnt matter tho
<FromGitter> <j8r> You too @oprypin, you donate lots of time, which as valuable
<oprypin> ❤️
<FromGitter> <j8r> I can use <=>
<FromGitter> <j8r> if the result change, stop
<oprypin> that.. is quite an idea
<straight-shoota> that looks really, nice oprypin
<oprypin> i dont get it, how do i parse if a http request returns body `error=bad_verification_code&error_description=The+code+passed+is+incorrect+or+expired.&error_uri=blabla` ? seems like there's only the block version of https://crystal-lang.org/api/0.35.1/HTTP/FormData.html#build(response:HTTP::Server::Response,boundary=MIME::Multipart.generate_boundary,&)-class-method ?
<oprypin> straight-shoota, thanks :>
<oprypin> i have so much pressure to finish all my various projects xD
<straight-shoota> seems familiar...
<FromGitter> <j8r> question: in your opinion, what's the sign of `Float32::NAN`?
<straight-shoota> oprypin, you want to *parse* a body, so you should be using FormData.parse ?
<FromGitter> <j8r> `Float32::NAN.sign #=> 1`- a bug?
<straight-shoota> hm, how can something have a sign when it's not even a number...?
<oprypin> j8r, what should it be, an exception?
<oprypin> straight-shoota, yea i want to parse but just get a Hash
<FromGitter> <j8r> at least, `0` maybe
<straight-shoota> IMO exception would be best
<straight-shoota> any value other than `1` or `-1` would be a total screw up
<FromGitter> <j8r> #<=> and #sign are quite close
<_ht> If I overload "initialize" how can I call another initialize method in my overloaded one?
<FromGitter> <j8r> and `#<=>` returns nil, 0, 1, or -1
<straight-shoota> `number.sign * some_value` is a typical use case for `#sign`
<straight-shoota> it's not related to `#<=>` in any way
<FromGitter> <j8r> it can
<FromGitter> <j8r> because it checks nan values, and sign is basically `self <=> 0` no?
<straight-shoota> _ht, you shouldn't
<_ht> Why not? I'd like to have one initialize with a block parameter and one without.
<_ht> That is not possible / common in Crystal?
<oprypin> j8r, fyi this is why it's positive
<oprypin> >> [1f32, -1f32, Float32::NAN].each { |y| x = y; p "%032b %f" % {pointerof(x).as(UInt32*).value, x} }
<DeBot> oprypin: "00111111100000000000000000000000 1.000000" - more at https://carc.in/#/r/9zoz
<_ht> @straight-shoota or should I just duplicate my code in the constructor?
<_ht> That's fine as well, I suppose, because it is very small anyways
<straight-shoota> _ht, the idiomatic solution is to overload `self.new`
<_ht> Aha! I'll look into that
<oprypin> >> [0b01111111110000000000000000000000u32, 0b11111111110000000000000000000000u32].each { |x| print "%f, " % pointerof(x).as(Float32*).value }
<DeBot> oprypin: nan, -nan, - https://carc.in/#/r/9zp0
<oprypin> j8r, here's negative nan for you
<FromGitter> <j8r> hum, ok
<FromGitter> <j8r> Is it standard, or just an implementation detail for Crystal?
<FromGitter> <j8r> *or decision
<oprypin> here are two more nans
<oprypin> >> [0b01111111110000100001000100000000u32, 0b11111111110000000010000000000101u32].each { |x| print "%f, " % pointerof(x).as(Float32*).value }
<DeBot> oprypin: nan, -nan, - https://carc.in/#/r/9zp1
<FromGitter> <j8r> nans can be positive or negative
<oprypin> actually im not sure, maybe *that* is a mistake on crystal's part
<oprypin> i think it is actually
<FromGitter> <j8r> that's what you showed me, and `Float32::NAN` is an arbitrary one?
<oprypin> yes an arbitrary one
<straight-shoota> tight
<straight-shoota> *right
<FromGitter> <j8r> I don't know if this constant has a use-case
<oprypin> yes it does
<oprypin> >> Float32::NAN != Float32::NAN
<DeBot> oprypin: # => false - https://carc.in/#/r/9zp2
<oprypin> um nvm it doesn't
<FromGitter> <j8r> I see Float64::NAN used in YAML
<oprypin> in all other languages this inequality holds
<oprypin> seems like there are a lot of bugs here then
<straight-shoota> hm but `Float#nan?` is `!(self == self)`
<oprypin> >> Float32::NAN == Float32::NAN
<DeBot> oprypin: # => false - https://carc.in/#/r/9zp3
<oprypin> oh ok then
<oprypin> straight-shoota, wait, this is not FormData, that's the issue!! there's no `boundary`
<FromGitter> <j8r> the <=> make nans not comparable, logic, even though there are at a low level
<FromGitter> <j8r> (like you showed me)
<FromGitter> <j8r> the same could be done for sign, maybe
<straight-shoota> oprypin, so you just need HTTP::Params.parse
<oprypin> aha that's the one! thanks
<FromGitter> <j8r> hum, I can't use `<` as a proc, like `->1.<`
<oprypin> >> ->1.<(Int32)
<DeBot> oprypin: Error: unexpected token: 1 - https://carc.in/#/r/9zp6
<oprypin> >> x = 1; ->x.<(Int32)
<DeBot> oprypin: # => #<Proc(Int32, Bool):0x55e525a9ff40:closure> - https://carc.in/#/r/9zp8
<oprypin> j8r, this isthe syntaz
<FromGitter> <j8r> thanks, right
<FromGitter> <j8r> I will use this for my destination reached check
_ht has quit [Quit: quit!]
<FromGitter> <j8r> the return type is inferred, nice
<oprypin> j8r, at that point just use the iterator
<FromGitter> <j8r> this is quite simple actually
<straight-shoota> oprypin, so mkdocstrings-crystal parses the JSON output of `crystal doc`?
<oprypin> straight-shoota, yes
<FromGitter> <j8r> No iterator, this can impact perf. This calculation will be done, a lot
<oprypin> proc can impact it too
<FromGitter> <j8r> like 1000 entities * 5 per seconds
<straight-shoota> That's basically an implementation of my separation idea in https://github.com/crystal-lang/crystal/issues/6947#issuecomment-561368164 just with a non-crystal frontend genrator
<FromGitter> <j8r> the proc is only done one time, in a struct. Using classes will put pressure to the GC each time one change directions :/
<FromGitter> <j8r> also, I need 2 iterators
<FromGitter> <j8r> so, not ideal
<FromGitter> <j8r> and finally, as you said, I would like to stop after reaching the destination (and then round to the actual x,y), not before :/
<oprypin> straight-shoota, woops i had forgotten to push my code. there's more now. https://github.com/oprypin/mkdocstrings-crystal/blob/master/mkdocstrings/handlers/crystal/collector.py
<oprypin> ugh sucks that GitHub shows committed date, not authored date
<FromGitter> <munjalpatel> Hello, ⏎ ⏎ I am trying to make `https` calls to a service that is using a `self-signed` cert. ⏎ I have the `ca.pem` of that cert. ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5fbc259babf6a739a6af29ca]
<erdnaxeli> what are the reasons the use a named tuple instead of a record (beside mutability)?
<FromGitter> <j8r> convenient spec testing
<oprypin> erdnaxeli, no reason, even mutability. namedtuple is to acceps **kwargs, maybe pass them sometimes, that's it
<erdnaxeli> ok :)
<FromGitter> <j8r> also, useful in macros
<FromGitter> <j8r> (NamedTupleLiteral)
<FromGitter> <j8r> not quite the same
deimos_ has joined #crystal-lang
deimos_ has quit [Remote host closed the connection]
deimos_ has joined #crystal-lang
<oprypin> whos the last man standing
<erdnaxeli> I like of a method named URL_concat use join from the File module :p
<FromGitter> <Blacksmoke16> It's twice as fast if you use two frameworks :p
<raz> crystal really needs persistent http connections
<raz> that would really make things twice as fast
<FromGitter> <Blacksmoke16> It reuses the fiber if it's keep alive
<FromGitter> <Blacksmoke16> To handle a request
<raz> the TCP connection tho, that's the one that counts
<jhass> I think one of you is thinking client and one is thinking server
<raz> er wait, you mean it re-uses that?
<raz> last i checked http-client couldn't do persistent conns
<raz> not sure about server
deimos_ has quit [Ping timeout: 240 seconds]
deimos_ has joined #crystal-lang
<FromGitter> <Blacksmoke16> Ah, yup jhass was right :p
deimos_ has quit [Quit: deimos_]
<oprypin> Blacksmoke16, how do i pass a database to athena?
<FromGitter> <Blacksmoke16> Pass a database? There isn't a specific orm if that's what you mean
<FromGitter> <Blacksmoke16> So can use whichever you prefer
<oprypin> Blacksmoke16, ok there's DB.open |db| and i have athena quickstart in front of me. how to combine the two
<FromGitter> <Blacksmoke16> Mmm probably could have a singleton wrapper to the db connection you can use like the orms do
<FromGitter> <Blacksmoke16> Or maybe just define a helper method in the base controller type
<FromGitter> <Blacksmoke16> Which could yield the db instance, i.e. abstract the connection url
f1refly has quit [Quit: bye fags]
f1refly has joined #crystal-lang
<oprypin> ah shit https://app.quicktype.io/
<oprypin> Error 503 Backend.max_conn reached
<FromGitter> <Blacksmoke16> rip
<FromGitter> <Blacksmoke16> and going back to the db thing, i suppose a more robust solution would be to have a like `DBFactory` or `DBProvider` or something that you can inject as needed. It could be a singleton (since DB handles checking out connections), and provide an API to yield a connection.
<FromGitter> <Blacksmoke16> but :shrug: depends on how you want to go about it
<FromGitter> <christopherzimmerman> Is there a way to use the `FILE` type from C in bindings? Thought it might be exposed via LibC, but guess not.
<oprypin> chachasmooth, Void* if you really need
<oprypin> ideally dont do that tho
<FromGitter> <christopherzimmerman> I guess that could work if I needed to receive a file handler, I think I need to be able to pass a file handler to a library. Not sure if that's possible right now.
<oprypin> Blacksmoke16, (lazy question), so i see that athena controller methods can return an object. is there any way to add a wrapper around all of them? to accept that object and further respond
<FromGitter> <Blacksmoke16> yes, sec