SamantazFox_ has quit [Remote host closed the connection]
SamantazFox has joined #crystal-lang
renich has quit [Ping timeout: 244 seconds]
ur5us has joined #crystal-lang
<FromGitter>
<Blacksmoke16> xD rip
onyx has joined #crystal-lang
ur5us_ has joined #crystal-lang
ur5us_ has quit [Read error: Connection reset by peer]
ur5us has quit [Read error: Connection reset by peer]
ur5us_ has joined #crystal-lang
onyx has quit [Read error: Connection reset by peer]
Sankalp has quit [Ping timeout: 276 seconds]
Sankalp has joined #crystal-lang
ur5us_ has quit [Ping timeout: 255 seconds]
Sankalp has quit [Ping timeout: 246 seconds]
Sankalp has joined #crystal-lang
_ht has joined #crystal-lang
_ht has quit [Remote host closed the connection]
ur5us_ has joined #crystal-lang
jmdaemon has quit [Ping timeout: 255 seconds]
notzmv has quit [Ping timeout: 258 seconds]
ur5us_ has quit [Ping timeout: 244 seconds]
brw has quit [Remote host closed the connection]
notzmv has joined #crystal-lang
Sankalp has quit [Ping timeout: 255 seconds]
Sankalp has joined #crystal-lang
<FromGitter>
<stellarpower> Does crystal have anything like a parallel map or each? I'd like to execute each block in a new thread and join all those to wait for the results, without having to plumb it by hand.
<FromGitter>
<Blacksmoke16> might be some shard that provides it, but nothing built in
<FromGitter>
<stellarpower> That's exactly what I'd like - fire and forget methods over arrays and hashes as were used to all the time for serial programming.
<FromGitter>
<stellarpower> Think this is what I used in ruby for the same
<FromGitter>
<Blacksmoke16> i also should point out, a fiber in crystal is not the same as a thread to be clear
<FromGitter>
<Blacksmoke16> fibers are for concurrency, not parallelism. in order for more than 1 fiber to be executed at a time you need to enable MT mode, which is still considered experimental
<FromGitter>
<Blacksmoke16> via `-Dpreview_mt`
<FromGitter>
<stellarpower> c++23 will be adding more support for something similar, which is pretty awesome
<FromGitter>
<stellarpower> You should be able to push an algorithm to the GPU within a loop
casionaut has joined #crystal-lang
casionaut has quit [Ping timeout: 252 seconds]
casionaut has joined #crystal-lang
casionaut has quit [Quit: Client closed]
<FromGitter>
<paulocoghi> Hello everyone ⏎ ⏎ I'm trying to create a basic project just to familiarize myself with Crystal prior to "migrate" my NodeJS frameworks and architecture concepts, but I'm stuck with JSON to object conversion. ⏎ ⏎ I have the following structure, and I would like to be able to create new instances from a JSON string, like: ... [https://gitter.im/crystal-lang/crystal?at=62a39060e393a318064e8d89]
<FromGitter>
<Blacksmoke16> so like a `Poll` type that has a `title : String` property, and a `alternatives : Hash(String, Choice)` where the `Choice` type has `description : String` and `votes : Int32`
<FromGitter>
<paulocoghi> Exactly
<FromGitter>
<paulocoghi> Thanks a lot, Dietrich
<FromGitter>
<Blacksmoke16> 👍
<FromGitter>
<paulocoghi> By the way, excellent book! I already bought mine!
<FromGitter>
<Blacksmoke16> thanks! glad you're enjoying it
<FromGitter>
<paulocoghi> After making our classes with JSON::Serializable, is there a way to check if the provided JSON fulfills/respects the class structure? ⏎ ⏎ IN other words, I would like to ensure my Crystal programs doesn't exit just because the JSON string passed doesn't respect the structure.
<FromGitter>
<Blacksmoke16> how to do that depends on the context id say. like are you in a CLI/web context or?
<FromGitter>
<Blacksmoke16> really the only way to handle that is rescue the exception and handle it somehow
<FromGitter>
<paulocoghi> Web API context
<FromGitter>
<paulocoghi> Ok, thanks!
<FromGitter>
<Blacksmoke16> if you're using a farmework, then they might provide a good/better way to handle it
<FromGitter>
<Blacksmoke16> framework*
<FromGitter>
<paulocoghi> I'm trying to to a (basic) project from scratch, since I plan to build a new framework on Crystal
<FromGitter>
<Blacksmoke16> ah another one eh? :P planning anything cool/unique features for it?
<FromGitter>
<Blacksmoke16> including the serializable module creates a constructor, essentially removing the default no arg one
<FromGitter>
<Blacksmoke16> so may need to add back a `def initialize; end` if you want to do it that way as well
<FromGitter>
<Blacksmoke16> however there is no need to include the module into `Polls` if that type will never need to be (de)serialized
<FromGitter>
<paulocoghi> Polls are converted to JSON when the read_all method is called
<FromGitter>
<paulocoghi> In this case, we will need to (de)serialize them
<FromGitter>
<paulocoghi> I will try with `def initialize; end`. Thanks a lot, again!
<FromGitter>
<Blacksmoke16> 👍 yea then that should work fine
_ht has quit [Remote host closed the connection]
<FromGitter>
<stellarpower> I'm hitting something a bit weird with HTTP::Client and tor
<FromGitter>
<stellarpower> although only on some sites
<FromGitter>
<stellarpower> If I run Crystal via `torify`, this should handl routing the application via tor in lieu of exiting normally through the host
<FromGitter>
<stellarpower> I've narrowed it down to happening only when I access this site using tls
<FromGitter>
<stellarpower> And it seems to wokr okay if I send it to google or ifconfig.me
<riza>
@stellarpower try setting the tls config to verify::none on the client configuration
<FromGitter>
<Blacksmoke16> @stellarpower thanks for that ifconfig.me site, it made me finally figure out why some websites would randomly be in german for me 😅
<FromGitter>
<stellarpower> XD
<FromGitter>
<stellarpower> How can I do that, sorry?
<FromGitter>
<stellarpower> ot seeing it documented anywhere
<FromGitter>
<stellarpower> But I tink you're probably right, is it MITMing or something?
<FromGitter>
<Blacksmoke16> German was set as a language in chrome, so websites were getting sent `accept-language: en-US,en;q=0.9,de;q=0.8` header, and must have not liked the first two so got german versus the default of usually english
<riza>
my guess is that it's just failing the ssl domain verification for some reason
<FromGitter>
<stellarpower> Oh wait, okay
<riza>
you may need a certificate chain for tor or something, i dont remember
<riza>
when you http::client.exec you can pass it a tls_config: https://crystal-lang.org/api/1.4.1/HTTP/Client.html#exec%28method%2Curl%3AString%7CURI%2Cheaders%3AHTTP%3A%3AHeaders%3F%3Dnil%2Cbody%3ABodyType%3Dnil%2Ctls%3ATLSContext%3Dnil%29%3AHTTP%3A%3AClient%3A%3AResponse-class-method
<riza>
it's a bit of noisy boilerplate just to get it to ignore ssl trust chain, but it works
<FromGitter>
<stellarpower> Thanks, I saw that but read the SSL Context as a constant/enum/etc.
<riza>
if you find out that it does work with that, but you do want it to correctly verify the chain of trust, you'll need to dive in a little more to figure out why it's not trusting the connection
<FromGitter>
<stellarpower> Takes some time to get used to the arithmetic-style types
<FromGitter>
<stellarpower> Just testing, sorry, I have about a million windows open right now
<FromGitter>
<stellarpower> > German was set as a language in chrome, so websites were getting sent `accept-language: en-US,en;q=0.9,de;q=0.8` header, and must have not liked the first two so got german versus the default of usually english ⏎ ⏎ Ah! Nothing like sporadic reproducabilty to make our lives harder
<FromGitter>
<stellarpower> I had something where package installations, other web requests would sporadically fail in Solaris
<FromGitter>
<stellarpower> turns out it had two DNS set up and one was not so happy with some sites.
<FromGitter>
<stellarpower> And it was just luck which it was picking at the time itr claled out.
<FromGitter>
<stellarpower> Still doesmn't seem to be too happy
<FromGitter>
<Blacksmoke16> Does it work in curl
<FromGitter>
<stellarpower> Yeah, without any issues at all
<FromGitter>
<stellarpower> Doesn't seem like this really ought to be an EOFError, would it be worth opening as a bug to throw a different exception somewhere?
<FromGitter>
<Blacksmoke16> does the response look normal? could be curl just handles it but crystal is a bit more strict?
<FromGitter>
<Blacksmoke16> :shrug:
<FromGitter>
<stellarpower> It's a POST that then 302s to the results
<FromGitter>
<stellarpower> Or at leats that's what I'm aiming for, I tihkn I hit the same issue just trying to get to the landing page
<FromGitter>
<stellarpower> I have to soak up some cookies, it's been a right pain in the arse. Mayb I should've just tried with Postman or what have you, but they don't usually let you do much with the results,and I want then to go and fetch more data
<FromGitter>
<stellarpower> Not reall sure what to do without being able ot get past the EOFErrorr t osee wha tthe real issue ois
<FromGitter>
<stellarpower> Maybe I can just call out to the shell instead
<FromGitter>
<girng> i had an interview with a local ISP company and mentioned crystal. did the 2nd round interview, and the ceo said he dabbled around with it. it made my day, haha wanted to share