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
alexherbo2 has joined #crystal-lang
ur5us has quit [Ping timeout: 260 seconds]
<watzon> I feel like I've done this before, but for the life of me I can't remember. How would I convert an Array(UInt32) to a Bytes object?
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]
ur5us has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <naqvis> one way to achieve the outcome could be ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e7999d1ada8262f814a9155]
_whitelogger has joined #crystal-lang
<FromGitter> <naqvis> how did you go with that then?
ur5us has quit [Ping timeout: 246 seconds]
<watzon> Turned out my array was actually an Array(UInt8)
<watzon> I needed to convert it to a string, which is pretty easy
<FromGitter> <naqvis> lucky you 😆
<watzon> Yes lol
<watzon> Now I'm trying to figure out if Crystal's IO has anything akin to Ruby's wait_readable
<watzon> Not finding anything in the docs though
<FromGitter> <naqvis> I highly doubt that
<FromGitter> <naqvis> guess you would have to come up with your own abstraction
<watzon> Yeah it's seeming like it
<FromGitter> <naqvis> `IO::Evented ` have you looked into this?
<FromGitter> <naqvis> This seems to be right starting point
<watzon> Ooh that might actually work
<FromGitter> <naqvis> they only have `Socket` as implementation, but if you are looking for different IO then you will need to roll-up your own sleeves
<watzon> Well I'm dealing with STDOUT which is an `IO::FileDescriptor` which, lucky me, includes `IO::Evented`
<FromGitter> <naqvis> 👍
<watzon> Why does this have a damn "nodoc" over it? This is exactly what I need https://github.com/crystal-lang/crystal/blob/612825a53c831ce7d17368c8211342b199ca02ff/src/io/evented.cr#L119
<FromGitter> <naqvis> developers are lazy as you know Lol
_ht has joined #crystal-lang
<oprypin> you could say that if it had no doc. but `:nodoc:` is very different
<oprypin> it's like private but not actually
<sorcus> https://sorcus.name/screenshot-2020-03-24_09-17-59.png - search on `crystal-lang.org/reference` is broken :-(
postmodern has quit [Quit: Leaving]
<oprypin> sorcus, your link is also broken. forbidden
<sorcus> oprypin: Haha, you right, try again.
wakatara has joined #crystal-lang
<FromGitter> <j8r> watzon I think with `to_unsafe`
wakatara has quit [Ping timeout: 240 seconds]
wakatara has joined #crystal-lang
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 264 seconds]
wakatara has quit [Remote host closed the connection]
<watzon> This is why we do it folks
<watzon> So I'm trying to figure out how to mock STDOUT for tests. In Ruby you'd use StringIO, which Crystal use to have then it got renamed to MemoryIO and then IO::Memory, but it seems like it no longer "quacks like a file".
<FromGitter> <Blacksmoke16> example?
<FromGitter> <stronny> STDOUT isn't exactly a file
<watzon> STDOUT is a FileDescriptor
<FromGitter> <stronny> is IO not enough?
<watzon> IO::Memory doesn't have methods like `noecho` and stuff
<watzon> I'm dealing with a terminal environment, so I need everything that STDOUT offers. It would just be nice to have an easy way to mock it.
<watzon> Seems like I'm going to have to write my own mock class though
<FromGitter> <stronny> does noecho work on pipes? `yourprogram | cat` would echo everything
<FromGitter> <stronny> at least check `.tty?`
<FromGitter> <stronny> fundamentally I don't think unit tests cover program boundaries, integration tests do
<FromGitter> <manveru> just lost 2 hours because doing output in systemd services doesn't flush stdout anymore :P
<FromGitter> <manveru> is there some way to get `IO#flush_on_newline` back?
<FromGitter> <stronny> @oprypin do you still support dbus bindings?
<FromGitter> <7sedam7> hi, how can i compile crystal code and call it from swift for the osx and ios apps?
postmodern has joined #crystal-lang
<FromGitter> <asterite> @manveru Yeah. I want to bring back `flush_on_newline` and make it true by default for TTY and non-TTY.
zorp has quit [*.net *.split]
daemonwrangler has quit [*.net *.split]
daemonwrangler has joined #crystal-lang
zorp has joined #crystal-lang
<FromGitter> <stronny> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e7a484f63bf7c2ff81f5726]
<FromGitter> <stronny> what does Crystal want from me?
<FromGitter> <stronny> nvm, `Pointer(Void)?`
<FromGitter> <asterite> `Pointer(Void).null`
<FromGitter> <stronny> oh
<FromGitter> <asterite> `nil` is allowed to be converted to `Pointer(Void)` but only in a C function call
<FromGitter> <stronny> I see
* watzon uploaded a video: 2020-03-24_12-08-29.mp4 (89KB) < https://matrix.org/_matrix/media/r0/download/matrix.org/niokvIJYaeMcTLbpIpTjashu >
<watzon> This is exciting. May seem small, but it's a precursor to bigger things.
<FromGitter> <manveru> @asterite seems like it even happens when i use Logger, this is quite frustrating :|
<oz> watzon: that's nice. 👍
DTZUZU2 has joined #crystal-lang
DTZUZU has quit [Ping timeout: 250 seconds]
<FromGitter> <asterite> Even with Logger? That's strange
<FromGitter> <asterite> That doesn't make much sense, Logger does flush
blueberrypie has quit [Quit: leaving]
blueberrypie has joined #crystal-lang
cloaked1 has joined #crystal-lang
<FromGitter> <kingsleyh> hello - I'm struggling to find out why this code throws an IO:EOFError - all the specs seem to pass - but I don't want this error being thrown all the time: https://github.com/tbrand/tokoroten/blob/master/src/tokoroten/worker.cr
<FromGitter> <kingsleyh> anyone have any idea how I can catch the error?
<FromGitter> <stronny> where does it raise?
<FromGitter> <kingsleyh> I've tried putting a rescue around pretty much everything I can think of - but still throws the error
<FromGitter> <stronny> can you show stacktrace?
<FromGitter> <kingsleyh> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e7a62c74f363653cecfb625]
<FromGitter> <kingsleyh> there is no reference to the code here - its all just internal crystal
<FromGitter> <kingsleyh> so I can't even see what is throwing the error
<FromGitter> <stronny> oh
<FromGitter> <stronny> > name: Signal Loop
<FromGitter> <stronny> that's interesting
<FromGitter> <kingsleyh> it only throws on these specs: https://github.com/tbrand/tokoroten/blob/master/spec/tokoroten_spec.cr#L110
<FromGitter> <kingsleyh> and if I run them one at a time - they don't throw
<FromGitter> <kingsleyh> but I can't see how to catch it anywhere
<FromGitter> <stronny> it's not in your fibers, it's in a Crystal's secret fiber
<FromGitter> <stronny> do you do mt_preview?
<FromGitter> <kingsleyh> it's only doing this in 0.33 - previous releases don't have this issue
<FromGitter> <stronny> mt_preview?
<FromGitter> <kingsleyh> is it a bug in crystal 0.33?
<FromGitter> <stronny> do you use mt_preview or not?
<FromGitter> <stronny> try without
<FromGitter> <kingsleyh> how do I know if I use it?
<FromGitter> <stronny> why do you mention threads?
<FromGitter> <kingsleyh> how do I run with mt_preview off?
<FromGitter> <stronny> it's off by default
<FromGitter> <Blacksmoke16> if you have to ask if you're using it or not, you're not using it :p
<FromGitter> <kingsleyh> how do I run with it on? `crystal -Dpreview_mt spec spec/tokoroten_spec.cr:110`
<FromGitter> <kingsleyh> doesn't work
<FromGitter> <Blacksmoke16> prob add it after `spec`
<FromGitter> <kingsleyh> oh: crystal spec -Dpreview_mt
<FromGitter> <kingsleyh> Error: Process fork is unsupported with multithread mode
<FromGitter> <stronny> right
<FromGitter> <stronny> Please report an issue
<FromGitter> <kingsleyh> so I guess it's a bug - since I can't actually catch it anywhere
<FromGitter> <stronny> I've told you, an exception occurs in Crystal's internals
<watzon> I don't think tokoroten uses Crystals built in multithreading, so doubtful he'd be using it
<watzon> Otherwise he wouldn't need tokoroten
<FromGitter> <stronny> guys, it's written in plain English
<FromGitter> <stronny> `Unhandled exception in spawn(name: Signal Loop):`
<FromGitter> <kingsleyh> yeah multithreading is too new - I was considering moving to it instead of tokoroten - but it's not ready yet for the kind of pressure I need
<FromGitter> <stronny> Signal Loop is the Crystal's internal fiber
<FromGitter> <stronny> (unless I miss something)
<FromGitter> <kingsleyh> Gitter is very flaky for me lately - messages come all out of order
<FromGitter> <stronny> yeah, it has problems
ur5us has joined #crystal-lang
<FromGitter> <stronny> I wouldn't fork in crystal even without mt
<FromGitter> <stronny> it's too complicated to do right
DTZUZU2 has quit [Ping timeout: 256 seconds]
<FromGitter> <straight-shoota> @asterite In the example in #8935 shouldn't it be `STDOUT.flush_on_newline = false`?
<DeBot> https://github.com/crystal-lang/crystal/pull/8935 (Add `IO::Buffered#flush_on_newline` back and set it to true for non-tty)
<FromGitter> <Blacksmoke16> thoughts on this API for validation callbacks?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5e7a75962378e90d05f0ead7]
<FromGitter> <asterite> @straight-shoota oh, yeah, thanks. Fixes
DTZUZU2 has joined #crystal-lang
<FromGitter> <jwoertink> Anyone happen to see this? https://andrewkelley.me/post/zig-cc-powerful-drop-in-replacement-gcc-clang.html I'm curious to see what would happen if we tried to use this to compile crystal 😂
_ht has quit [Quit: _ht]
<livcd> I have just a few questions. What is the best supported DB driver and what is the best way to check your code without recompiling ?
<FromGitter> <Blacksmoke16> check your code in what way?
<livcd> smh like cargo check
<watzon> @jwoertink yes! I watched his screencasts where he was live coding it. I think we may even be able to use `zig cc` to cross compile Crystal without using a VM, but I'll have to play around with it.
<watzon> Also, I just got this pushed https://github.com/crystal-term/reader
<FromGitter> <jwoertink> `CC="zig cc -target x86_64-macosx" make` on the crystal repo works 😅
<FromGitter> <jwoertink> it builds the crystal binary