ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.33.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
_whitelogger has joined #crystal-lang
postmodern has quit [Read error: Connection reset by peer]
postmodern has joined #crystal-lang
cloaked1 has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
return0e has joined #crystal-lang
return0e_ has quit [Ping timeout: 240 seconds]
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 250 seconds]
_whitelogger has joined #crystal-lang
juanfra_ has quit [Ping timeout: 260 seconds]
ur5us has joined #crystal-lang
juanfra_ has joined #crystal-lang
<watzon> Well I must be a glutton for punishment. I'm taking on another fairly large project.
<watzon> One shard down, many more to go
<FromGitter> <naqvis> @watzon on fire 🔥 👍 . Watched your youtube videos 👍
_ht has joined #crystal-lang
HumanGeek has joined #crystal-lang
Human_G33k has quit [Ping timeout: 250 seconds]
<watzon> 😁
ur5us has quit [Ping timeout: 246 seconds]
<FromGitter> <j8r> watzin does it feature screen width detection?
<FromGitter> <j8r> and better use `\033[`, more portable
<watzon> That's coming tomorrow in another shard
<FromGitter> <j8r> Ideas can be taken from https://github.com/j8r/cride
<watzon> Right now I'm actually doing a direct port of a collection of Ruby gems and adapting them to Crystal, but I'm definitely open to suggestions and PRs if things could be done in a more portable way
<FromGitter> <j8r> to get the terminal width and height
<FromGitter> <j8r> changing the size dynamically is another challenge
_ht has quit [Quit: _ht]
<FromGitter> <pynixwang> hello,
<FromGitter> <pynixwang> how to debug c++ library with crystal.
<FromGitter> <stronny> not sure what you mean
<FromGitter> <pynixwang> I get some mangling symbol like this
<FromGitter> <pynixwang> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e74b14c54f26e12b52d7ee6]
<FromGitter> <pynixwang> I have link to debug version lib
<FromGitter> <pynixwang> but no c++ symbol
<FromGitter> <pynixwang> also mangling symbol.
<FromGitter> <stronny> can't tell you anything certain, but I guess Crystal won't help here
<FromGitter> <stronny> how would you do that in C? what does gdb say?
<FromGitter> <pynixwang> I will try lldb
<FromGitter> <pynixwang> lldb ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e74b33d7f9d323a02c9affa]
<FromGitter> <pynixwang> memmov
<FromGitter> <pynixwang> maye null reference
<FromGitter> <pynixwang> this is a c runtime error
<FromGitter> <pynixwang> libsystem_platform
<FromGitter> <pynixwang> macos c runtime?
<FromGitter> <naqvis> looks like a seg fault, you better share crystal C interface (you imported) as well as how you are calling that. More likely problem happening on how you are passing values to FFI
<FromGitter> <stronny> `address=0x0` is this just a null pointer?
postmodern has quit [Quit: Leaving]
<coderobe> Hey, how would i check whether a TCPSocket is still connected? `.closed?` always returns false.
<FromGitter> <stronny> what do you mean connected?
<FromGitter> <pynixwang> it qt5.cr
<FromGitter> <pynixwang> generate from qt c++ codebase
<FromGitter> <pynixwang> so too many c++ symbol
<FromGitter> <pynixwang> it hard to debug
<FromGitter> <pynixwang> interface file it too large
<FromGitter> <pynixwang> 5 MB
<FromGitter> <pynixwang> this
<coderobe> stronny: as in, the other end of the socket hasn't gone away yet..
<FromGitter> <pynixwang> `compute_kernel_digest` looks like GL operation.
<FromGitter> <stronny> basically there is no way to "check" it
<coderobe> if i netcat to a TCPServer and keep doing `puts client.closed?` in a fiber i pass the client IO to, it will keep printing `false` forever, even when my netcat side goes away
<FromGitter> <stronny> what you do is rescue exceptions that arise when the other side does go away
<coderobe> There are no exceptions thrown.
<coderobe> My issue is that i have literally no way to find out whether the other end is dead
<FromGitter> <stronny> yes
<FromGitter> <stronny> that's the sockets API for you
<FromGitter> <stronny> you may try TCP keepalives
<FromGitter> <stronny> you may invent some form of line control at L7
<coderobe> read/write will just block for eternity (unless i set a timeout, but a r/w timeout doesn't tell me whether the other end just hasn't sent or processed any data, or whether the connection is gone)
<coderobe> i should get an Errno from this...
<FromGitter> <stronny> are you developing a network daemon?
<coderobe> a tcp proxy.
<FromGitter> <pynixwang> about macos CoreImage
<FromGitter> <stronny> in my opinion Crystal is not your friend in these cases
<FromGitter> <stronny> try pony!
<coderobe> ...
<FromGitter> <stronny> but to answer you question directly TCP has no way to know if the connection is still okay
<FromGitter> <stronny> no language could do that
<FromGitter> <stronny> set a timeout on read
<FromGitter> <stronny> I mean what do you want from kernel? How does it know why there are no packets for a port?
<coderobe> ... because the connection got a RST?
<coderobe> i'm not literally unplugging the ethernet cable
<FromGitter> <stronny> you'll get an exception on RST and FIN
<FromGitter> <stronny> or a nil, depends
<FromGitter> <stronny> or even an empty string? I don't remember off the top of my head sorry
<FromGitter> <wout> Why doesn't `BigDecimal` have a `from_json` method? Is there a specific reason, or kjust not implemented yet?
<FromGitter> <Blacksmoke16> i think you need to do `require "big/json"`
<FromGitter> <wout> Aaah...
<FromGitter> <wout> You're right. Thanks! I've been using a converter all this time. 😂️
travis-ci has joined #crystal-lang
travis-ci has left #crystal-lang [#crystal-lang]
<travis-ci> crystal-lang/crystal#aee6cee (master - Optimized Implementation of `Array#fill` for Zero Values (#8903)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/664880808
<DeBot> https://github.com/crystal-lang/crystal/pull/8903 (Optimized Implementation of `Array#fill` for Zero Values)
<FromGitter> <ImAHopelessDev_gitlab> hi
<FromGitter> <ImAHopelessDev_gitlab> nice @faustinoaq, happy to hear from you!!
<FromGitter> <smalls12> is there a way to cast Int32 to Uint32? ⏎ I understand Int could be negative so how would you represent that in UInt ⏎ My question stems from Array returning Int32 for size()
<FromGitter> <Blacksmoke16> `1.to_u32`?
<FromGitter> <Blacksmoke16> it would either raise an `OverflowError` or wrap
<FromGitter> <smalls12> aw really, I tried 1.as(Uint32)
<FromGitter> <Blacksmoke16> and the method below it are your options
<FromGitter> <smalls12> why would .as say it couldn't cast ?
<FromGitter> <Blacksmoke16> `.as` is mainly used to resolve unions
<FromGitter> <smalls12> ok thanks : )
<FromGitter> <wout> What's the best one-liner to create a hash like Ruby's `Hash[:key, "value"]`? I've got `Hash.zip([:key], ["value"])` right now, but is there a more concise alternative?
<FromGitter> <Blacksmoke16> does that just make a hash with that one key/value pair?
<FromGitter> <Blacksmoke16> {:key => "value"}?
_ht has joined #crystal-lang
<FromGitter> <wout> Yes, but I have to note that the key is a variable.
<jhass> >> key = "foo"; value = "bar"; {key => value}
<DeBot> jhass: # => {"foo" => "bar"} - https://carc.in/#/r/8qq7
<jhass> valid in Ruby too, its Hash[] is meant to create a hash out of list of alternating key value pairs
<FromGitter> <wout> Ok, thanks.
<cyberarm> Is there a way of easily populating a struct from a pointer? (Similar to Ruby ffi's managed struct)
<FromGitter> <Blacksmoke16> could prob define an initializer for it
<FromGitter> <Blacksmoke16> that accepts a pointer?
<watzon> cyberarm: with a C struct from a lib definition
<watzon> ??
<watzon> Got another video out btw https://youtu.be/O6hVs8TF0ig
<FromGitter> <wontruefree> very cool I am part way through it
<FromGitter> <wontruefree> you are on a roll with the videos
<watzon> I'm trying!
<watzon> I want to get one more out today, but this one on a different topic. Maybe Crystal in general.
ur5us has joined #crystal-lang
<FromGitter> <smalls12> anyone know of some command line argument parsing shards ? ⏎ ( asking before googling )
<FromGitter> <smalls12> oh and thats part of stdlib
<FromGitter> <smalls12> nice
<FromGitter> <Blacksmoke16> are others out there that might be more advanced
<FromGitter> <smalls12> basics should be good enough for me
ur5us has quit [Quit: Leaving]
_ht has quit [Quit: _ht]
<FromGitter> <smalls12> @Blacksmoke16 how would one go about testing a change to the stdlib ⏎ ie. I want to test some differnet behavior with the OptionParser
<FromGitter> <smalls12> would I have to go and build crystal myself ?
ur5us has joined #crystal-lang
<FromGitter> <Blacksmoke16> that would be easiest
<FromGitter> <Blacksmoke16> otherwise could just override/reopen stuff if its simple
<FromGitter> <smalls12> I did find option_parser.cr on my system
<FromGitter> <smalls12> it seems I can modify that on the fly
<watzon> Is there a way to get the size of an IO that doesn't require using `gets_to_end`?
<watzon> I'm thinking no, but it would be nice
chachasmooth has quit [Ping timeout: 246 seconds]
chachasmooth has joined #crystal-lang
confact_ has joined #crystal-lang
confact has quit [Ping timeout: 246 seconds]
confact_ is now known as confact
<watzon> Really I just want to convert a File to a Slice easily
ur5us has quit [Ping timeout: 260 seconds]
DeBot has quit [Ping timeout: 246 seconds]
gangstacat has quit [Ping timeout: 246 seconds]
jetpack_joe has quit [Ping timeout: 246 seconds]
gangstacat has joined #crystal-lang
jetpack_joe has joined #crystal-lang
DeBot has joined #crystal-lang
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/IO.html#read_fully(slice:Bytes)-instance-method ?