RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.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
<crystal-gh> [crystal] bcardiff closed pull request #5461: Update bin/ci to use LIBRARY_PATH from 0.24.1 (release/0.24...fix/ci) https://git.io/vb59t
<crystal-gh> [crystal] bcardiff pushed 1 new commit to master: https://git.io/vb5b4
<crystal-gh> crystal/master 5e17dd5 Brian J. Cardiff: Update bin/ci to use LIBRARY_PATH from 0.24.1 (#5461)
radagast has quit [Ping timeout: 248 seconds]
<travis-ci> crystal-lang/crystal#4313e86 (release/0.24 - Update bin/ci to use LIBRARY_PATH from 0.24.1 (#5461)): The build was fixed. https://travis-ci.org/crystal-lang/crystal/builds/322005649
marius has joined #crystal-lang
vivus has quit [Quit: Leaving]
<travis-ci> crystal-lang/crystal#5e17dd5 (master - Update bin/ci to use LIBRARY_PATH from 0.24.1 (#5461)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/322006964
hightower2 has quit [Ping timeout: 256 seconds]
hightower2 has joined #crystal-lang
faustinoaq has joined #crystal-lang
hightower2 has quit [Ping timeout: 264 seconds]
<woodruffw> does anybody have an opinion on a `Bool.to_i` method? i think it'd be nice to have one, since `Bool.hash` already normatively provides `1` and `0` for `true` and `false`, respectively
<FromGitter> <edwardloveall> congrats on shipping 0.24
ashirase has quit [Ping timeout: 240 seconds]
ashirase has joined #crystal-lang
<FromGitter> <elorest> What's the best way to return bytes of a file? `File.open("name").gets_to_end.to_slice` works but it seems wrong to turn it into a string and then back to bytes.
nkts has joined #crystal-lang
rohitpaulk has quit [Read error: Connection reset by peer]
marius has quit [Read error: Connection reset by peer]
rohitpaulk has joined #crystal-lang
marius has joined #crystal-lang
rohitpaulk has quit [Read error: Connection reset by peer]
nkts has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <picatz> @elorest I guess you could just emulate what `gets_to_end` is doing looking at the underyling source code: https://github.com/crystal-lang/crystal/blob/80a975cf0a98a4ce8464d0069145131667becd70/src/io.cr#L549
<FromGitter> <picatz> You're probably right though -- or at least I agree -- that turning it into a String then into a Slice of Bytes isn't the way to go.
marius has quit [Ping timeout: 240 seconds]
<FromGitter> <picatz> I'd like an `all_bytes` method I think myself.
marius has joined #crystal-lang
ashirase has quit [Ping timeout: 260 seconds]
ashirase has joined #crystal-lang
marius has quit [Read error: Connection reset by peer]
marius has joined #crystal-lang
<FromGitter> <elorest> What that would make sense. Weird because File is very similar to IO and IO::Memory has a #to_slice method.
nkts has joined #crystal-lang
marius has quit [Read error: Connection reset by peer]
<FromGitter> <elorest> Is there a way to send `Bytes` through a TCP::Socket. Whenever I try it comes through as a string representation `message # => "Bytes[133, 163, 108, 97, 116, 171, 49, 50]"` Which isn't very useful. How would I get an array of Bytes out?
rohitpaulk has quit [Read error: Connection reset by peer]
rohitpaulk has joined #crystal-lang
marius has joined #crystal-lang
<FromGitter> <picatz> @elorest From what I can tell, hilariously you actually need to have a string to send out.
<FromGitter> <picatz> String.new(bytes_slice_here)
<FromGitter> <bew> @elorest try `io.write msg`
<FromGitter> <bararchy> what does this error means? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5a433c64e43a7a150cacfc99]
nkts has quit [Ping timeout: 260 seconds]
<FromGitter> <picatz> @bew may genuinely know more than I, so I'd listen to him first before me 😹
<FromGitter> <elorest> @bew thanks!
<FromGitter> <elorest> While you're here do you have an answer to my first question. How would I turn a file to Bytes?
<crystal-gh> [crystal] woodruffw opened pull request #5465: Bool: Add `to_i` (master...bool-to-i) https://git.io/vbdTY
<FromGitter> <elorest> with @bew's answer it comes through as a corrupt string but that works. I can treat it as bytes on the other end.
<FromGitter> <bew> Seems logic, as the bytes are not necessary a correct string
<FromGitter> <bew> About the file 2 bytes, I think you should create a slice of a given size, then do `io.read slice_content`
<FromGitter> <bew> To know the size you can do file.size for example
<FromGitter> <bew> Or read chunk by chunk (e.g: by block of 4096 bytes)
<FromGitter> <elorest> `io.gets_to_end.to_slice` works as well? What do you think is the most effective way to get the while files as bytes. I the cases I currently care about I just need the whole file in bytes.
<FromGitter> <bew> My method is better
<FromGitter> <elorest> :)
<FromGitter> <bew> Yours will create an intermediate string
<FromGitter> <elorest> I believe you but why?
<FromGitter> <bew> Λ†Λ†
<FromGitter> <bew> And it'll probably be a bit faster
<FromGitter> <bew> Why do you need the file in bytes?
<FromGitter> <elorest> Yeah that's what I was thinking above... ^ But yours runs 3 commands size Bytes(size), and read
<FromGitter> <elorest> In this case so that I can encode it into protobuf.
<FromGitter> <bew> Yes @elorest but under the hood gets_to_end will probably do more things
<FromGitter> <elorest> In other cases I've need to have it so that I could decrypt it.
<FromGitter> <elorest> #peek seems to work as well but isn't predictable.
<FromGitter> <bew> Or less efficiently as you already know the size (gets_to_end will just read until the end, but it doesn't know where the end is)
<FromGitter> <elorest> True but size is found by reading until the end as well.
<FromGitter> <bew> Nop
<FromGitter> <bew> Not for a file!
<FromGitter> <elorest> If I could just dump all bytes til the end it would be most efficient.
<FromGitter> <elorest> Hmmm ok.
<FromGitter> <bew> The filesystem can give you the file size
<FromGitter> <elorest> Good point.
<FromGitter> <bew> Not even sure about that, should be 1 syscall at all
<FromGitter> <bew> At least 1 read instead of potentially many
<FromGitter> <bew> And 1 allocation
<FromGitter> <bew> Need to go, bye!
<FromGitter> <elorest> Thanks.
faustinoaq has quit [Quit: IRC client terminated!]
<FromGitter> <picatz> :metal: Great stuff!
<FromGitter> <elorest> @bew @picatz I got some interesting results when benchmarking this in release mode. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5a434470232e79134d96ae2d]
<FromGitter> <picatz> Very interesting!
<FromGitter> <picatz> I wonder if there's like... some sort of optimization being done by LLVM? ( I have no idea what I'm talking about )
<FromGitter> <elorest> Perhaps. I'm sure @bew or <oprypin> have some idea of why this would be. Could be that it's faster but uses a lot more memory or something.
<FromGitter> <picatz> Computers are just the craziest things.
snsei has joined #crystal-lang
<RX14> makes sense to me
<RX14> IO is buffered
<RX14> actually no it doesnt
<RX14> read_bytes being slower does though
<RX14> ah actually yes
<RX14> gets_to_end basically copies into the stack then into a string
<RX14> idk why peek is slower, it shouldn't be as it does only one copy
<RX14> your slice/read one should be slower as it does 2 syscalls
<FromGitter> <bew> 2 ?
<RX14> also the benchmark is basically entirely void as it leaks file descriptors
<RX14> size and read
<RX14> the others dont bother
<RX14> they read it by chunks and use realloc
<RX14> it's going to end up faster when your original guess is close to correct
<RX14> syscalls are incredibly expensive
<FromGitter> <bew> I would think that reading by chunk and realloc-ing would be slower than reading the whole file directly
<RX14> just the simplest getpid syscall is 200+ cycles
<RX14> read() will be 500+ cycles and wreck your caches
marius has quit [Quit: marius]
<FromGitter> <bew> Maybe it's true only for huuge file, bit then it probably doesn't makes sense anymore...
<RX14> keep in mind that the buffer size quickly approaches the correct size
<RX14> String::Builder does * 2
<RX14> and most of the time libgc will just return you the same pointer in a microbenchmark
<RX14> because the previous time around left a whacking great hole just the right size
<RX14> in this microbenchmark all your objects are the same size
<RX14> so realloc is essentially free
sky_ has joined #crystal-lang
sky_ is now known as relyks
relyks has quit [Client Quit]
rohitpaulk has quit [Read error: Connection reset by peer]
alex`` has joined #crystal-lang
rohitpaulk has joined #crystal-lang
claudiuinberlin has joined #crystal-lang
rohitpaulk has quit [Read error: Connection reset by peer]
mark_66 has joined #crystal-lang
rohitpaulk has joined #crystal-lang
pleiosaur has quit [Remote host closed the connection]
<lvmbdv> built 0.24.1 with LLVM 5.0.1 with no problems during the build, just checking in
<lvmbdv> i don't bother with the spec tests tho so don't take my word :^)
<FromGitter> <bararchy> I got the strangest issue.... ⏎ I can run specs on a shard that binds to c lib, it runs and works, trying to use it in a project raises a compile issue from the linker ⏎ both are on the same machine, on the same user and in the same shell
Yxhuvud has quit [Read error: Connection reset by peer]
Yxhuvud has joined #crystal-lang
<FromGitter> <bararchy> the issue I see is this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5a436e8f0163b02810825b38]
<FromGitter> <bararchy> also C++ that links to this same libs compiles without an issue
<FromGitter> <bararchy> maybe I'm missing something?
rohitpaulk has quit [Ping timeout: 256 seconds]
rohitpaulk has joined #crystal-lang
hightower2 has joined #crystal-lang
radagast has joined #crystal-lang
<FromGitter> <straight-shoota> @RX14 I've updated the wiki page to directly include instructions for building libraries on windows. Could you take look at it? https://github.com/crystal-lang/crystal/wiki/Porting-to-Windows#how-to-build-libs
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 240 seconds]
<crystal-gh> [crystal] MakeNowJust opened pull request #5466: Fix to look up NamedTuple from self (master...fix/crystal/5464-instantiate-namedtuple-by-self-restriction) https://git.io/vbdnp
hightower3 has quit [Ping timeout: 272 seconds]
hightower3 has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
cremes has quit [Quit: cremes]
rohitpaulk has joined #crystal-lang
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 252 seconds]
<RX14> @straight-shoota those instructions are wrong
<RX14> You need to test them and tweak them a bit
<RX14> For example the cmake command should use -D for all the options
<RX14> Which caused me much pain
<RX14> Also we dont need all those libraries yet
<RX14> And the wording around build_path is super confusing
<RX14> Also just use pcre 8.41
<RX14> And skip the edit step
<RX14> You can just unpack 8.41 and it works with the correct cmake options out of the box
<FromGitter> <straight-shoota> I've so far only built libgc myself
rohitpaulk has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
<RX14> Well
<FromGitter> <straight-shoota> yeah I know...
<RX14> @straight-shoota if you try to run my branch with specs working
<RX14> You will get a link error with pcre
<RX14> The pcre built by bcardiff also followed the wrong instructions
<RX14> So it links until you actually try to use some regex
<FromGitter> <straight-shoota> haven't tried that yet
<RX14> And then it instantly breaks
<RX14> Well windows looks to have severe Codegen bugs
<RX14> So I'm not too excited to work on iy
<RX14> It*
<RX14> Given I know nothing about crystal codegen
<RX14> Or the internals of llvm
<FromGitter> <straight-shoota> that's probably still more then I
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 246 seconds]
rohitpaulk has quit [Ping timeout: 265 seconds]
cremes has joined #crystal-lang
rohitpaulk has joined #crystal-lang
literal has quit [Ping timeout: 240 seconds]
snsei has joined #crystal-lang
rohitpaulk has quit [Read error: Connection reset by peer]
snsei has quit [Ping timeout: 272 seconds]
rohitpaulk has joined #crystal-lang
faustinoaq has joined #crystal-lang
<hightower2> Papierkorb: re. Fancyline, I copy the basic 3 lines from "Step 0: Most basic usage" and get: lib/fancyline/src/fancyline/widget/history_search.cr:25: instance variable '@display_handle' of Fancyline::Widget::HistorySearch must be Int32, not UInt64
rohitpaulk has quit [Read error: Connection reset by peer]
rohitpaulk has joined #crystal-lang
<FromGitter> <bararchy> how do I test if Float_a is 0.5 points near to Float_b? I remmber specs had something for it
<FromGitter> <straight-shoota> https://crystal-lang.org/api/0.24.1/Spec/Expectations.html#be_close%28expected%2Cdelta%29-instance-method
<FromGitter> <bararchy> be_close(expected, delta)
<FromGitter> <bararchy> thanks :)
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <bararchy> @straight-shoota ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5a43b99003838b2f2a40b18f]
<FromGitter> <bararchy> where do I pass actual ?
<FromGitter> <straight-shoota> `actual` is the value which this expectation refers to: ⏎ ⏎ ```actual.should be_close(expected, delta)``` [https://gitter.im/crystal-lang/crystal?at=5a43b9f2c072deaf0b0a1189]
marius has joined #crystal-lang
<FromGitter> <bararchy> oh
<FromGitter> <bararchy> .should
<FromGitter> <bararchy> right XD
<FromGitter> <straight-shoota> @RX14 I've improved the instructions for libpcre (and tested it myself) and commented out the other libraries that are currently not needed
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 252 seconds]
snsei_ has joined #crystal-lang
<FromGitter> <bararchy> Running neural networks in Crystal really makes me itch for multi-threading
snsei_ has quit [Remote host closed the connection]
marius has quit [Quit: marius]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 252 seconds]
snsei has joined #crystal-lang
vivus has joined #crystal-lang
snsei has quit [Ping timeout: 256 seconds]
rohitpaulk has joined #crystal-lang
mark_66 has quit [Remote host closed the connection]
<FromGitter> <codenoid> hi
<FromGitter> <codenoid> how i can do simple login with crystal (http client)
<FromGitter> <codenoid> and doing some action after login ?
<FromGitter> <codenoid> please give me some example code
<FromGitter> <codenoid> i'm trying with standart post but it's doesnt work
<FromGitter> <bararchy> ```client.basic_auth(user,pass) # this adds basic authentication ⏎ client.get(....)``` [https://gitter.im/crystal-lang/crystal?at=5a43cb42232e79134d990387]
<FromGitter> <codenoid> it doesnt work
<FromGitter> <codenoid> client .new pointed to POST login url
<FromGitter> <bararchy> does "post login" has a login form?
<FromGitter> <bararchy> or is it a basic auth supported site?
<FromGitter> <codenoid> yes,
<FromGitter> <codenoid> and i think crystall basic auth can choose automatically username annd pw form
<FromGitter> <codenoid> i move to seleniium
claudiuinberlin has quit [Quit: Textual IRC Client: www.textualapp.com]
<crystal-gh> [crystal] j8r opened pull request #5468: Change from `bash` to `sh` (master...shell-cleanups) https://git.io/vbdKo
aroaminggeek has quit [Quit: Textual IRC Client: www.textualapp.com]
rohitpaulk has quit [Ping timeout: 260 seconds]
claudiuinberlin has joined #crystal-lang
rohitpaulk has joined #crystal-lang
snsei has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
alex`` has quit [Quit: WeeChat 2.0.1]
<FromGitter> <faustinoaq> Running neural networks in Crystal really makes me itch for multi-threading ⏎ @bararchy So
<FromGitter> <faustinoaq> Multithreading is the second thing to achieve in 2018 πŸ˜„ πŸŽ‰
<FromGitter> <bararchy> really hope so, thinking that I could make my program at least 8 times faster is crazy
<FromGitter> <bararchy> we already beat big names in python land (tensor flow) at speed
<FromGitter> <bararchy> (not GPU)
<FromGitter> <bararchy> I'm sure people will prefer Crystal to Matlab and the likes
<FromGitter> <bararchy> and god forbid...R
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
<FromGitter> <HCLarsen> @faustinoaq If multithreading is the second thing, what's the first?
faustinoaq has quit [Quit: IRC client terminated!]
<FromGitter> <bararchy> Windows support I guess ?
<oprypin> faustinoaq, iirc neural networks dont use allocations so theyre a good candidate to run multithreaded even right now
cremes has quit [Quit: cremes]
<FromGitter> <bararchy> Hmmm can it be done easily ?
<oprypin> not easily. only if you're very careful
<oprypin> so allocate everything, start a thread to use it without any allocations
<FromGitter> <bararchy> Cool
<FromGitter> <bararchy> Let me try it
<FromGitter> <bararchy> I can use it for wight adjustmnet and function (sigmod, thna, etc..)
<FromGitter> <ziprandom> hey crystallers, any of you at the chaos communications congress in leipzig :)?
<FromGitter> <HCLarsen> Hey guys, is there a Crystal equivalent to the $_ operator in other languages?
<FromGitter> <HCLarsen> Sorry, not operator, variable.
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
<oprypin> HCLarsen, i dont know any such other languages
<FromGitter> <HCLarsen> Well, hopefully someone here knows Ruby.
<oprypin> i guess this is what racism feels like?
<FromGitter> <HCLarsen> ???
snsei has quit [Ping timeout: 252 seconds]
<FromGitter> <HCLarsen> Sometimes referred to as: ⏎ The local variable, last string read by gets or readline in the current scope.
<FromGitter> <straight-shoota> No such global variables in Crystal
<FromGitter> <HCLarsen> Damn.
<FromGitter> <straight-shoota> make sure to store the result from gets by yourself
<FromGitter> <HCLarsen> I'm not using gets.
<oprypin> i described all $ vars in https://github.com/crystal-lang/crystal/issues/4715 ($0 gone since then)
<FromGitter> <HCLarsen> Thanks
<FromGitter> <HCLarsen> How do you get access to the standard input then?
snsei has joined #crystal-lang
<oprypin> STDIN
snsei has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei_ has joined #crystal-lang
alex`` has joined #crystal-lang
manveru has quit [Ping timeout: 240 seconds]
aemadrid has quit [Ping timeout: 252 seconds]
danzilio has quit [Ping timeout: 252 seconds]
aarongodin has quit [Ping timeout: 252 seconds]
snsei has quit [Ping timeout: 252 seconds]
avdi has quit [Ping timeout: 252 seconds]
andersh has quit [Ping timeout: 252 seconds]
mroth has quit [Read error: Connection reset by peer]
ilovezfs_ has quit [Read error: Connection reset by peer]
Majost has quit [Ping timeout: 250 seconds]
alex`` is now known as alexherbo2
jeromegn has quit [Ping timeout: 252 seconds]
hmans has quit [Ping timeout: 252 seconds]
alexherbo2 is now known as alex``
rohitpaulk has joined #crystal-lang
andrewzah has quit [Ping timeout: 240 seconds]
andrewzah has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
snsei_ has quit [Remote host closed the connection]
snsei has joined #crystal-lang
snsei has quit [Ping timeout: 252 seconds]
<FromGitter> <bararchy> oprypin I try to add your multithread solution here https://github.com/NeuraLegion/shainet/blob/master/src/shainet/network.cr#L160-L162
<FromGitter> <bararchy> but it seems to just get stuck
<FromGitter> <bararchy> am I missing something?
snsei has joined #crystal-lang
hmans has joined #crystal-lang
danzilio has joined #crystal-lang
andersh has joined #crystal-lang
avdi has joined #crystal-lang
<FromGitter> <paulcsmith> I'm working on upgrading Lucky to 0.24.1 but I'm running in to an odd issue. When running this spec (https://github.com/luckyframework/lucky/pull/322/files#diff-0d240f7a6d6d5b088599b726c0523cf0R41) I get ```Index out of bounds ⏎ Error running at_exit handler: Index out of bounds```
Majost has joined #crystal-lang
<FromGitter> <paulcsmith> There is no stacktrace either and no mention of which spec failed
ilovezfs_ has joined #crystal-lang
<FromGitter> <paulcsmith> I've narrowed it done to the line I linked to above but it doesn't make sense that it would failed because of raising and I'm unsure how to handle it. Any ideas?
aarongodin has joined #crystal-lang
snsei has quit [Remote host closed the connection]
manveru has joined #crystal-lang
aemadrid has joined #crystal-lang
mroth has joined #crystal-lang
literal has joined #crystal-lang
<FromGitter> <straight-shoota> @paulcsmith #5460
<FromGitter> <straight-shoota> or rather #5224
<FromGitter> <straight-shoota> Until this is fixed you can try `--no-debug`
<FromGitter> <paulcsmith> --no-debug worked. Thanks a ton @straight-shoota
aroaminggeek has joined #crystal-lang
rohitpaulk has joined #crystal-lang
snsei has joined #crystal-lang
<FromGitter> <drosehn> `$_` was popular in perl. I'm not sure that it still is. Early ruby picked up the idea of `$_` from perl (because it picked up a lot of ideas from perl), but I haven't seen any ruby programs which take advantage of that. That doesn't mean there aren't any, but I think use of the magic `$_` variable was strongly discouraged in ruby at some point.
<FromGitter> <drosehn> ... at some point, many years ago.
rohitpaulk has quit [Ping timeout: 260 seconds]
snsei has quit [Ping timeout: 246 seconds]
<hightower2> Yeah, use of a global was never encouraged in ruby
<hightower2> (global $_ I mean)
cremes has joined #crystal-lang
<FromGitter> <fridgerator> RX14 - I dont know if some work was done on travis to get crystal 0.24.1 working, but it worked for me yesterday
<FromGitter> <fridgerator> fa
<RX14> Cool
rohitpaulk has joined #crystal-lang
jeromegn has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 264 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
radagast has quit [Ping timeout: 248 seconds]
cremes has quit [Quit: cremes]
claudiuinberlin has quit [Quit: Textual IRC Client: www.textualapp.com]
radagast has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.0.1]
rohitpaulk has joined #crystal-lang
<FromGitter> <straight-shoota> The gitter room topic should be updated to 0.24.1 @RX14
rohitpaulk has quit [Ping timeout: 264 seconds]
hightower2 has quit [Ping timeout: 268 seconds]
cremes has joined #crystal-lang
radagast has quit [Quit: radagast]
radagast has joined #crystal-lang