jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.28.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
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 248 seconds]
<FromGitter> <Blacksmoke16> @watzon https://play.crystal-lang.org/#/r/6uo3 for when you get back, so it doesnt get lost
<FromGitter> <watzon> And this is why we ask for help! Thanks @Blacksmoke16 !
<FromGitter> <Blacksmoke16> np
Liothen has quit [Quit: The Dogmatic Law of Shadowsong]
Liothen has joined #crystal-lang
<beepdog> Hey, I'm having some trouble trying to cross compile a thing to run on aarch64 (my raspberry pi)
<beepdog> https://crystal-lang.org/reference/syntax_and_semantics/cross-compilation.html is the only instructions I've been able to find
<beepdog> and it seems as tho it doesn't work tho
<beepdog> gitwork/pet_watchdog master> crystal build src/pet_watchdog.cr --cross-compile --target "aarch64-unknown-linux-gnu" 1s[0c61be1]systemsystemsystem
<beepdog> cc 'pet_watchdog.o' -o 'pet_watchdog' -rdynamic -lpcre /home/dkowis/.anyenv/envs/crenv/versions/0.28.0/bin/../lib/crystal/lib/libgc.a -lpthread /home/dkowis/.anyenv/envs/crenv/versions/0.28.0/share/crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/home/dkowis/.anyenv/envs/crenv/versions/0.28.0/bin/../lib/crystal/lib -L/usr/lib -L/usr/local/lib
<beepdog> I get a linking command that hooks up to things that won't work on that other architecture
beepdog has quit [Quit: lol]
dkowis has joined #crystal-lang
dkowis has quit [Client Quit]
beepdog has joined #crystal-lang
return0e_ has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
alexherbo2911 has joined #crystal-lang
alexherbo291 has quit [Ping timeout: 248 seconds]
f1refly has quit [Ping timeout: 252 seconds]
dkowis has joined #crystal-lang
f1refly has joined #crystal-lang
laaron- has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <watzon> Can you get the index with `Enumerable#reduce`?
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <watzon> Trying to create a n-dimensional array of a specified shape filled with zeros is a pain in the butt
<FromGitter> <watzon> ```code paste, see link``` ⏎ ⏎ This is getting close at least [https://gitter.im/crystal-lang/crystal?at=5ccfcb9c990feb45185e0b06]
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
Flipez has quit [Quit: The Lounge - https://thelounge.github.io]
Flipez has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <vladfaust> The article's published. I need your claps to spread it — https://medium.com/@vladfaust/sorbet-is-cool-but-crystal-is-smoother-d16f4a920108. However, you should only clap if you liked it ;)
<FromGitter> <bararchy> Any idea if I can use https://github.com/crystal-community/msgpack-crystal with a logic like MSGPack::Any ?
<FromGitter> <bararchy> like the JSON
<FromGitter> <vladfaust> I'm going to post it on Reddit and HN after some time
<FromGitter> <bararchy> so I can parse dynamiclly w
<FromGitter> <vladfaust> @bararchy `MessagePack::Table.from_msgpack`
<FromGitter> <bararchy> Awsome!
<FromGitter> <bararchy> thanks
<FromGitter> <dscottboggs_gitlab> yeah I didn't know that was a thing -- super excited to have that as a part of the toolkit now
<FromGitter> <vladfaust> It's painful that serializations has different APIs though. I also think that MessagePack should be part of stdlib
<FromGitter> <alex-lairan> @vladfaust if MessagePack became part of stdlib, Protobuf should too ;)
<FromGitter> <vladfaust> Well, ProtoBuf is way more complicated than Read-From-STDIN protocols (i.e. JSON, MP, YAML)
<FromGitter> <vladfaust> It requires .proto files etc.
<FromGitter> <vladfaust> While MP has the same complexity as JSON, basically
<FromGitter> <vladfaust> Articles are rare, so @everyone, please leave some claps (you can hold the clap button resulting in more than one clap). I'm hoping to catch more Ruby devs with that Sorbet hype train, so help me on that! https://medium.com/@vladfaust/sorbet-is-cool-but-crystal-is-smoother-d16f4a920108
<FromGitter> <kaukas_gitlab> @vladfaust, it's a great introduction for rubyists. But the devil is in the details. It is quite likely that Rails devs would look for alternatives when their Rails app is big and slow (whatever that means). By then it makes no sense to rewrite everything. Instead you want to optimise the "core parts". The only way Crystal could help is as a standalone app (somehow network-based), and that's not
<FromGitter> ... convenient. E.g. Rust can be used to write Ruby extensions (https://crates.io/crates/rutie) (not super elegant but possible) which allows to gradually improve the most painful parts only, and then later possibly take over the whole app. Crystal can not do that yet, not without MT support and a good binding shard.
<FromGitter> <kaukas_gitlab> In comparison, Sorbet is very gradual and you do not *have* to infect your files with `T::Sig`s, `.rbi`s are supposed to be auto-generatable, so largely out-of-sight.
<FromGitter> <vladfaust> It doesn't matter. The main goal is to raise the language awareness
<FromGitter> <kaukas_gitlab> Yes, I guess awareness is important. More eyes means more hands to fix problems. That said, the thoughts above are from a person who actually tried to use Crystal in a Ruby app, and failed. Since you are comparing Ruby+Sorbet to Crystal the details on how to integrate (not as a lib) and what performance to expect (problematic compile times) could be relevant for any non-green field project.
alexherbo29111 has joined #crystal-lang
alexherbo2911 has quit [Ping timeout: 245 seconds]
<FromGitter> <jackturnbull> Howdy folks. Does anyone know if iterating over Postgres result-sets is thread (or fiber) safe? I'm setting an ID cache outside of the ResultSet `each` block and I'm expecting there to be an ID in an array for the second row, but there isn't. I'll not drop my full code but I've got something like; ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ So it appears that the first push of the ID into the cache
<FromGitter> ... outside of the result set block isn't completing by the time the 2nd row gets read. [https://gitter.im/crystal-lang/crystal?at=5cd0131da4ef0974715a845b]
<FromGitter> <jackturnbull> Am I missing something fundemental?
<FromGitter> <jackturnbull> I had posted a message but I've solved my own issue, so I'll remove it to save clutter, but for anyone that did see it; *user error, incorrectly resetting my cache on first iteration*
sz0 has joined #crystal-lang
alexherbo29111 has quit [Quit: The Lounge - https://thelounge.chat]
alexherbo2 has joined #crystal-lang
<FromGitter> <Blacksmoke16> @watzon you mean recreate an array filled with zeros from that the response on of that shape method?
<FromGitter> <j8r> @watzon you can use `StaticArray` for that
<FromGitter> <j8r> `p StaticArray(Int32, 99).new 0`
<FromGitter> <yxhuvud> @watzon Doesn't Array.new yield the index anyhow?
<FromGitter> <yxhuvud> It does in ruby anyhow.
<FromGitter> <yxhuvud> ie `Array.new(5) {|x| x}` => [0,1,2,3,4]
<FromGitter> <j8r> Good to know. Maybe `StaticArray` is better for its usecase, or is it needed to reduce/grow the Array size?
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6urr @watzon
<FromGitter> <Blacksmoke16> i think that's what he wanted?
<FromGitter> <j8r> it's not a good idea to monkey patch the stdlib
<FromGitter> <Blacksmoke16> oh well
<FromGitter> <yxhuvud> It would definitely make sense as a lib though. There are a couple of lapack bindings, but doing a full lapack/BLAS implementation is a lot of work, and it is largely orthogonal to having a nice and workable API against a matrix.
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
lucasb has joined #crystal-lang
moei has joined #crystal-lang
<jokke> hey
<FromGitter> <Blacksmoke16> o/
<jokke> following minimal example: https://p.jokke.space/I9Fea/
<jokke> any idea why the binary running in the container built from this image cannot be killed?
<jokke> (only with SIGKILL)
<z64> jokke: i can't test that right now, but i had a similar issue with a blocking application and adding a `Signal::TERM.trap` handler fixed it
<jokke> z64: interesting.. i think you're right. i have to trap INT and TERM for it to behave normally...
<jokke> i wonder why that is
<jokke> z64: eg: this works: https://p.jokke.space/noUA/
<z64> i don't know about INT, but thats what docker does - it sends TERM to give the app a chance to do a graceful cleanup, and after a long timout period, kills it
<jokke> yeah except if you start it with docker run and hit ctrl-c
<jokke> then it seems to send an INT
<z64> yes, if you're attached, it will behave like a normal terminal and send sigint. but for production, you need to handle `TERM` sent by the docker daemon
ukd1 has quit [Quit: Lost terminal]
<FromGitter> <nsuchy> Posted this on the forum, people here might also have suggestions https://forum.crystal-lang.org/t/how-can-i-start-contributing/734
wakatara has joined #crystal-lang
<wakatara> I am getting what would be strange behaviour moving over from ruby to crystal. I am trying to sort an array of hashes and using a .sort_by{|h| [h.date, h.habit]} but this is causing a weird error: no overload matches 'String#<=>' with type (String | Time)
<wakatara> What I"m trying to do is do a bilevel sort where I get things sorted by date and then by the string habit, but I'm assuming I'm doing it wrong in Crystal land.
<wakatara> Can anyone give me an idea of the correct way to do this? (again, I'm sorting an array of hashes one of which has a Time type, the other a String - in case hat was not obvious)
<FromGitter> <jwoertink> You could go `h.date.to_s("%Y-%m-%d")` or whatever
<wakatara> jwoertink: I had assumed that would not work because the system is translating the read file from the %Y-%m-%d fromat into something like @date=2019-04-29 00:00:00.0 +07:00 Local in the Struct. Why does that work?
<wakatara> (it does seem to compile without error... just curious though, since I would never have thought of that.
<FromGitter> <jwoertink> @nsuchy I replied to your post. Also, another idea is maybe go through the bug label issues, and look to see if that bug is still reproducible in the latest release on different systems. That could be a bit time consuming, but might help close out some old issues no longer relevant
<FromGitter> <jwoertink> My guess was that your overload error was because of the Union. I figured 2 String objects would work.
<FromGitter> <jwoertink> But that was purely a guess lol
<Yxhuvud> wakatara: the type of [h.date, h.havit] is Array(String|Time). Try to change it to {h.date, h.habit}
<Yxhuvud> that at least has a chance of working :)
<Yxhuvud> Tuples have positional typing, arrays do *not*.
<wakatara> Yxhuvud: Ah, yes, {h.date, h.habit} works
<wakatara> Thank you. I think I need to read up on why both seemed to work, but the second seems to work properly. POints for jwoertink though since it certainly _seemed_ plausible what he was saying. Lol.
<Yxhuvud> what he was saying was true, just not the efficient and clean solution :)
<wakatara> It's kinda cool that both work, but I would not have thought of the first one but was going for the first one just from more idiomatic ruby.
<wakatara> One other niggling thing: I am writing a CLI app. When I use a `results = get` for command line input, I am being asked for it on a new line rather on the same line after after the prompt.
<wakatara> I'm gathering there is an easy way round it in Crystal but just don't know the idiom. Does anyone?
alexherbo2 has quit [Ping timeout: 246 seconds]
<FromGitter> <vladfaust> Kek
<z64> wakatara: check how you are printing the prompt. if its using `puts`, a newline will be written at the end. using `print "foo"` will omit this newline
alexherbo2 has joined #crystal-lang
<wakatara> z64: thank you!
wakatara has quit []
olbat[m]2 is now known as olba4
olba4 is now known as olba6
rohitpaulk has joined #crystal-lang
alexherbo22 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 258 seconds]
<Yxhuvud> that behaviour is the same in ruby, FWIW.
olba6 is now known as olbat[m]
<FromGitter> <mwlang> what's the correct way to cast to a specific type from a NamedTuple? For example, I need to convert to Symbol from a NamedTuple that contains Float64 and Symbol values.
<FromGitter> <mwlang> @pivot_kind = options.fetch(:pivot_kind, :traditional) => instance variable '@pivot_kind' of Indicators must be Symbol, not (Float64 | Symbol)
<FromGitter> <mwlang> I've largely just been tacking on .to_f64 or .to_i32, or .to_s and so on, but starting to wonder if this is the idiomatic way to do it.
<FromGitter> <kinxer> @vladfaust Lack of Windows support is the barrier of inconvenience that keeps me from programming in Crystal at home. I work primarily on Linux at my job, and that's where I was exposed to the language and have been using it, but my personal desktop is Windows 7, and it's just not convenient for me right now to add another computer or Linux partition to my home setup.
<FromGitter> <lsymonds> @kinxer Can you not use Cygwin? Or upgrade to Windows 10 (if possible) and use WSL?
<FromGitter> <lsymonds> Granted it's not ideal to do that
alexherbo223 has joined #crystal-lang
<FromGitter> <kinxer> I mean, there are certainly workarounds. That's why I described it as a barrier of inconvenience. I could certainly use Cygwin or Windows 10 ($$$), or I could even set up a Linux VM using Vagrant and a shared directory (something I use heavily at work) and run my code from that.
alexherbo22 has quit [Ping timeout: 252 seconds]
<FromGitter> <kinxer> It's just that my personal motivation to work on Crystal side projects (which is, of course, not something the language can fix) isn't great enough to overcome the inconvenience.
<FromGitter> <kinxer> Which is why I've recently just been doing side stuff in Python, since it's easy to write in (for the little stuff I'm using it for) and has native Windows support. Of course, it's slow.
rohitpaulk has quit [Ping timeout: 246 seconds]
rohitpaulk has joined #crystal-lang
return0e has quit [Ping timeout: 268 seconds]
return0e has joined #crystal-lang
<FromGitter> <watzon> Is it possible to run `HTTP.get` through a SOCKS proxy?
<FromGitter> <straight-shoota> No, it's currently tied to a TCP transport
<FromGitter> <straight-shoota> But there are plans to change that
<RX14> @straight-shoota if there's any PR that just needs a second review that i've missed in the past few months (just cleaned out my github inbox) please let me know
<FromGitter> <j8r> @mwlang very often, there is a better way than using `Symbol` and `NamedTuple`
<FromGitter> <j8r> The idiomatic way is to used records
<FromGitter> <straight-shoota> RX14, take a look at https://github.com/crystal-lang/crystal/labels/pr%3Aneeds-review
<FromGitter> <straight-shoota> I've tried to label those low hanging fruits
<Yxhuvud> mwlang: well, one way to do type subtraction is to do an if statement.
<FromGitter> <straight-shoota> And probably more which have already been approved: https://github.com/crystal-lang/crystal/pulls?q=is%3Apr+is%3Aopen+review%3Aapproved
<Yxhuvud> looking explicitly at the type.
<RX14> thanks @straight-shoota
<RX14> i've never really used that label :(
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <mwlang> Makes no sense: @pivot = ((high.to_f64 + low.to_f64 + close.to_f64) / 3.0).to_f64 => Can't infer the type of instance variable '@pivot' of Pivot
<FromGitter> <mwlang> trying to figure out where the compiler is failing to infer correct type, so I appended #to_f64 on everything and still get the error.
<z64> @mwlang the compiler currently doesn't know the return type of the expression that makes a call like that (it doesn't know what `.to_f64` returns yet, etc) - see this more basic example https://carc.in/#/r/6uvz
<z64> in this case you have to add an annotation, `@pivot : Float64` in the type body somewhere
lucasb has quit [Quit: Connection closed for inactivity]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <bew> This is pretty cool: https://carc.in/#/r/6uw4 aka being able to override any system behavior with fake ones (here, for the system ENV)
<FromGitter> <bew> this could be used to fake everything in specs very easily! (filesystems, stdin/out, time, env)
<FromGitter> <bew> I'm loving this, will start a shard I think
Liothen has quit [Ping timeout: 248 seconds]
_whitelogger has quit [Ping timeout: 248 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
laaron has quit [Remote host closed the connection]