ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.31.1 | 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
woodruffw has quit [Ping timeout: 268 seconds]
woodruffw has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 246 seconds]
woodruffw has quit [Ping timeout: 240 seconds]
woodruffw has joined #crystal-lang
woodruffw has quit [Ping timeout: 276 seconds]
woodruffw has joined #crystal-lang
woodruffw has quit [Ping timeout: 240 seconds]
Nekka has quit [Read error: Connection reset by peer]
woodruffw has joined #crystal-lang
Nekka has joined #crystal-lang
hightower4 has quit [Ping timeout: 268 seconds]
woodruffw has quit [Ping timeout: 240 seconds]
woodruffw has joined #crystal-lang
rocx has joined #crystal-lang
f1refly has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 240 seconds]
_whitelogger has joined #crystal-lang
rohitpaulk has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> hi
_whitelogger has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
woodruffw has quit [Ping timeout: 240 seconds]
woodruffw has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
_whitelogger has joined #crystal-lang
<FromGitter> <ImAHopelessDev_gitlab> YES finally got my stash system working on the server. thank goodness for classes and hashes baby. SOOOOOOO powerful
ht_ has joined #crystal-lang
DTZUZO has quit [Ping timeout: 276 seconds]
tdc has quit [Quit: Leaving]
<FromGitter> <watzon> Has anyone seen about getting forum.crystal-lang.org added to Tapatalk? @asterite?
<FromGitter> <fizvlad> Have anyone converted reference at https://crystal-lang.org/reference/ into PDF?
<FromGitter> <fizvlad> > (https://files.gitter.im/crystal-lang/crystal/ur1l/crystal-book.pdf) ⏎ ⏎ Found it. Hope it didn't change much
livcd has quit [Quit: Lost terminal]
alexherbo2 has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <fizvlad> I've tried to create PDF version of gitbook myself but encountered lot of template errors, so I simply removed few pages which were causing errors lol
hightower3 has joined #crystal-lang
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 276 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 268 seconds]
<hightower3> Why are there no specific methods to make Colorize::ColorRGB convert to/from tuples easily?
DTZUZO has joined #crystal-lang
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
DTZUZO has quit [Ping timeout: 265 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 265 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 265 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 268 seconds]
f1refly has quit [Ping timeout: 245 seconds]
DTZUZO has joined #crystal-lang
livcd has joined #crystal-lang
f1refly has joined #crystal-lang
f1refly has quit [Ping timeout: 252 seconds]
f1refly has joined #crystal-lang
f1refly has quit [Ping timeout: 240 seconds]
f1refly has joined #crystal-lang
f1refly has quit [Ping timeout: 265 seconds]
f1refly has joined #crystal-lang
f1refly has quit [Ping timeout: 252 seconds]
f1refly has joined #crystal-lang
f1refly has quit [Ping timeout: 245 seconds]
f1refly has joined #crystal-lang
f1refly has quit [Ping timeout: 265 seconds]
f1refly has joined #crystal-lang
<FromGitter> <Blacksmoke16> couldn't you just do like `Colorize::ColorRGB.new *tuple`?
woodruffw has quit [Ping timeout: 268 seconds]
woodruffw has joined #crystal-lang
woodruffw has quit [Ping timeout: 268 seconds]
woodruffw has joined #crystal-lang
<hightower3> well yeah, suppose that'd work. But I also didn't find options to convert the values to a tuple...
<hightower3> is there anything more elegant than {rgb.red,rgb.green,rgb.blue} ?
<FromGitter> <tenebrousedge> where are your values coming from?
<hightower3> I have code which manipulates rgb values using tuples exclusively. I'm trying to see if I could use more of Crystal's ColorRGB objects
<hightower3> but I suppose it doesn't really matter since they don't offer any particularly useful methods on them... so I've just done it so that I can accept ColorRGB as input to my functions, and that's it
<FromGitter> <tenebrousedge> they're just structs
<hightower3> yeah
* FromGitter * tenebrousedge shrugs
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
alexherbo2 has joined #crystal-lang
dannyAAM has joined #crystal-lang
<hightower3> Hey I have a socket, and IO::Memory with already constructed binary data in the desired endianness. What's the best way to directly write that content into the socket?
<FromGitter> <ilanpillemer> this seems wrong to me
<FromGitter> <ilanpillemer> surely if you rotate
<FromGitter> <ilanpillemer> `['e', 'c', 'a', 'b', 'd’]`
<FromGitter> <ilanpillemer> 6 times
<FromGitter> <ilanpillemer> you should get
<FromGitter> <ilanpillemer> `decab`?
<FromGitter> <ilanpillemer> not
<FromGitter> <ilanpillemer> `cabde`?
<hightower3> Shouldn't File::Info had a convenience method #socket? ?
<hightower3> have*
<FromGitter> <christopherzimmerman> @ilanpillemer you’re thinking of rotating the other direction.
<FromGitter> <christopherzimmerman> Loop through and print out a rotation at a time
<FromGitter> <ilanpillemer> it rotates left by default?
mistergibson has joined #crystal-lang
<hightower3> Eh what was that trick to get a proc from a method?
<FromGitter> <ilanpillemer> yup.. thats it.
<FromGitter> <ilanpillemer> documentation should probably say that I suppose
<FromGitter> <Blacksmoke16> `->method`
<hightower3> ++!
<FromGitter> <ilanpillemer> probably implemented by someone who drives on the wrong side of the road!
<FromGitter> <bajro17> can someone tell me what is best shard for web scrapping?
<FromGitter> <Blacksmoke16> @watzon has one iirc
<FromGitter> <bajro17> I find arachnid
<FromGitter> <bajro17> Thank you @Blacksmoke16
<FromGitter> <bajro17> I try to get big project to make it in crystal for client
<FromGitter> <bajro17> I hope I will have support from community :)
<FromGitter> <watzon> Yep I have the only one I know of so far in the Crystalverse
<FromGitter> <watzon> If you have any questions feel free to ask here. I haven't touched it in a few months.
<FromGitter> <bajro17> No problem if I find any problems I can make issue on github also we can stay in touch here
<FromGitter> <watzon> Perfect. Issues will get my attention pretty quickly
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <watzon> You know, when coming back to Crystal after coding in Python for a while there are two things I find myself missing. Explicit imports, and list comprehensions.
<FromGitter> <watzon> Especially the list comprehensions. Those are nice.
alexherbo2 has joined #crystal-lang
alexherbo2 is now known as alex```
Nekka has quit [Quit: zzz]
<FromGitter> <lbarasti> On modules variables and type inference ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ fails at compile-time with `Error: can't infer the type of class variable '@@n' of A` - see https://play.crystal-lang.org/#/r/7zlm ... [https://gitter.im/crystal-lang/crystal?at=5dc7326752b73c7cb2ec1d74]
Nekka has joined #crystal-lang
Nekka has quit [Client Quit]
Nekka has joined #crystal-lang
<raz> i never understood what people like about python's list comprehensions. i find ruby & crystal's map, collect, etc. so much more intuitive.
<FromGitter> <tenebrousedge> that's weird as heck @lbarasti
<FromGitter> <watzon> Map is really nice, but I find list comprehensions better sometimes
<FromGitter> <tenebrousedge> @lbarasti there seems to be an open issue https://github.com/crystal-lang/crystal/issues/4066
<FromGitter> <tenebrousedge> `include` works, sort of https://play.crystal-lang.org/#/r/7zmt
<FromGitter> <lbarasti> Yes @tenebrousedge, crystal-lang/crystal#4066 looks like *the one*
<FromGitter> <DRVTiny> Hello4all! ⏎ Does anybody knows, why empty? method was removed from Channel core class and why this change was not metnioned in Changelog, so i don't know, to look at comment for the commit, where empty? was removed ?
<FromGitter> <lbarasti> > `include` works, sort of https://play.crystal-lang.org/#/r/7zmt ⏎ ⏎ I guess that grants you access to the module variable, but not to the `n` method itself?
<FromGitter> <lbarasti> a long-winded workaround: https://play.crystal-lang.org/#/r/7zmw
<FromGitter> <watzon> I didn't know `Channel` ever had an `empty?` attribute
<FromGitter> <DRVTiny> @watzon ⏎ ⏎ 1) 23.1/src/concurrent/channel.cr: ⏎ ⏎ ``` def empty? ⏎ @queue.empty? ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5dc737b2091dd14a0e8fd18d]
DTZUZO has quit [Ping timeout: 268 seconds]
<FromGitter> <watzon> Damn that is an old ass release
<FromGitter> <tenebrousedge> @lbarasti if it works, I guess that's what you have to use :/ I'll file that one away for when I need it next
<FromGitter> <Daniel-Worrall> They had `#empty?` on `Channel::Buffered` and `Channel::Unbuffered` which were removed
<FromGitter> <lbarasti> @tenebrousedge I commented on the issue, too 👍
<FromGitter> <tenebrousedge> thank you!
<FromGitter> <watzon> That was over 2 years ago now though. Channel isn't even defined in the same file anymore. It's now `src/channel.cr`
<FromGitter> <DRVTiny> @Daniel-Worrall but why? :) ⏎ For example, i have to inject this method again to the Channel, so cr-dns, the only DNS library for Crystal, can work. ⏎ And i think there are good reasons to have, for example receive_nb method to receive value only it it was actually sended on the other side of the Channel. Author of cr-dns uses empty? to implement this logic.
<FromGitter> <lbarasti> @watzon would be great to have like a mega banner on the API pages whenever you're not looking at the latest version? Akka does
<FromGitter> <watzon> Agreed. Docs are just lacking in general imo.
<FromGitter> <watzon> It looks like Channel was refactored pretty recently though. They must've forgot to mention that `empty?` got removed.
<FromGitter> <lbarasti> @DRVTiny but how good would `empty?` be really, in a soon-to-be multi-threaded world?
<FromGitter> <Daniel-Worrall> Seems it was removed in the `MT` PR. Either the removal was unintentional, or the mention of removing it was.
<FromGitter> <Daniel-Worrall> (lack of mention)
<FromGitter> <DRVTiny> @lbarasti there many non-blocking I/O method in modern multithreaded world :) In some cases methodology "spawn new fibers in all unclear situations" - is not comfort, so non-blocking I/O which not yield's from fiber to event loop is more suitable
<FromGitter> <Daniel-Worrall> Can you give a usage example of `empty?`
<FromGitter> <lbarasti> @DRVTiny what I meant is, checking for emptiness is a bit flaky, as making decisions based on that might lead to race conditions
<FromGitter> <DRVTiny> @Daniel-Worrall ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc73e22c26e8923c4f7364f]
<FromGitter> <lbarasti> for example here: https://github.com/teknomunk/cr-dns/blob/a262e16d1213c55bc6463a999df55fa141409570/src/dns/server.cr#L46 ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ There is no guarantee that `request_channel` will be non-empty when the fiber gets to call `request_channel.receive`, unless you're assuming the program runs on a single thread - which is true right now, but won't be true in the future
<FromGitter> <DRVTiny> @lbarasti Yes, it is true. So i think for this cases thread-safe receive_non_block may be implemented
mps has left #crystal-lang [#crystal-lang]
<FromGitter> <lbarasti> You should be able to rewrite the whole thing with a `select` statement, but there is not much documentation available, ATM. ⏎ I suggest you have a look at the tests for `select`, they are quite extensive: https://github.com/crystal-lang/crystal/blob/master/spec/std/concurrent/select_spec.cr#L87
<FromGitter> <Blacksmoke16> iirc it works very similar/the same to how it does in go
<FromGitter> <j8r> Don't use empty? for channels
<FromGitter> <j8r> it was a bad feature, thus removed
<FromGitter> <j8r> you can count how many fibers are spawn
<FromGitter> <DRVTiny> @lbarasti Thank you! i'll try to understand how select works and what is intended for. I'm not very familar with Crystal but i need DNS library that works on 0.31.x, so i have no choice :)
<FromGitter> <j8r> then receive X times
<FromGitter> <j8r> cc @DRVTiny
<FromGitter> <DRVTiny> @j8r what about fiber that must send something but raises exception and dont send anything. 10 fibers were spawned, i'll wait for 10 values, but fibers "forgot" to send its values. What to do next?
<FromGitter> <j8r> you can rescue the exception
<FromGitter> <Blacksmoke16> do like in the spec prob ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc7416e35889012b1dd355e]
<FromGitter> <j8r> and send something else, or close the channel
<FromGitter> <j8r> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5dc741c1091dd14a0e901433]
<FromGitter> <DRVTiny> @Blacksmoke16 things stand more complex if code of that fibers is not my code, fibers spawned inside the shard i use :( Unfortunately many shards, not only cr-dns, written in a very "tricky"/dilettantish manner.
<FromGitter> <Daniel-Worrall> Well, they just need to be reworked and there's no avoiding that
<FromGitter> <j8r> propose a PR that exposes a counter, or a similar feature
<FromGitter> <j8r> @Daniel-Worrall 💯
<FromGitter> <DRVTiny> Fibers may not send value to channel because of mistake in its algorithm: some if branch will not be fired in some rare cases, for example. No exception and no value in the Channel. But receiver will wait it forever.
<FromGitter> <didactic-drunk> You either 1) Tell it to wait and it waits 2) Have a timeout.
<FromGitter> <Blacksmoke16> thats what specs are for
<FromGitter> <lbarasti> I found this on reddit the other day, a crystal implementation of wait group: https://github.com/jasonrobot/crystal-wait-group ⏎ Might help @DRVTiny. Basically, you make sure you count down on the wait group every time a fiber terminates - you could put that in the `ensure` block so that the code will be executed even in case of exception
<FromGitter> <DRVTiny> @lbarasti Oh, it's very similar AnyEvent's $condvar->begin, $condvar->end, $condvar->receive in Perl. Very (help|use)ful shard!
<FromGitter> <didactic-drunk> A count down latch (https://didactic-drunk.github.io/concurrent.cr/Concurrent/CountDownLatch.html) and wait group are almost identical.
<FromGitter> <didactic-drunk> The latch works with -Dpreview_mt and uses an atomic int. It should be much faster than the wait group implementation.
alex``` has quit [Quit: The Lounge - https://thelounge.chat]
<FromGitter> <lbarasti> @didactic-drunk really good to know, thanks
DTZUZO has joined #crystal-lang