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
dwdv has quit [Ping timeout: 268 seconds]
HumanG33k has quit [Quit: Leaving]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Creatornator has joined #crystal-lang
f1reflyylmao has joined #crystal-lang
f1refly has quit [Ping timeout: 252 seconds]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ur5us has quit [Ping timeout: 250 seconds]
return0e has quit [Ping timeout: 250 seconds]
return0e has joined #crystal-lang
Creatornator has joined #crystal-lang
<FromGitter> <johnpyp> Is there a way to set an index outside the bounds of an array, filling the intermediate values with a default value?
yukai has quit [Ping timeout: 265 seconds]
yukai has joined #crystal-lang
<FromGitter> <Daniel-Worrall> I can think of an easy way to make a new array with that
_whitelogger has joined #crystal-lang
ht_ has joined #crystal-lang
<livcd> tenebrousedge: that looks awesome
DTZUZO has quit [Ping timeout: 240 seconds]
DTZUZO has joined #crystal-lang
ht_ has quit [Remote host closed the connection]
ur5us has joined #crystal-lang
ur5us_ has joined #crystal-lang
yukai has quit [Ping timeout: 265 seconds]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ur5us has quit [Ping timeout: 246 seconds]
<FromGitter> <yxhuvud> @johnpyp someone is doing aoc I see :)
ur5us__ has joined #crystal-lang
ur5us_ has quit [Ping timeout: 245 seconds]
<foxxx0> is there a way to see how many values are left in channel?
<FromGitter> <lbarasti> From the top of my head, @foxxx0 not in the Channel's public API, that I know of.
<FromGitter> <lbarasti> Looking at the implementation of Channel, you might find some hacky way of exposing that information, though
<FromGitter> <lbarasti> Right, there is an instance variable of type `Deque` called `@queue` that holds the received values until they are processed
<FromGitter> <lbarasti> It's private - and that makes sense because you don't want people to fiddle with it
<FromGitter> <lbarasti> You might also want to look into the `@senders` Deque, which lists all the sender's waiting for a spot in the `@queue` to free up
<foxxx0> currently i'm only spawning a single fiber but i don't know how much it will send back
<foxxx0> so i don't know how many times i have to call #receive in the parent
<FromGitter> <lbarasti> I see. You will often see the following pattern to consume from a channel
<FromGitter> <lbarasti> ``````
<livcd> Are there any benchmarks for parallelism against Go ?
<FromGitter> <lbarasti> this is because typically the number of values that will be sent through cannot be known - think of a web app, for example, or an interactive terminal app
<repo> foxxx0: no there's not
<repo> FromGitter: but you can close the channel
<FromGitter> repo, I'm a bot, *bleep, bloop*. I relay messages between here and https://gitter.im/crystal-lang/crystal
<repo> äh
<repo> foxxx0:
<repo> and then use #receive?
<repo> or use another channel to signal that the thread(s) have finished
ur5us has joined #crystal-lang
ur5us__ has quit [Read error: Connection reset by peer]
<foxxx0> repo: i don't see how this would help. i still don't know how many items are left in the output channel of the finished fiber
<foxxx0> and when i call "receive" one too many times, that call will be blocking and deadlock the program
ur5us has quit [Ping timeout: 250 seconds]
<repo> i think this is a x y problem
<repo> what you do need to know is if there's further output to be expected
<repo> by having a status channel which every fiber sends something to when they finish
<repo> then you just NUM_THREADS.times { status.receive }
<repo> and close the output channel
dwdv has joined #crystal-lang
<foxxx0> no
<foxxx0> i only have ONE fiber
<foxxx0> but i don't know how many times that fiber calls #send
<foxxx0> so it doesn't help knowing when that fiber has finished
<repo> sure it does. that way you know when you can close the channel
<repo> and thus unblocking all receive calls on the channel
_whitelogger has joined #crystal-lang
<FromGitter> <lbarasti> @foxxx0, let the producer fiber signal that it is done sending values by calling `Channel#close`on the channel
ternarysolo has quit [Quit: killed]
tleydxdy has quit [Quit: killed]
beepdog has quit [Quit: killed]
erdnaxeli has quit [Quit: killed]
olbat[m] has quit [Quit: killed]
<FromGitter> <lbarasti> the loop above becomes something like ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5dee1f1c1e0b827cc8ca6388]
<foxxx0> i've worked around it by not only returning the fiber's id on the control channel but instead returning a Tuple(Int32, Int32) with {@id, @sent_items} so i know how many #receive calls i need to make
<FromGitter> <lbarasti> cool, mind that relying on `.close` has the upside that the closure will be broadcast to all the receiving fibers
<FromGitter> <lbarasti> in case you have multiple workers reading from a single channel
<foxxx0> good to know, thanks
<foxxx0> can i still #receive the queued elements from a closed channel?
<foxxx0> i would expect it to raise the closedchannel exception when i try to #receive on a closed channel when *no* elements are left in the queue
<FromGitter> <firejox> If the channel has buffer, it can receive data until the buffer empty.
<foxxx0> and on another attemt at #receive it raises Channel::ClosedError
<foxxx0> thanks!
<FromGitter> <lbarasti> yes, exactly
DTZUZO has quit [Ping timeout: 268 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 252 seconds]
tleydxdy has joined #crystal-lang
ternarysolo has joined #crystal-lang
beepdog has joined #crystal-lang
olbat[m] has joined #crystal-lang
erdnaxeli 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: 250 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 240 seconds]
DTZUZO has joined #crystal-lang
Nekka has quit [Ping timeout: 265 seconds]
Nekka_ has joined #crystal-lang
Nekka_ is now known as Nekka
return0__ has joined #crystal-lang
return0e has quit [Ping timeout: 240 seconds]
DTZUZO has quit [Ping timeout: 240 seconds]
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 265 seconds]
Human_G33k has joined #crystal-lang
DTZUZO has joined #crystal-lang
Human_G33k has quit [Remote host closed the connection]
Human_G33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 268 seconds]
DTZUZO has quit [Read error: Connection reset by peer]
DTZUZO_ has joined #crystal-lang
DTZUZO_ has quit [Ping timeout: 245 seconds]
return0e has joined #crystal-lang
return0__ has quit [Ping timeout: 265 seconds]
duane has quit [Ping timeout: 250 seconds]
duane has joined #crystal-lang
<FromGitter> <manveru> is there a way to manually create an instance of a class that uses `JSON.mapping` without having to generate the JSON first?
<FromGitter> <Blacksmoke16> define another initializer
<FromGitter> <Blacksmoke16> could just be `def initialize; end`
<FromGitter> <manveru> ah, ok
<FromGitter> <Blacksmoke16> 👍
DTZUZO_ has joined #crystal-lang
DTZUZO_ has quit [Ping timeout: 240 seconds]
DTZUZO_ has joined #crystal-lang
DTZUZO_ has quit [Ping timeout: 268 seconds]
Creatornator has joined #crystal-lang
DTZUZO_ has joined #crystal-lang
DTZUZO_ has quit [Ping timeout: 276 seconds]
flaviodesousa has joined #crystal-lang
Human_G33k has quit [Remote host closed the connection]
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
flaviodesousa has quit [Quit: KVIrc 4.9.3 Aria http://www.kvirc.net/]
Creatornator has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
ht_ has joined #crystal-lang
Creatornator has joined #crystal-lang
Creatornator has quit [Client Quit]
<FromGitter> <manveru> is there a way to use the `parallel` macro over an array?
<FromGitter> <manveru> like `parallel(tasks.map(&.heavy_lifting))`
<FromGitter> <Blacksmoke16> it would prob be easier to just implement what that method does on your own
<FromGitter> <manveru> yeah, i did that in the past, but just found that macro :)
<FromGitter> <Blacksmoke16> it would work if you have a tuple
<FromGitter> <Blacksmoke16> or just define your own method that accepts an array
<FromGitter> <watzon> So apparently `clone` doesn't actually clone a String or Slice?
<FromGitter> <watzon> It seems like it still references the same memory
<FromGitter> <watzon> Lol yep
duane has quit [Ping timeout: 252 seconds]
<FromGitter> <watzon> So I guess if you really want a clone of a string and not the same string you need to do `str[0..-1]`
<FromGitter> <tenebrousedge> huh
<FromGitter> <tenebrousedge> I wonder why that is
<FromGitter> <tenebrousedge> > But I'm not sure. Some types are immutable and dup and clone should just return self. Others are mutable but are not meant to be cloned, though in generic code you might invoke clone on a series of objects and you'd want that to work.
<FromGitter> <watzon> Thanks for the link. Commented on that issue. It looks like maybe String just got missed.
<FromGitter> <watzon> I don't think `String#[range : Range]` actually copies either. I think it just returns a reference to that same memory
<FromGitter> <watzon> Damn it, I just want an easy way to allocate a new String, with a completely new Pointer, from another String
<FromGitter> <Blacksmoke16> would like `String.new str.to_unsafe` do it?
<FromGitter> <watzon> I don't think String.new actually copies the pointer
<FromGitter> <watzon> Pretty sure it references the same memory
<FromGitter> <watzon> `str.to_unsafe.clone` works for getting a unique pointer, but for some reason passing that into a C method fails unless I access it beforehand
<FromGitter> <watzon> Like with a `puts the_clone`
<FromGitter> <watzon> For instance ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5deea18b26eeb8518f935e27]
<FromGitter> <watzon> The former throws `Invalid memory access (signal 11) at address 0x0`
<FromGitter> <watzon> Maybe @asterite or @straight-shoota knows what's going on here? Definitely not the first time I've seen it.
<FromGitter> <watzon> This works. I hate it, but it works ⏎ ⏎ ```key = Pointer(UInt8).malloc(@key.bytesize) { |i| @key.bytes[i] }``` [https://gitter.im/crystal-lang/crystal?at=5deea422b065c6433c69bb23]
<FromGitter> <tenebrousedge> :/
<hightower3> watzon did you solve your fibers-blocking issue from the other day?
<hightower3> (if yes, what was the solution)
<FromGitter> <watzon> Kinda, I basically just wrapped the whole block in a `Concurrent::Future` block and returned a future
<FromGitter> <watzon> Not what I want though
duane has joined #crystal-lang
ur5us has joined #crystal-lang
<FromGitter> <kinxer> @watzon https://carc.in/#/r/869e
<FromGitter> <kinxer> Not many good options.
kevinsjoberg has left #crystal-lang ["Textual IRC Client: www.textualapp.com"]
<FromGitter> <wontruefree> We were super excited to host @asterite at Chicago Crystal. People who attended loved the talk and hope people here will too https://youtu.be/5rpZOtcCHtk
<FromGitter> <igor-alexandrov> @wontruefree thank you!
<FromGitter> <wontruefree> you are welcome
<FromGitter> <wontruefree> it was a really good talk
<FromGitter> <wontruefree> I am going to watch it again after work
sagax has joined #crystal-lang
<hightower3> so cool!
<FromGitter> <lbarasti> I'm 30 minutes in and have already learned loads!
Creatornator has joined #crystal-lang
<FromGitter> <wontruefree> I know right
<FromGitter> <wontruefree> it is really good
<FromGitter> <wontruefree> I sent it to some friends of mine that program in python
DTZUZO_ has joined #crystal-lang
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <kingsleyh> @lbarasti hey there :)
dwdv has quit [Quit: quit]
<hightower3> Haha in the talk Ary says "Everything can be solved with time, effort, and patience".
<hightower3> yeah, just those three, no biggie :)
<FromGitter> <wontruefree> hahaha
<FromGitter> <wontruefree> yep
Creatornator has joined #crystal-lang
<FromGitter> <asterite> @watzon cloning a pointer is just returning itself. Maybe we should remove `clone` from that type
<FromGitter> <watzon> Maybe. It would be nice to have a simple way to duplicate a pointer though. When I'm wrapping a C library that modifies a buffer, but I want a nicer interface where it actually returns a value and doesn't modify the original I find myself needing that a lot
<FromGitter> <lbarasti> @kingsleyh 👋
ht_ has quit [Remote host closed the connection]
<FromGitter> <daya> hi are there any shards that can help with ADFS (SAML 2.0) integration for SSO?
<FromGitter> <watzon> @daya doesn't seem to be currently
yukai has joined #crystal-lang
<FromGitter> <watzon> Iirc there was a library that was attempting to be kind of like Passport in the NodeJS space, but for Crystal
<FromGitter> <watzon> But I can't remember what it was called
<FromGitter> <watzon> This (https://github.com/randomstate/auth) was trying, but it looks like development has stalled
<FromGitter> <watzon> Hmm looks like the TCPSocket docs are out of sync
<FromGitter> <watzon> `#new` methods are wrong
<FromGitter> <wontruefree> acknowledged
Creatornator has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]