RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.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
pabs has quit [*.net *.split]
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
_whitelogger has joined #crystal-lang
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
<FromGitter> <j8r> f1refly yes https://crystal-lang.org/api/master/Process.html#run%28command%3AString%2Cargs%3Dnil%2Cenv%3AEnv%3Dnil%2Cclear_env%3ABool%3Dfalse%2Cshell%3ABool%3Dfalse%2Cinput%3AStdio%3DRedirect%3A%3APipe%2Coutput%3AStdio%3DRedirect%3A%3APipe%2Cerror%3AStdio%3DRedirect%3A%3APipe%2Cchdir%3AString%3F%3Dnil%2C%26block%29-class-method
<FromGitter> <j8r> how can I get `require "uri"; puts URI.new(host: "[::1]", port: 8000)` return `[::1]:8000` instead of `//[::1]:8000`?
<FromGitter> <j8r> without `lchop`
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
<FromGitter> <0x2C6> how can I change encoding? I know crystal uses utf8 by default but when I try to render a letter as a json it returns weird characters on the browser(Safari) How can I change this encoding?
<FromGitter> <bew> @straight-shoota Wait what? How can #7377 fix #7687 ? Since he's running on WSL, the stdlib for win32 shouldn't be used (and #7377 shouldn't impact the results).. Or am I looking it wrong?
<DeBot> https://github.com/crystal-lang/crystal/pull/7377 (Fix windows monotonic time bug) | https://github.com/crystal-lang/crystal/issues/7687 (Crystal can't measure time below 1100 nanoseconds) | https://github.com/crystal-lang/crystal/pull/7377 (Fix windows monotonic time bug)
ashirase has quit [Ping timeout: 255 seconds]
ashirase has joined #crystal-lang
Raimondi has quit [Read error: Connection reset by peer]
sz0 has joined #crystal-lang
DmitryBochkarev has joined #crystal-lang
DmitryBochkarev has quit [Client Quit]
alexherbo2 has joined #crystal-lang
alexherbo2 has quit [Client Quit]
alexherbo2 has joined #crystal-lang
<mps> j8r: your PR for gc is accepted right now
<mps> I didn't know for it, and just posted same to patchwork.a.o
laaron has quit [Remote host closed the connection]
<FromGitter> <j8r> mps amazing! :D
laaron has joined #crystal-lang
<mps> I tried to build static crystal and noticed that the new gc-dev doesn't have static libs
<mps> so, I posted patch to enable it, and maintainer told me that there is your patch 11 days old, so he pushed your patch
<mps> maybe you could join #alpine-devel channel when you have some things for 'us'
<FromGitter> <j8r> maybe, but it wasn't urgent
<FromGitter> <j8r> there are a lot of patch/PRs waiting too :/
<mps> yes, but some are crucial, like that one you posted
<FromGitter> <j8r> you need to compile crystal statically?
<FromGitter> <j8r> anyway I didn't it was better to ping on IRC vs GitHub - I may do this in the future
<FromGitter> <j8r> didn't know
<mps> static version is needed to build new version of crystal on builders
<mps> previous static version, I mean
<FromGitter> <j8r> right, now you say this
<mps> I have plan to skip this 'static version' phase but didn't finished it yet
FromGitter has quit [Remote host closed the connection]
oprypin has quit [Quit: Bye]
oprypin has joined #crystal-lang
FromGitter has joined #crystal-lang
oprypin has quit [Quit: Bye]
oprypin has joined #crystal-lang
oprypin has quit [Client Quit]
oprypin has joined #crystal-lang
oprypin has quit [Client Quit]
oprypin has joined #crystal-lang
Raimondi has joined #crystal-lang
oprypin has quit [Quit: Bye]
oprypin has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
fanta1 has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <kinxer> Which 0.28.0 changes are steps toward Windows support?
flaviodesousa has joined #crystal-lang
fanta1 has quit [Quit: fanta1]
<FromGitter> <kinxer> Cool. Thank you.
lucasb has joined #crystal-lang
DTZUZO has quit [Ping timeout: 246 seconds]
Jenz has joined #crystal-lang
Raimondi has quit [Quit: WeeChat 2.3: ¡Chau!]
dannyAAM has quit [Ping timeout: 264 seconds]
<Jenz> These new "begin-less and end-less ranges" are amazing!
dannyAAM has joined #crystal-lang
<FromGitter> <tenebrousedge> how so?
<Jenz> Uh, well, I just love em! :D
<FromGitter> <tenebrousedge> how have you used them?
<Jenz> I haven't, but I've used very similar constructs in other languages (like julia)
<Jenz> And I bet I'll use them from now on, I've wanted to have a go at implementing a mathematical shard, with multidimensional arrays like in julia numpy and similiar, which I'm sure will be a huge failure
* Jenz :D
<z64> hm, am i missing something with the new deprecation system? if i have a file with `Time.utc_now`, should it emit a warning when built with `--warnings all`?
<Jenz> No I don't think so, isn't it Time.new that is deprecated?
<FromGitter> <kinxer> I expect that they'll be really nice for slicing arrays and such. ⏎ ⏎ ```arr.each(start: 3, count: arr.size - 3) { ... }``` [https://gitter.im/crystal-lang/crystal?at=5cb89cb94b4cb471d919c1b4]
<FromGitter> <kinxer> @z64 I think it should emit a warning, yes. Is it not?
<Jenz> kinxer, you can just do arr.each(3..) { ... }
<Jenz> Um wait
<z64> i just did `echo 'Time.utc_now' > test.cr` and `crystal build --warnings all test.cr` and nothing was shown
<Jenz> I mean ofc `arr[3..].each { ... }` haha
<Jenz> And @tenebrousedge, thanks for being an exercism mentor! :) It's great
<z64> yeah end-less ranges are nice for that. i never liked `a[3..-1]`
<FromGitter> <kinxer> @Jenz Right you are. Even better. :P
<FromGitter> <r00ster91> z64: it works for me. Are you sure you updated to 0.28.0?
<z64> i'm using the official 0.28 docker image.
<FromGitter> <r00ster91> thats strange
<Jenz> And `arr[..]` is pretty cool, sure it's no use to do it like so (as it's the same as just `arr`), but with something like `r = cond ? 3..10 : ...` then `arr[r]`
<z64> um, nevermind, seems to work now. weird
* Jenz O_o
<FromGitter> <Blacksmoke16> :trollface:
<FromGitter> <tenebrousedge> @Jenz, are you going through the Crystal track on exercism?
Raimondi has joined #crystal-lang
<Jenz> Yeah, I'm of your irritating students, right now you're reviewing the main track Triangle exercise of mine, and you've helped greatly on the side track exercise Forth
<Jenz> s/I'm of/I'm one of/
<FromGitter> <tenebrousedge> I'm pretty sure you're my least irritating student :)
<Jenz> Huh? Sounds weird, well, thanks I guess, I had always thought I must be very irritating
<Jenz> Haha
alexherbo2 has quit [Ping timeout: 245 seconds]
<FromGitter> <tenebrousedge> You know what you're doing. Yesterday I was reviewing some Ruby code that used `while` and an explicit counter to iterate through a string in-order. I think I've even seen someone use a `for` loop recently. And you know, I try to say nice things about the code I review, but sometimes it's a considerable effort
<FromGitter> <j8r> @tenebrousedge do you use a linter to help you for this reviews?
<Jenz> Haha, during the Forth review it was made quite clear you didn't like my until loop. I kept it :P
<FromGitter> <tenebrousedge> @j8r not typically. I will often point people towards them or suggest things that e.g. `rubocop` would dislike, but I at least like to think that I've memorized those rules
<FromGitter> <j8r> to some extend, you are a like a ++linter :)
<FromGitter> <tenebrousedge> `until` and `while` should not be used when the number of iterations is knowable, as a general rule, but the rules aren't unalterable mathematical laws. To say that this is an empirical profession is probably overly generous: our rules are at best based on subjective experience, and at worst, everybody repeating the same thing
* Jenz :o
<Jenz> A very pragmatic and prophetic speech
<mps> tenebrousedge: well told, +1
<FromGitter> <tenebrousedge> so, I don't like either of those constructs, because they're forms of iteration that don't have the `Enumerable` methods available, and I think that's sort of limiting. However, they can also be necessary. I don't know that there is a way to write e.g. Pollard's rho algorithm for prime factorization without using a `while` loop. But either way, if someone else chooses to code using `while` loops, then I
<FromGitter> ... think that "I don't like that" is as much as I have any business in saying, and I think it's totally fine for someone else to have their own opinions on the matter
<FromGitter> <Blacksmoke16> tbh i never used a while loop so far in crystal
<FromGitter> <Blacksmoke16> :S
<Jenz> I've used a lot of `until`-loops, but no `while`-loops AFAICR
<Jenz> I like `until`-loops XD
<FromGitter> <kinxer> I use while loops to wait for and handle socket communication. I don't think I've ever used them in Crystal outside of that.
<FromGitter> <Blacksmoke16> while loop meaning loop forever then like `break if xxx`?
<FromGitter> <Blacksmoke16> `while true` i mean
* Jenz throws a `loop do` at Blacksmoke16
<FromGitter> <Blacksmoke16> yea, thats what i was going to suggest
<FromGitter> <Blacksmoke16> then he wont use them either ha
<FromGitter> <kinxer> @Blacksmoke16 I can't find one of those that I've written (I've not done a lot of socket communication). I try to make it conditional on something that might actually change.
<FromGitter> <kinxer> Often the loop is in another fiber (and has a blocking method in it), so it can be stopped by calling a method on some object.
<FromGitter> <kinxer> I do like the syntax of `loop do`, but I don't think I've actually used it.
<FromGitter> <j8r> I use `while` with buffer
<FromGitter> <j8r> while the buffer isn't full, keep filling it
<FromGitter> <tenebrousedge> I've used `loop do` in creating an `Enumerator` in Ruby. My tendency would be to wrap a low-level construct like that in something that I can use `map` on
<FromGitter> <jwoertink> So I decided to take a stab at making a PR to the compiler... I'm definitely in over my head, but I'd really like to understand this stuff. Anyone around with some knowledge in this area available for some questions?
<FromGitter> <Blacksmoke16> What part of the compiler?
<FromGitter> <jwoertink> I'm currently poking around `src/compiler/crystal/semantic/call_error.cr`
<FromGitter> <jwoertink> in `Crystal::Path`
<FromGitter> <Blacksmoke16> 😬 never heard of it :p
<FromGitter> <jwoertink> 😂
<FromGitter> <jwoertink> We have a `Crystal::Path` and `Crystal::CrystalPath` .... not confusing at all 😆
<FromGitter> <Blacksmoke16> One might be an internal thing while the other is exposed to the user?
<Jenz> The second is the macro-time (or whatever it's called) type of a path literal (e.g YAML), while `Crystal::Path` is the compiler-internal type of a path
<Jenz> I think
<FromGitter> <Blacksmoke16> I remember seeing the former in some of my macro work
<Jenz> I've always been a bit confounded by the Crystal module
<FromGitter> <jwoertink> When you see the error "undefined constant Whatever", that "Whatever" part seems to be an instance of `Crystal::Path`
<FromGitter> <jwoertink> which is the thing I'm wanting to change, but this class is so small, I don't know what I have access to
<FromGitter> <jwoertink> And then there's this argument passed in to this method called `type` that seems to be a `Crystal::NumberLiteralType` which makes no sense to me
<FromGitter> <jwoertink> but somehow this `Crystal::NumberLiteralType` knows how to take the `Crystal::Path` and figure out if it's a private constant or not 😖
<Jenz> The more I look at this, the more I am confused, not by the Path implementation, but by the NumberLiteralType
<Jenz> Are you sure there's nothing else that is causing a NumberLiteralType being passed to Crystal::Path#raise_undefined_constant ?
<FromGitter> <jwoertink> I have it failing on my spec that I wrote
<FromGitter> <jwoertink> I changed the `self.raise` to just do `self.raise("moo #{type.name}")`
<FromGitter> <jwoertink> > undefined method 'name' for Crystal::NumberLiteralType (compile-time type is Crystal::Type+)
<FromGitter> <jwoertink> though... it is a compile error... so maybe it's not what I'm thinking...
<FromGitter> <jwoertink> I appreciate it.
alexherbo2 has joined #crystal-lang
<Jenz> There seems to be this weird interchangeability between Types and Constants, I'm just throwing random thoughts
<FromGitter> <jwoertink> It's definitely a bit confusing at first glance. I'm sure it becomes easier the more you poke around in this
go|dfish has joined #crystal-lang
<FromGitter> <0x2C6> how can I change encoding? I know crystal uses utf8 by default but when I try to render a letter as a json it returns weird characters on the browser(Safari) How can I change this encoding?
Jenz has quit [Ping timeout: 245 seconds]
<FromGitter> <kinxer> Do you know what encoding you need?
flaviodesousa has quit [Quit: KVIrc 4.9.3 Aria http://www.kvirc.net/]
<FromGitter> <kinxer> Also, how are you outputting this json?
Jenz has joined #crystal-lang
<Jenz> @0x2C6: What do you mean by "render a letter as a json" ?
<FromGitter> <Blacksmoke16> after writing that annotation section, i found out some new things about annotations
<FromGitter> <Blacksmoke16> like positional arguments are allowed before, but not after named arguments?
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6qvg but if you move it before `foo` it works, not sure if that is intended or not...
<FromGitter> <Blacksmoke16> also having some additional methods on `Annotation` type would be nice, like im thinking `size`, `keys`, `values`?
<FromGitter> <Blacksmoke16> where like size would be the number of total arguments, keys would be keys of named args, and values would be all positional and values of named arguments
<FromGitter> <Blacksmoke16> would be better if you could only have positional OR named arguments tho...
<FromGitter> <Blacksmoke16> main use case is allow iterating over each positional argument, which atm is not possible unless you know the exact number of values ahead of time
<FromGitter> <Blacksmoke16> prob write up an issue for this later
<FromGitter> <0x2C6> For example I'm gonna render something and result is that {"currency":"1 CÉ™nubi Afrika randı"} it should be "1 Cənubi Afrika randı" I know maybe it's not about the crystal but maybe someone knows why. I encountered with this problem in safari browsers. Chrome is okay
<FromGitter> <bew> @Blacksmoke16 about positional args, it's expected, regular method call has the same logic
<FromGitter> <Blacksmoke16> gotcha, so its really just up to the user to not do something stupid :P
<FromGitter> <kinxer> @0x2C6 Could you give some example Crystal code of how you're creating and outputting your json?
lucasb has quit [Quit: Connection closed for inactivity]
<FromGitter> <0x2C6> @kinxer :D from web scraping. it parses values from the bank's web site and collect them all into an hash
* Jenz o_O
<FromGitter> <0x2C6> ```code paste, see link``` ⏎ ⏎ I also set content_type to json on application_controller [https://gitter.im/crystal-lang/crystal?at=5cb8db1fe416b84519a01dfc]
<FromGitter> <0x2C6> And Open to suggestions. How can simplify that code ? :D
<FromGitter> <0x2C6> it works well on chrome but on safari somesh*t happens :(
<FromGitter> <fridgerator> what about setting the `charset` header? https://www.w3.org/International/articles/http-charset/index#charset
<Jenz> I've never really used the HTTP client, but glancing at the docs, there's this: file:///usr/share/doc/crystal/api/HTTP/Client/Response.html#charset%3AString%3F-instance-method
<Jenz> Oh, that might be the other way around
<Jenz> As mentioned, I don't really know what I'm doing, but maybe `context.response.headers["Content-Type"] = "application/json; charset=utf-8"`
<FromGitter> <Blacksmoke16> thats one way to do it yes
<FromGitter> <Blacksmoke16> `context.response.content_type = "application/json; charset=utf-8"` would prob also do the trick
<FromGitter> <Blacksmoke16> which internally does the same thing
* Jenz :D
<FromGitter> <Blacksmoke16> :p
<Jenz> I'd never thought I was right, haha
<Jenz> Thanks for the clarification
<FromGitter> <Blacksmoke16> `ctx.response.headers.add "Content-Type", "application/json; charset=utf-8"` also works :S
<Jenz> As does `ctx.response.headers.merge!(HTTP::Headers.new.tap &.[]=("Content-Type", "application/json; charset=utf-8"))` -- I think
* Jenz :z
<FromGitter> <Blacksmoke16> oh boy
<Jenz> Not that it's a very good idea haha
sz0 has quit [Quit: Connection closed for inactivity]
Jenz has quit [Quit: leaving]
<FromGitter> <drum445> Hi all, does anyone know why in kemal `env.redirect` doesn't exit the block?
<FromGitter> <drum445> it runs the code below it :O
<sagax> hi all!
<sagax> we have some little examples with small programs?
<FromGitter> <Blacksmoke16> examples of anything in particular?
<FromGitter> <dscottboggs_gitlab> are you looking for examples or saying that you have produced some @sagax?
<FromGitter> <Blacksmoke16> @sullivg2 https://crystal-lang.org/2019/04/17/crystal-0.28.0-released.html does a good overview of stuff
<sagax> i looking for examples
<sagax> some small programs
<FromGitter> <dscottboggs_gitlab> there is a really nice collection as a part of the source tree
<sagax> with some specific target
<sagax> thanks, will be see
<FromGitter> <dscottboggs_gitlab> I posted the link above
<FromGitter> <Blacksmoke16> so i made some breaking but nice changes to CrSerializer
<FromGitter> <Blacksmoke16> i realized i could have done `delegate assertions, errors, invalid_properties, valid?, validate, to: @validator`
<FromGitter> <Blacksmoke16> so now you can just do like `model.valid?` vs `model.validator.valid`
<FromGitter> <Blacksmoke16> also the module is now a generic, so if you want to support JSON format you do `include CrSerializer(JSON)`, for YAML `include CrSerializer(YAML)`, for both `include CrSerializer(JSON | YAML)`
<FromGitter> <Blacksmoke16> 💯
<FromGitter> <Blacksmoke16> or if you dont want any can just but some garbage in like `include CrSerializer(Int32)` or whatever