qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
relyks has joined #crystal-lang
_whitelogger has joined #crystal-lang
<crystal-gh>
[crystal] MakeNowJust opened pull request #5599: Use join instead of each_with_index and `if i > 0` (master...fix/use-join) https://git.io/vN4vt
DTZUZU has quit [Ping timeout: 248 seconds]
DTZUZU2 has joined #crystal-lang
greengriminal has quit [Ping timeout: 255 seconds]
greengriminal has joined #crystal-lang
snsei has quit [Ping timeout: 256 seconds]
<FromGitter>
<straight-shoota> I'm having trouble with linking windows builds since random implementation was merged...
<FromGitter>
<straight-shoota> `error LNK2019: unresolved external symbol SystemFunction036 referenced in function .2A.Crystal.3A..3A.System.3A..3A.Random.3A..3A.random_bytes.3C.Slice.28.UInt8.29..3E..3A.Nil`
<FromGitter>
<straight-shoota> I guess it's something about advapi32.lib...
<FromGitter>
<straight-shoota> I think I've installed everything necessary from the VS 2017 installer but maybe I missed something
<FromGitter>
<straight-shoota> RX14 any idea?
<RX14>
You are linking with advapi32.lib right?
<FromGitter>
<straight-shoota> yep
<FromGitter>
<straight-shoota> several versions of that are available in the WindowsKits folder
<RX14>
And the linker acknowledges that?
<FromGitter>
<straight-shoota> not really
<RX14>
It prints out all the libs it uses
<RX14>
By default
<FromGitter>
<straight-shoota> yes, advapi32.lib is not listed
<FromGitter>
<straight-shoota> its only in the linker command
<RX14>
And that symbol hadn't changed name since I was born
<RX14>
So it shouldn't be a version incompatibility
snsei has quit [Ping timeout: 276 seconds]
<RX14>
Try specifying the full path
<RX14>
Apart from that no clie
<RX14>
Clue*
<FromGitter>
<straight-shoota> damn
<FromGitter>
<straight-shoota> it was my cross-compile script
<FromGitter>
<straight-shoota> it shows the linker command returned from `crystal --cross-compile`
<FromGitter>
<straight-shoota> but it actually ran a differnt commant with hardcoded arguments where advapi32 was missing
<FromGitter>
<straight-shoota> I'm gonna need a proper solution for that
<FromGitter>
<straight-shoota> but the bottom line is: time zone implementation for windows works
DTZUZU2 has quit [Ping timeout: 255 seconds]
greengriminal has quit [Quit: This computer has gone to sleep]
snsei has joined #crystal-lang
DTZUZU2 has joined #crystal-lang
greengriminal has joined #crystal-lang
greengriminal has quit [Client Quit]
<hightower4>
Is there a performance difference between calling @var and getter var inside a class?
<FromGitter>
<asterite> None, should be inlined when optimized
LastWhisper____ has joined #crystal-lang
<hightower4>
++
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
relyks has quit [Quit: relyks]
relyks has joined #crystal-lang
snsei has quit [Ping timeout: 265 seconds]
snsei has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter>
<Dillybob1992> have a question about setting hashes: https://play.crystal-lang.org/#/r/3egy/edit ⏎ does that code generate a memory leak? what happens to the 3 initializes of `ChatRoom` that weren't set to any hash key?
c-c has quit [Ping timeout: 276 seconds]
c-c has joined #crystal-lang
c-c is now known as Guest23132
wontruefree has joined #crystal-lang
relyks has quit [Quit: relyks]
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
wontruefree has quit [Ping timeout: 276 seconds]
relyks has joined #crystal-lang
wontruefree has joined #crystal-lang
hightower4 has quit [Ping timeout: 256 seconds]
wontruefree has quit [Read error: Connection reset by peer]
wontruefree has joined #crystal-lang
<FromGitter>
<watzon> @Dillybob1992 So you're assigning multiple things to the same key?
<FromGitter>
<Dillybob1992> yah, but i did it on accident. but im just kinda curious how the inner workings work there
<FromGitter>
<watzon> @Dillybob1992 my guess would be that there would be no wasted memory. You are just creating objects and destroying them almost immediately
<FromGitter>
<Dillybob1992> i see =] im reading on memory docs now, seems like ill be fine
<FromGitter>
<Dillybob1992> i see, reading memory doc page now too, ty
<FromGitter>
<watzon> I want to send and receive websocket messages without blocking. How would I do that? Right now I'm trying to run `HTTP::WebSocket.run` inside of a `spawn`, but it doesn't seem to work
snsei has quit [Remote host closed the connection]
greengriminal has quit [Quit: Leaving]
snsei has joined #crystal-lang
relyks has quit [Quit: relyks]
lacour has quit [Quit: Leaving]
<FromGitter>
<yxhuvud> How does it not work?
snsei has quit [Ping timeout: 276 seconds]
andrewzah has quit [Ping timeout: 265 seconds]
mark_66 has joined #crystal-lang
andrewzah has joined #crystal-lang
flaviodesousa has joined #crystal-lang
dyreshark has quit [Quit: WeeChat 1.9]
andrewzah has quit [Ping timeout: 255 seconds]
return0e_ has joined #crystal-lang
andrewzah has joined #crystal-lang
snsei has joined #crystal-lang
jnyw has quit [Quit: WeeChat 2.0.1]
hightower4 has joined #crystal-lang
<RX14>
Lol I would have bet on the argument not making it to the linker @straight-shoota
wontruef_ has joined #crystal-lang
wontruefree has quit [Ping timeout: 276 seconds]
snsei has quit [Ping timeout: 276 seconds]
wontruefree has joined #crystal-lang
wontruef_ has quit [Ping timeout: 265 seconds]
xfbs has joined #crystal-lang
snsei has joined #crystal-lang
<xfbs>
Namasté my favourite crystallers! Quick question: when you have a crystal project and you want to kinda separate the library code from the code for the executable, is there a standard way to do this? Like just putting the executable code in src/bin/?
hightower3 has quit [Read error: Connection reset by peer]
hightower2 has joined #crystal-lang
<FromGitter>
<straight-shoota> There are no existing conventions xfbs
<FromGitter>
<straight-shoota> But many projects call their executables cli.cr or app.cr so it would make sense to put additional files in src/cli or src/app respectively
<FromGitter>
<xfbs> Welp I'm basically using crystal to solve some project eulers. I would just have `src/solver.cr` as the library code and `src/solve.cr` as the executable. So putting the executable into `src/bin/solve.cr` wouldn't be a bad idea?
xfbs has quit []
Yxhuvud has quit [Ping timeout: 268 seconds]
<FromGitter>
<Dillybob1992> hey, is it possible to add a return statement in short if form? ⏎ `client.send "Channel name is too long.", "ERROR" return, if want_to_join.size > 20` ⏎ i know can prob just do a `raise` and catch, but just out of curiosity
<FromGitter>
<l3kn> So you have some if clause that checks if the channel name is too long in it, you first send the error message
<FromGitter>
<l3kn> and if the want_to_join size is to big, too, you want to return?
<FromGitter>
<Dillybob1992> yah, if i do if block it'll be 2 extra lines just trying to tidy it up :O
<FromGitter>
<asterite> I think you just want return channel.send... if...
<FromGitter>
<xfbs> [want_to_join].select{|n| n > 20}.each{|_| client.send "Channel name is too long", "ERROR"; return}
<FromGitter>
<Dillybob1992> oh god, sorcery
<FromGitter>
<xfbs> I mean this ^ could work, it's a one liner, but probably not what you want
<FromGitter>
<Dillybob1992> i like it but my gosh, prob confuse me when i wake up tomorrow and re-look, LOL
<FromGitter>
<asterite> Just put the return in the beginning of the line
<FromGitter>
<Dillybob1992> wow really
<FromGitter>
<Dillybob1992> WOW, that does work.. omg, awesome
<FromGitter>
<asterite> About your other question, the extra objects will be created and eventually freed (after much more memory is allocated). It's not freed immediately as someone suggested
<FromGitter>
<xfbs> Only downside of that is that you'll return whatever client.send returns, but if that's alright, probably the most obvious thing to do
wontruef_ has joined #crystal-lang
wontruefree has quit [Ping timeout: 276 seconds]
<FromGitter>
<Dillybob1992> @asterite oh, good to know, thx alot. love how crystal takes care of that low level stuff for me. it really does make programming a lot more easier/fun (in my experience)
<FromGitter>
<Dillybob1992> @xfbs i see, ya should be fine in my case hehe
<FromGitter>
<asterite> Well, nodejs also takes care of the memory for you
<FromGitter>
<Dillybob1992> I feel it's funner on crystal because when i do puts on objects, i can see memory addresses and i know if i do array.delete class, that's it. on nodejs, i did the same thing but can't see any memory address stuff (doesn't feel right now looking back), and i don't think I'd get nearly as much performance. especially after looking at kemal's websocket benchmark. crystal just seems right, and i don't
<FromGitter>
... want to go back. ⏎ ⏎ I think, a lot of other nodejs developers will love the "everything is an object" line, that crystal has. I don't know why I just switched to the language now. I do remember, however, back in 05 / 06, it was linux only, and I didn't want to work on virtual machine or dual boot. However, now with Bas ... [https://gitter.im/crystal-lang/crystal?at=5a5f49085a9ebe4f759a204d]
<FromGitter>
<xfbs> I kinda agree with you. I've been doing ruby for a long time, and while I always loved the syntax, it's just kinda slow sometimes and you have to optimise things here and there. But with crystal, I can get performance almost as good as C (have a look at the progress table at https://github.com/xfbs/euler) with a syntax ten times sweeter!
<FromGitter>
<Dillybob1992> @xfbs yeah, here's something I found with the syntax differentiation compared to js. I am terrible at remembering things and been with nodejs for years, and can't even write out my own little tcp server w/o copying a snippet from SO (even those are around same amount of lines). However, with Crystal, just on the 2nd day of reading the docs and recipe book.. memorization has been 10x easier. I can
<FromGitter>
... literally just open a new file, a write a tcp server w/o having to look at snippets online. Sure, I occasionally alt-tab back to the docs/recipe book, but there is something about the syntax and the way the code "flows" that triggers something in the brain to make you remember. I don't really know how to explain it. ⏎ ⏎ For ex ... [https://gitter.im/crystal-lang/crystal?at=5a5f4dd3ae53c15903fb6393]
xfbs has joined #crystal-lang
<FromGitter>
<xfbs> Oh yes, the ruby-esque syntax is so nice. Sometimes you feel like you're just reading a story. I'm really liking the fact that the characters allowed for function names are more liberal than other languages, so stuff like this is allowed: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ Isn't that beautiful? [https://gitter.im/crystal-lang/crystal?at=5a5f50621dcb91f1775fa75c]
xfbs has left #crystal-lang [#crystal-lang]
snsei has quit [Ping timeout: 265 seconds]
<lvmbdv>
finally, i wrote a lisp parser i'm not ashamed of
<FromGitter>
<Dillybob1992> @xfbs oh wow, neat. yeah, i definitely like ruby-esque. i swear, i am remembering more with that kind of snytax, there has to be a correlation
<Papierkorb>
I'm actually surprised, currently porting a whole project from Crystal to C++. Same architecture, mostly same methods (even names), same underlying libs. In C++, I need 1.5-2x the line count to do the same thing. Surprising in that this is mostly "hidden", you don't really notice you're writing much more in the general case (except for explicit for loops and the tons of breaks in switches). Only if you compare it after you ported a
<Papierkorb>
whole class it shows.
<Papierkorb>
The 6502 interpret core takes (Plain editor line counts:) 250 lines in Crystal, but 460 in C++. That alone doesn't explain the ~15lines of overhead to accomodate for the different memory model (of C++), and the ~60 breaks; for the switches.
snsei has joined #crystal-lang
<FromGitter>
<asterite> cool
<FromGitter>
<asterite> How's the performance?
<Papierkorb>
Haven't compared it yet
<FromGitter>
<xfbs> Ohh you're writing an emulator for a 6502? Sounds like a fun project. Why did you decide to port it to C++ tho
<FromGitter>
<xfbs> *?
<Papierkorb>
Cause I'm writing my thesis on dynamic recompilation (of 6502 code), using the NES as guest platform. And the grading folks can read C++ ("I know Java" - Close enough.), and would probably refuse reading Crystal. Well, and C++ also makes more sense if you want to get a job in something low level right now :P
<Vexatos>
How could you "refuse" reading something?
<Vexatos>
That's what they are paid to do
<Papierkorb>
And they also have other shit to do than just reading my thesis
<lvmbdv>
is this a bachelor thesis
<Papierkorb>
That is correct
<Vexatos>
I am going to start mine in two to three months.
<lvmbdv>
i'm in the middle of mine
LastWhisper____ has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
wontruefree has joined #crystal-lang
wontruef_ has quit [Ping timeout: 276 seconds]
snsei has joined #crystal-lang
<livcd>
Papierkorb: huh imagine doing it in nim and providing them with the nim generated C++ code what would they say about that :X
faustinoaq has quit [Ping timeout: 240 seconds]
wontruefree has quit [Quit: The Internet needs a break and I need a cookie]
moei has joined #crystal-lang
relyks has joined #crystal-lang
mark_66 has quit [Remote host closed the connection]
<greenbigfrog>
How can I initialize a empty Set?
<FromGitter>
<xfbs> Something like `Set.new`?
<FromGitter>
<xfbs> Actually you'll likely have to do `Set(TypeName).new`, since the compiler can't infer the type if you don't provide any members, I think..
<greenbigfrog>
it's Set.new(Array(UInt64).new)
<greenbigfrog>
thanks... somehow I was failing at thinking (once again)
<greenbigfrog>
or not...
<greenbigfrog>
Set(UInt64).new also works... wtf was I doing earlier...
<FromGitter>
<xfbs> I think Set(TypeName).new is the cleanest way to do it, if you do Set.new(Array(TypeName).new) you'll construct an array just to throw it away again.
<greenbigfrog>
yep. somehow I thought I had tried the cleaner way before and it didn't work
<greenbigfrog>
Is there a reason for Set not having a `#sample`?
<FromGitter>
<xfbs> @greenbigfrog: I think there is no `#sample` because a `Set(T)` isn't `Indexable(T)`, meaning that it'd be non-trivial to return a random element. But I guess you could dig into the source and find out yourself if it's possible, and if it is, implement it
<greenbigfrog>
RX14: ping
wontruefree has quit [Client Quit]
mrShardy has joined #crystal-lang
<RX14>
no
<greenbigfrog>
RX14: ?
<RX14>
as in no, don't ping me
snsei has quit [Remote host closed the connection]
<greenbigfrog>
can you give me an answer to my question though rx 14?
relyks has quit [Quit: relyks]
mrShardy has quit [Ping timeout: 260 seconds]
wontruefree has joined #crystal-lang
wontruefree has quit [Read error: Connection reset by peer]
qard has joined #crystal-lang
qard has quit [Client Quit]
relyks has joined #crystal-lang
vivus has joined #crystal-lang
<FromGitter>
<asterite> because it's not there
<FromGitter>
<asterite> plus I don't know how one would implement it
<FromGitter>
<asterite> Many times the answer of "why isn't there X" is simply because no one did it or no one needed it
qard has joined #crystal-lang
snsei has joined #crystal-lang
<greenbigfrog>
ok. thanks :)
vivus has quit [Quit: Leaving]
<FromGitter>
<Fryguy> greenbigfrog: Ruby doesn't have Set#sample either, so I'm surprised you'd ask for it
<greenbigfrog>
hm. ok.
IamAuselessMetho has joined #crystal-lang
<IamAuselessMetho>
is there anywhere a list of all methods that are possible to call in the entire language?
<IamAuselessMetho>
that would it make it easier to search for a method you need
relyks has quit [Quit: relyks]
<FromGitter>
<xfbs> You have two choices: since ruby and crystal have a very similar API, you can start an interactive ruby session on your console of choice with `irb`, and for every object you can call `object.methods` to see what you can call on it. For example: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5a5f8eb1ba39a53f1a294280]
<FromGitter>
<xfbs> Alternatively, if you are on macOS, you can download Dash from https://kapeli.com/dash and load the crystal docset (I can give you a free license for an older version), which is a searchable documentation browser for pretty much all languages (also has rust, C, C++, java, ...)
<IamAuselessMetho>
i mean especially the methods that arent to binded to some object. like "require"
<IamAuselessMetho>
(im actually searching for some method that can load a cr file and run it in my program)
<FromGitter>
<xfbs> So in Ruby, all methods global methods are part of the Kernel module. For example:
<FromGitter>
<xfbs> You'll find that `puts`, `require`, `load`, and all those essential functions are defined in Kernel
<IamAuselessMetho>
ah alright thx
<IamAuselessMetho>
and where can I find methods like load in https://crystal-lang.org/api/0.24.1/ ? I searched for Kernel and Global but it was something else
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
qard has joined #crystal-lang
<FromGitter>
<asterite> IamAuselessMetho there's no "load" nor "require"
<FromGitter>
<asterite> There's require, but it's not a method, it's a keyword
<IamAuselessMetho>
wait wat. You cant run a cr file in your program?
<FromGitter>
<asterite> what do you need to do?
<FromGitter>
<xfbs> `require './otherfile'`
<FromGitter>
<asterite> "load" in Ruby reads a file and executes it... but Ruby is interpreted. You can't do that in Crystal. You can do `require`, though
<IamAuselessMetho>
but that cannot be used in for example a method or a loop or whatever, xfbs. just on top level
<FromGitter>
<xfbs> What exactly is it that you're trying to do?
<oprypin>
IamAuselessMetho, you are correct there, only top level. and in ruby if you did that people would be like ಠ_ಠ
<RX14>
IamAuselessMetho, why do you need to "run a cr file in your program"
<RX14>
what are you trying to accomplish?
<IamAuselessMetho>
i have this now: "macro eval(code) ; {{code.id}} ; end" and im trying to do this with this: "eval(gets)" to run code i type in the program in the program
<crystal-gh>
crystal/master bba4985 TSUYUSATO Kitsune: Use join instead of each_with_index and `if i > 0` (#5599)...
<IamAuselessMetho>
man! this eval method is useless then
<hmans>
IamAuselessMetho: Crystal is not Ruby
<IamAuselessMetho>
i know
<IamAuselessMetho>
why do you think i think crystal is ruby
<hmans>
Just a hunch. :b
<RX14>
IamAuselessMetho, it's impossible to interpret a string or file as crystal in crystal
<RX14>
that's ebcause crystal is a compiled language
Ven`` has joined #crystal-lang
<RX14>
*all* the crystal code needs to be known before it's run#
<IamAuselessMetho>
hmm.. but im actually trying to do something like the ICR shard. interactive crystal. i think i will look at the source
<RX14>
you can't
<RX14>
it's impossible
<IamAuselessMetho>
?!? and how did the devs of ICR did this?
<RX14>
icr is a hack
<RX14>
look at the readme
<IamAuselessMetho>
oooh..
<RX14>
every time you type a line in icr, it just appends the line to a file
<RX14>
and runs the WHOLE PROGRAM again
<hmans>
I'm guessing you can spawn a new process that compiles and runs Crystal, but... no
<RX14>
try doing x = Time.now in icr IamAuselessMetho
<RX14>
and then print x again and again
<RX14>
it'll chnage every time
<RX14>
hmans, yeah you can
<RX14>
but it doesn't have access to variables
<RX14>
or anything
<hmans>
Yeah
<hmans>
IamAuselessMetho: if your goal is to make your app scriptable in some fashion, maybe look at embedding a language designed for that purpose. I'm sure there's a Lua binding available for Crystal somewhere
<RX14>
or just consider a different language
<hmans>
Well, if his goal is to allow users to script the app, going the way of an embedded glue language isn't the worst choice. Probably better than eg. switching to Elixir (which can happily hot-compile and -swap Elixir code at runtime)
<crystal-gh>
crystal/master 84288b7 Ary Borenszweig: Compiler: add more locations (#5597)
qard has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
thi_ has joined #crystal-lang
Ven`` has joined #crystal-lang
cremes has quit [Quit: cremes]
<cptaffe>
How do I get crystal to deserialize a jsonb column into a type using JSON.mapping instead of throwing an error `PG::ResultSet#read returned a JSON::Any`
cremes has joined #crystal-lang
<FromGitter>
<watzon> Can anyone tell me why this (https://hastebin.com/lakolegine.rb) doesn't work? I want to do `HTTP::WebSocket.run` inside of a fiber so that it doesn't block, but when I do that I don't get any response
<RX14>
@watzon what's the empty loop do doing?
<RX14>
that'll just block the whole application
<RX14>
also why's there a Fiber.yield in your constructor?
cremes has quit [Quit: cremes]
<RX14>
@watzon you need to remove the Fiber.yield and replace the `loop do` with `sleep`
<RX14>
and I mean sleep with no arguments
cremes has joined #crystal-lang
qard has joined #crystal-lang
cremes has quit [Quit: cremes]
<FromGitter>
<watzon> This is why I need you RX14
<FromGitter>
<watzon> Thanks haha
<RX14>
Fiber.yield was just unneccesary
<RX14>
not... bad per se
<RX14>
sleep basically stops the current fiber forever
<RX14>
loop {} will run the current fiber forever
<RX14>
using 100% cpu
<RX14>
and just doing nothing
<FromGitter>
<watzon> I wasn't sure. The docs aren't super clear on the matter, but sleep was definitely what I needed
<FromGitter>
<Dillybob1992> hi =]
hightower4 has quit [Ping timeout: 240 seconds]
Yxhuvud has joined #crystal-lang
hightower4 has joined #crystal-lang
crystal-lang885 has joined #crystal-lang
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<crystal-lang885>
anyone here with experience setting up a docker container for crystal on windows 10?
LastWhisper____ has joined #crystal-lang
snsei has quit [Ping timeout: 255 seconds]
<FromGitter>
<watzon> crystal-lang885 not docker, but I've used WSL
<crystal-lang885>
what's WSL?
<oprypin>
Windows Subsystem for Linux
<FromGitter>
<Dillybob1992> im using it now, i love it
<crystal-lang885>
watzon: ah yes, Windows Subsystem for Linux. Did this too and it does work.
<crystal-lang885>
... but being able to use a docker image would be nice too :-)
<crystal-lang885>
but maybe i'm asking for too much
Ven`` has quit [Ping timeout: 260 seconds]
fifr[m] has joined #crystal-lang
Ven`` has joined #crystal-lang
<FromGitter>
<watzon> Ok another question, I've got this (https://hastebin.com/xiyimuxovu.rb) now and it works, however I think Channels may not be the right fit. Basically I want the send method to wait for a response and then return that response to the user. In Javascript I could use a promise, but a Channel seemed appropriate here. The only thing is I need to make sure send returns the right response which is based off of an ID
<FromGitter>
... included in the message
<FromGitter>
<watzon> Is there a way to do Channel.send with an id and then Channel.recieve(id)? Or is there another good solution?
<oprypin>
watzon, please never use hastebin (I say it's literally unreadable). https://bpaste.net/ is a better alternative if you want something simple, and it has Crystal
<FromGitter>
<watzon> Oh nice!
<oprypin>
gist.github.com and carc.in are the more known ones
<oprypin>
watzon, based solely on your message, not the code, you might want a new channel for each message
<oprypin>
though that defeats the point
<oprypin>
which leads me to believe you don't need channels at all
snsei has quit [Ping timeout: 265 seconds]
<oprypin>
I just want to know more about the use case, not the current attempt
<FromGitter>
<watzon> Right that's my though too
LastWhisper____ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter>
<watzon> The use case is just sending and receiving responses from a websocket. The websocket in question will eventually be a headless chrome instance. I just need an easy way to send a message, wait for the message to come back, and then make sure it's the right message by checking the id's against each other
<oprypin>
spawn a fiber for everything. no channels, as mentioned
<oprypin>
wait a second
<oprypin>
you have 1 websocket, you send 1 message on it and you receive 1 message on it - is that correct?
<FromGitter>
<watzon> I need to be able to check the id because not all responses from chrome are going to contain an id
<FromGitter>
<watzon> And for those I need to do something else
<oprypin>
watzon, i dunno, just do what they do, but the equivlent of promises is spawning a fiber with a "blocking" wait and then writing the followup action on the next line after it
<FromGitter>
<watzon> oprypin: If it's not too much to ask, do you have an example?
<FromGitter>
<watzon> I agree. It really needs to be reworked
<oprypin>
feel free to open an issue and quote me on that
<oprypin>
for now, your code is perfect
<oprypin>
not the one with spawn
<FromGitter>
<watzon> Right haha
<oprypin>
oh one thing. message.to_json.to_s - you're calling string.to_s
LastWhisper____ has joined #crystal-lang
snsei has quit [Ping timeout: 276 seconds]
<oprypin>
drop .to_s
moei has quit [Quit: Leaving...]
<FromGitter>
<watzon> Oh awesome haha
<FromGitter>
<watzon> I thought to_json returned JSON::Any
<FromGitter>
<watzon> Idk though. Does it make sense to have a websocket be synchronous? What if you send a request and no response comes back? Or it takes a long time?
<FromGitter>
<watzon> Timeouts?
<FromGitter>
<watzon> Or I guess that's what blocks are for haha
<oprypin>
sockets are "blocking" and i see no reason for websockets to be different
<FromGitter>
<Dillybob1992> spawn feels like Magic :D
<FromGitter>
<Dillybob1992> btw, is there a rate limiter module for crystal?
<oprypin>
there's no such thing as response, it's a two way pipe with no correspondence between the number of things sent and received
<FromGitter>
<watzon> Ahh right...
<oprypin>
or i could be horribly mistaken cuz i've never used websockets
<FromGitter>
<watzon> No you're right
<oprypin>
i've previously specified the ideal way in my example
maxpowa has quit [Ping timeout: 252 seconds]
<oprypin>
Dillybob1992, though in my mind a rate limiter is something that sleeps when you're doing too many attempts, not something that refuses to do the action
<oprypin>
with optional exponential backoff
<oprypin>
i guess that's the difference in thinking between when you're the server and when you're the client
<FromGitter>
<Dillybob1992> @oprypin i see. yeah, i want to eventually do something like no more than 5-10 msg's : second, if true, close socket
<oprypin>
the bigger problem is that it creates broen strings but ^
<crystal-gh>
[crystal] waj opened pull request #5601: Bug: default_verify_param are inverted in SSL::Context::Client and SSL::Context::Server (fixes #5266) (master...fix/5266-ssl-verify) https://git.io/vNRLR
<oprypin>
so yeah, it's not crystal version, just a "bad" file that you have :|
<jokke>
RX14: i tried reading files byte by byte and writing "Bytes[#{byte}_u8,...]" :P
<RX14>
ouch
<jokke>
but umm.. my memory didn't like that :D
<jokke>
at all
<RX14>
yeah...
snsei has quit [Ping timeout: 255 seconds]
<jokke>
but the issue i'm facing is fairly easy to fix
<jokke>
it's actually a one-byte diff :D
<FromGitter>
<watzon> Holy crap. I pasted that line into my editor and it froze my system lol
<FromGitter>
<watzon> That's a lot more text than I thought