RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.25.0 | Fund Crystal's development: http://is.gd/X7PRtI | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <confact> @RX14 How do I get Client's get method to use my method then?
wontruefree has joined #crystal-lang
<FromGitter> <aemadrid> @mjago thx! I’ll give that a try
<FromGitter> <constXife> Hi! How can I make a binding to this? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2c425a960fcd4eb9182405]
snsei has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
<FromGitter> <constXife> Probably it should look like that. Thank, I will try. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2c46535862c35f47bc963f]
wontruefree has quit [Quit: bye]
wontruefree has joined #crystal-lang
wontruefree has quit [Quit: bye]
wontruefree has joined #crystal-lang
zachk has quit [Quit: Leaving]
<FromGitter> <adamgotterer_twitter> I have a websocket server / client setup. I'm curious why the context on_close method (sent to HTTP::WebSocketHandler.new) can't detect a client disconnect? If the server hangs up my client knows the socket was closed. But it doesn't seem to work in the reverse. Any ideas how I can detect a client disconnect from the server?
wontruefree has quit [Read error: Connection reset by peer]
wontruefree has joined #crystal-lang
<FromGitter> <adamgotterer_twitter> Some code: https://gist.github.com/adamgotterer/2330b2dd05be28279b9dda0889ec8e91
wontruefree has quit [Quit: bye]
<FromGitter> <fridgerator> if there is an unexpected disconnect from the client, then the server doesn't know about it
<FromGitter> <fridgerator> you have to implement heartbeats and stuff like that
<FromGitter> <adamgotterer_twitter> That's unfortunate. Thanks.
<FromGitter> <fridgerator> thats not specific to crystal either
<FromGitter> <fridgerator> it works that way with websockets in any language
<FromGitter> <adamgotterer_twitter> Any suggestion for the best place to put a heartbeat?
<FromGitter> <adamgotterer_twitter> Should I throw it in a fiber once the session is created and every second send a PING?
<FromGitter> <adamgotterer_twitter> Btw, I didn't setup a heartbeat on the client side and it detects the hang up without issue
wontruefree has joined #crystal-lang
akaiiro has joined #crystal-lang
wontruefree has quit [Quit: bye]
wontruefree has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 245 seconds]
_whitelogger has joined #crystal-lang
<FromGitter> <faustinoaq> @S-YOU Oh, awesome! 🎉 Are those companies in this list (https://github.com/crystal-lang/crystal/wiki/Used-in-production)?
<FromGitter> <S-YOU> No, one is DMM. https://inside.dmm.com/entry/2018/05/30/crystal-lang
<FromGitter> <faustinoaq> BTW, would be possible to use `h2o.cr` as `HTTP::Server` replacement for crystal frameworks like Kemal/Amber/Raze/Lucky?
<FromGitter> <S-YOU> h2o run on its own eventloop, so it is kind of tricky with Fiber/Scheduler and GC
<FromGitter> <faustinoaq> @S-YOU Thanks for the link! 👍
<FromGitter> <faustinoaq> @S-YOU Oh, I see you disabled most crystal stdlib `-Dgc_none -D... -Dextreme` etc 😅
<FromGitter> <S-YOU> True, it is basically C
<FromGitter> <faustinoaq> Oh ok 😄 👍
<FromGitter> <faustinoaq> Still very impressive ✨
<FromGitter> <S-YOU> It is ok to turn on most of them, I just don't use any for C bindings.
<FromGitter> <S-YOU> There is little overhead on bound checks with exception handling, GC is okay to include as long as you don't trigger it.
<FromGitter> <S-YOU> Also it is very easy to see llvm-ir or assembly without them, because by default you get like 50k lines of LLVM-IR, but without them, it is like 500 lines.
<FromGitter> <faustinoaq> @S-YOU Well, we can try a immix GC as well: https://github.com/ysbaddaden/gc
<FromGitter> <S-YOU> Yeah, but within hot loop, triggering GC is not a good choice. h2o has its own mempool, which never return to system but can reuse, if there is a need to allocate.
<FromGitter> <faustinoaq> > Also it is very easy to see llvm-ir or assembly without them, because by default you get like 50k lines of LLVM-IR, but without them, it is like 500 lines, same level as C. ⏎ ⏎ Yeah, I saw your tweet, without stdlib, the LLVM-IR generated by crystal looks pretty clean 👍
<FromGitter> <faustinoaq> @S-YOU Yeah 👍
<FromGitter> <faustinoaq> Thank you for your collaboration with crystal community, very appreciated! 😄
<FromGitter> <S-YOU> I am very happy to meet with them :)
<FromGitter> <S-YOU> I met MakeNowJust in person too 😄 , showed as part of the crystal lexer, which I am trying to learn.
<FromGitter> <codenoid> i was success to solve my problem
<FromGitter> <codenoid> now how i can split 1 number into 3 number in array with random division
<FromGitter> <codenoid> i have x : 200, how to split x into list of number (in array) with random division ⏎ ⏎ example: ⏎ ⏎ ```1. [2,5,3] # x : 10 ⏎ 2. [7,1,2] # x : 10 ⏎ 3. [8,5,7] # x : 20``` [https://gitter.im/crystal-lang/crystal?at=5b2c70640168e70c08e27bc0]
<FromGitter> <Daniel-Worrall> @codenoid here's some bad code https://carc.in/#/r/4cic
<FromGitter> <Daniel-Worrall> https://carc.in/#/r/4cid or I could not do pointless allocations
<FromGitter> <codenoid> thank you so much @Daniel-Worrall
<FromGitter> <Daniel-Worrall> as long as it's not homewokr
<FromGitter> <codenoid> i was think about ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ but it's more complicated [https://gitter.im/crystal-lang/crystal?at=5b2c7abc7d3bca737affba7c]
<FromGitter> <codenoid> part of learning/wJob xD
<FromGitter> <Daniel-Worrall> rand(int) gives an int 0->(int-1)
<FromGitter> <Daniel-Worrall> so you just add your starting value
<z64> @Daniel-Worrall OOB if you're lucky :) https://carc.in/#/r/4cie
<FromGitter> <Daniel-Worrall> yeah, I called it bad code for a reason >_>
<z64> and i think you would want to use Array.new(size, &block) for this
<FromGitter> <Daniel-Worrall> fixed the bounds issue
<FromGitter> <Daniel-Worrall> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2c7f4059799e7017371da8]
rohitpaulk has joined #crystal-lang
<FromGitter> <Daniel-Worrall> bad code -> less bad code
<FromGitter> <Daniel-Worrall> @codenoid if you're actually going to use my bad code, use this one ^
<FromGitter> <codenoid> thank you @Daniel-Worrall
moei has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 276 seconds]
rohitpaulk has joined #crystal-lang
DTZUZO has joined #crystal-lang
<FromGitter> <codenoid> hi
<FromGitter> <codenoid> (4, 341) -> [87, 93, 62, 35] # total 277
<crystal-gh> [crystal] Daniel-Worrall opened pull request #6240: Fix HTTP::Server example in Playground About (master...bug-fix/playground-about) https://git.io/f87sO
<FromGitter> <Daniel-Worrall> ah
<FromGitter> <Daniel-Worrall> change it to splits - 1
<FromGitter> <Daniel-Worrall> on the `n == splits `
<FromGitter> <codenoid> done
<FromGitter> <Daniel-Worrall> you know what, that doesn't work either
<FromGitter> <Daniel-Worrall> I just have broken code and that's all there is to it
<FromGitter> <Daniel-Worrall> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b2c9af2d2abe466887eea80]
<crystal-gh> [crystal] Daniel-Worrall closed pull request #6240: Fix HTTP::Server example in Playground About (master...bug-fix/playground-about) https://git.io/f87sO
Ven`` has joined #crystal-lang