RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.25.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
<FromGitter> <Daniel-Worrall> Oh I saw that but didn't think of it that way. Probably
<FromGitter> <bmulvihill> This seems to do the trick https://carc.in/#/r/4iyy
<FromGitter> <Daniel-Worrall> https://carc.in/#/r/4iyz
<FromGitter> <Daniel-Worrall> well that one is better than mine
<FromGitter> <Daniel-Worrall> thanks
<FromGitter> <Daniel-Worrall> weirdly enough ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ this one benchmarks the fastest [https://gitter.im/crystal-lang/crystal?at=5b4bebc7866e0c6b15adcc24]
<crystal-gh> [crystal] MakeNowJust opened pull request #6392: Format: fix to use right alignment only if all whens are number literal (master...fix/crystal-format/right-alignment-only-if-all-whens-numbers) https://git.io/fNYop
<crystal-gh> [crystal] MakeNowJust opened pull request #6393: Format: fix comment indentation in case's else (master...fix/crystal-format/6391) https://git.io/fNYKt
phvse has joined #crystal-lang
renzhi has quit [Quit: WeeChat 2.1]
renzhi has joined #crystal-lang
phvse has quit [Ping timeout: 240 seconds]
<FromGitter> <snadon> Anyone using heroku with crystal and got `Error R10 (Boot timeout)`?
benharri has quit [Remote host closed the connection]
benharri has joined #crystal-lang
return0e has quit []
<FromGitter> <snadon> NVM I found my error, was using `127.0.0.1` instead of `0.0.0.0`
benharri has left #crystal-lang ["not here right now..."]
moei has quit [Quit: Leaving...]
moei has joined #crystal-lang
moei has quit [Quit: Leaving...]
<FromGitter> <Grabli66> Hi! Is it a bug? https://play.crystal-lang.org/#/r/4izy
<FromGitter> <j8r> that's not a bug, you print a Class
<FromGitter> <bew> I think he's talking about the abstract def that's not implemented
<FromGitter> <bew> It's not a bug, when you include a module with abstract defs, if you don't try to call the method it doesn't complain about it being missing
<FromGitter> <bew> Iirc that abstract defs in a class (or struct) are different (don't ask me why) they errors if the're not implemented in the child classes (can't check right now..)
<FromGitter> <Grabli66> I does not throw error that i have to implement abstract def
<FromGitter> <Grabli66> Ok
<FromGitter> <j8r> you have to use inheritance with the `Myclass < Other`
rohitpaulk has joined #crystal-lang
<crystal-gh> [crystal] RX14 closed pull request #6392: Format: fix to use right alignment only if all whens are number literal (master...fix/crystal-format/right-alignment-only-if-all-whens-numbers) https://git.io/fNYop
<crystal-gh> [crystal] RX14 pushed 1 new commit to master: https://git.io/fNYhx
<crystal-gh> crystal/master 466e0a2 TSUYUSATO Kitsune: Format: fix comment indentation in case's else (#6393)...
alex`` has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
<travis-ci> crystal-lang/crystal#210d8ef (master - Format: fix to use right alignment only if all whens are number literal (#6392)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/404375502
<DeBot> https://github.com/crystal-lang/crystal/pull/6392 (Format: fix to use right alignment only if all whens are number literal)
<travis-ci> crystal-lang/crystal#466e0a2 (master - Format: fix comment indentation in case's else (#6393)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/404376323
<DeBot> https://github.com/crystal-lang/crystal/pull/6393 (Format: fix comment indentation in case's else)
<FromGitter> <asterite> It's a bug, but it's already reported (abstract methods aren't currently checked for generic types)
Nik736 has joined #crystal-lang
Nik736 has quit [Client Quit]
<FromGitter> <kolyaio> Getting error when trying to compile amber on the server. ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ What should I do ? ... [https://gitter.im/crystal-lang/crystal?at=5b4c80d1c02eb83d7c7d3970]
<FromGitter> <asterite> Moar ram
rohitpaulk has joined #crystal-lang
<FromGitter> <Grabli66> Hi! Do you think it's normal? https://play.crystal-lang.org/#/r/4j44
<FromGitter> <Grabli66> Compiler changed my type from Int32 to (Int32 | UInt8) and i got 0 . https://play.crystal-lang.org/#/r/4j4j
rohitpaulk has quit [Ping timeout: 244 seconds]
<FromGitter> <asterite> Yup, overflow. Maybe in a next version that will raise.
<FromGitter> <Grabli66> Good :)
<FromGitter> <kolyaio> @asterite how much more ?
<FromGitter> <straight-shoota> @kolyaio depends on the size of your project
<FromGitter> <straight-shoota> I don't know how much a typical amber project needs. You could ask at https://gitter.im/amberframework/amber
<FromGitter> <straight-shoota> maybe 2 gig will suffice
<FromGitter> <straight-shoota> if you want to keep your server instance small (because you probably don't need that much memory for running the server), you could just build locally / on a different system and deploy the compiler binary to your server
<FromGitter> <j8r> To use even less memory you could also activate ram compression with https://en.wikipedia.org/wiki/Zswap :)
<FromGitter> <j8r> more infos at https://wiki.archlinux.org/index.php/Zswap
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 256 seconds]
duane has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 244 seconds]
rohitpaulk has joined #crystal-lang
moei has joined #crystal-lang
<FromGitter> <bararchy> How come ⏎ ⏎ ```int = 8 ⏎ case int ⏎ when .size > 2 ⏎ do stuff ⏎ end``` ⏎ ⏎ wont compile? [https://gitter.im/crystal-lang/crystal?at=5b4ca86d1c0f906b145dd266]
<FromGitter> <bararchy> is this a bug in the parser?
renzhi has quit [Ping timeout: 240 seconds]
<FromGitter> <straight-shoota> @bararchy Implicit object syntax in `when` conditions doesn't allow chaining methods
rohitpaulk has quit [Ping timeout: 268 seconds]
<FromGitter> <straight-shoota> I don't think that's a bug. It could probably be changed, though. But as a feature.
<FromGitter> <bararchy> @straight-shoota I guess i missed this, I see in Ruby it also raises `SyntaxError:` so ... idk :)
<FromGitter> <bararchy> thanks @straight-shoota
renzhi has joined #crystal-lang
FromGitter has quit [Remote host closed the connection]
FromGitter has joined #crystal-lang
<FromGitter> <straight-shoota> sometimes it would really be handy, though
<FromGitter> <j8r> but you can https://carc.in/#/r/4j74
<FromGitter> <straight-shoota> @j8r yes, you can use `.>`. But not `.size.>`. It's about chaining method calls.
<FromGitter> <j8r> indeed:)
FromGitter has quit [Read error: Connection reset by peer]
FromGitter has joined #crystal-lang
akaiiro has joined #crystal-lang
<FromGitter> <fridgerator> Is any one familiar with `Process.run` with a block, and `$?` ?
<FromGitter> <fridgerator> will `$?` alwyas reference the last `Process.run` ?
<FromGitter> <fridgerator> or is there a better way to get the status of `Process.run` with a block ?
rohitpaulk has joined #crystal-lang
wontruefree has joined #crystal-lang
<FromGitter> <rishavs> Quick question. Is creating/parsing a hash object faster and leaner than doing the same to an equivalent Json object?
<FromGitter> <j8r> In crystal? Of course
<FromGitter> <rishavs> thanks @j8r
<FromGitter> <j8r> JSON is a string, that have to be converted to a Hash of String, Int etc, and/or be parsed char by char
<FromGitter> <j8r> Of course in any time you can do `you_hash.to_json` 😏
<FromGitter> <talbergs> @fridgerator could you show us snippet of your current progress?
<FromGitter> <fridgerator> @talbergs no progress to show really, just running process with a block, and trying to get the exit code and exit status
<FromGitter> <fridgerator> ```Process.run(whatever) do |proc| ⏎ end ⏎ ⏎ puts $?``` [https://gitter.im/crystal-lang/crystal?at=5b4cc74e1c0f906b145f0639]
<FromGitter> <fridgerator> `$?` is the Process::Status, I'm just curious if it will ALWAYS be the last `Process.run` status, or if there is a better way to get the status
<FromGitter> <talbergs> wow does that one above actually work? `$?` <- looks like bash
<FromGitter> <fridgerator> lol yeah
<FromGitter> <fridgerator> https://crystal-lang.org/api/0.25.1/toplevel.html#system%28command%3AString%2Cargs%3Dnil%29%3ABool-class-method
<FromGitter> <talbergs> ```Process.run(whatever) do |proc| ⏎ puts proc.status. exit_status ⏎ end``` ⏎ ⏎ looking at api might be so.. [https://gitter.im/crystal-lang/crystal?at=5b4cc7df95e03e3d7b568be8]
<FromGitter> <j8r> maybe not the best idea
<FromGitter> <j8r> the `$?` sounds weird
<FromGitter> <fridgerator> I didnt see a `status` attribute on `Process`, hrmm
<FromGitter> <talbergs> it's pure bash syntax. `Process.run('la; echo $?')
<FromGitter> <fridgerator> yeah, there definitely isn't `proc.status` doesn't exist
<FromGitter> <fridgerator> yeah using `$?` feels super weird, thats why I'm wondering if there is a better way
<FromGitter> <fridgerator> `Process.run` without a block returns a `Process::Status`
<FromGitter> <j8r> you can assign to a variable
<FromGitter> <j8r> don't remember correctly, maybe Process.new, then exec, and then status
<FromGitter> <fridgerator> ok, I might have to do it without a block then
<FromGitter> <j8r> you can without
<FromGitter> <talbergs> I recently worked with `Process` + `block`. This what came out of that: https://gitlab.com/martinsaleksandrs/_1/blob/master/src/proccer.cr maybe helps.
<FromGitter> <fridgerator> I was using a block, becuase I want to read standard output as its printed
<FromGitter> <talbergs> same here - stdout and stderr
<FromGitter> <talbergs> forwarded to web client - as it happens
<FromGitter> <fridgerator> but this doesn't work: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b4ccb751c0f906b145f2858]
<FromGitter> <j8r> Running processes in Crystal isn't intuitive, for me :|
<FromGitter> <talbergs> yes there is some blocking idk.. thats why I do not create pipe my own. But us the default one created (process run without "output: " passed) ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b4ccc7d66c1e833a9ef5a9f]
<FromGitter> <fridgerator> @j8r yes I can do `output.to_s` after it has run, that works for me as well
<FromGitter> <talbergs> no, but looked at it, as I will have to jump on gql train any day now
<jokke> mmh same here
<jokke> seems very immature yet (the lib)
<jokke> and not actively developed :/
<FromGitter> <talbergs> tru
<jokke> i really want to use crystal for our next api project but it might be necessary to use graphql
<FromGitter> <talbergs> atlternative is to roll your own :D Or maybe port some lik=b like `railt`
akaiiro has quit [Remote host closed the connection]
rohitpaulk has quit [Ping timeout: 248 seconds]
akaiiro has joined #crystal-lang
alex`` has quit [Quit: WeeChat 2.1]
alex`` has joined #crystal-lang
<crystal-gh> [crystal] sdogruyol pushed 1 new commit to master: https://git.io/fNO9B
<crystal-gh> crystal/master c6f4fd9 Faustino Aguilar: Fix missing comment inside code block example (#6387)
<jokke> talbergs: hm i might roll my own. i'd like to write bindings to the c api
<jokke> (parser lib)
<FromGitter> <talbergs> which C lib you have in mind?
<jokke> libgraphqlparser
<jokke> graphql-crystal uses a pure crystal parser but it's way slower
<jokke> libgraphqlparser uses bison i think
<FromGitter> <talbergs> git hubs down at my continent :( https://twitter.com/githubstatus
<FromGitter> <talbergs> but writing a lexer must be a tough one, never done it.
<FromGitter> <talbergs> Thai dude from `railt` implemented hes own parser and beat some mainstream gql lib 10times
DTZUZO has quit [Ping timeout: 264 seconds]
<FromGitter> <fridgerator> @talbergs @j8r so this works: https://carc.in/#/r/4j9c
<FromGitter> <fridgerator> surely there's a better way though
duane has quit [Ping timeout: 265 seconds]
<travis-ci> crystal-lang/crystal#c6f4fd9 (master - Fix missing comment inside code block example (#6387)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/404544370
<DeBot> https://github.com/crystal-lang/crystal/pull/6387 (Fix missing comment inside code block example)
<FromGitter> <drum445> What linux distro do you guys use?
wontruefree has quit [Quit: bye]
alex`` has quit [Ping timeout: 240 seconds]
<FromGitter> <talbergs> :D https://github.com/tiagoad/suicide-linux
<FromGitter> <talbergs> osx
<FromGitter> <fridgerator> @talbergs @j8r https://carc.in/#/r/4j9f ;)
<FromGitter> <Daniel-Worrall> Is there an easy way to get `Enumerable#index` to not return a nilable object?
<FromGitter> <talbergs> @fridgerator that's beautiful
<FromGitter> <fridgerator> It seems like returning the process status from `Process.run` with a block should be in stdlib
<FromGitter> <bew> No, you must handle the case where index can't find something @Daniel-Worrall
alex`` has joined #crystal-lang
<FromGitter> <Daniel-Worrall> Shame
<FromGitter> <Daniel-Worrall> I think I found a different solution to my problem though
<FromGitter> <bew> But nilable is good, you should not dismiss them
<FromGitter> <Daniel-Worrall> It is, but I wanted to get an index of something I knew had to exist there without the extra assign and `if` check
<FromGitter> <bew> If you're 100% sure, you can use `not_nil!`
wontruefree has joined #crystal-lang
<FromGitter> <Daniel-Worrall> `Enumerable#find` has a `if_none` parameter, I think `#index` should too
<FromGitter> <Daniel-Worrall> The difference being find can find any object, and index is always 0-size which is why nil makes the most sense
<FromGitter> <Daniel-Worrall> so the if_none is for giving a nil-like object of the Enumerable returns
<FromGitter> <bew> What do you mean by "nil-like"?
duane has joined #crystal-lang
<FromGitter> <bew> Ah just a default... You can do the same with `idx = en.index(x) || -1`
<FromGitter> <Daniel-Worrall> ah yeah
<FromGitter> <Daniel-Worrall> I'm running into so many X-Y problems with this
<FromGitter> <jwaldrip> Does crystal have support for assymetric encryption?
return0e has joined #crystal-lang
DTZUZO has joined #crystal-lang
<FromGitter> <jwoertink> When using the `SO_REUSEPORT` and you have the app booted multiple times, is a process manager needed to direct traffic between all the apps? Or does the OS just handle that?
<FromGitter> <jwoertink> like if I have 4 processes booted, how will it know to use all 4 of them, and not just keep sending requests to the first process?
FromGitter has quit [Remote host closed the connection]
oprypin has quit [Quit: Bye]
FromGitter has joined #crystal-lang
oprypin has joined #crystal-lang
<FromGitter> <talbergs> Looks a lot like OS level decision.
<FromGitter> <jwoertink> Sweet. I guess that makes it easier to use
<FromGitter> <Daniel-Worrall> What can cause such variation in benchmarking?
<FromGitter> <Daniel-Worrall> Changed nothing
<FromGitter> <rishavs> How do I cast arrays? Trying something like; ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5b4d0e8c866e0c6b15b5fc3b]
<RX14> Just wrote a bit about Crystal on WIndows https://medium.com/futuredev/the-state-of-crystal-on-windows-c465a9fd4c4b
<Vexatoast> RX14, I feel like I've read this before
alex`` has quit [Quit: WeeChat 2.1]
duane has quit [Ping timeout: 240 seconds]
<FromGitter> <diegogub> Hi guys! Starting out with nim..I was wondering how could I map JSON:Any to class
<FromGitter> <diegogub> any idea?
<FromGitter> <Blacksmoke16> do that you can make a class from json?
<FromGitter> <Blacksmoke16> @diegogub
wontruefree has quit [Ping timeout: 248 seconds]
<FromGitter> <diegogub> @Blacksmoke16 I had JSON:Any object, what I did is : event.data.as_h.to_json()
<FromGitter> <diegogub> I don't know if its the best solution..but it worked
<FromGitter> <diegogub> ``` e = {{event_type}}.from_json(event.data.as_h.to_json()) ```
<FromGitter> <Blacksmoke16> take a look at that link
<FromGitter> <Blacksmoke16> should allow you to do like `e = {{event_type}}.from_json(event)`once you define your properties and such
<FromGitter> <Blacksmoke16> er assuming event is the json string...
<crystal-gh> [crystal] straight-shoota opened pull request #6397: (WIP) Optimize String#gsub with block (master...jm/feature/gsub-optimize) https://git.io/fN33z
<FromGitter> <fridgerator> is JSON::Serializable meant as a replacement for JSON::Mapping ?
<FromGitter> <Blacksmoke16> atm they do pretty much the same thing, just in a diff manner, but Serializable has a few more features
<FromGitter> <Blacksmoke16> afaik
<FromGitter> <fridgerator> Ok thats what I thought
<FromGitter> <aisrael> Hey, so TIL about annotations, e.g. `@[JSON::Field(key: "my_key", emit_null: true)]`. I can't seem to find the documentation on them though?
<FromGitter> <Blacksmoke16> talks about it under usage section
<FromGitter> <aisrael> I meant how about how to write and use annotations in general.
<FromGitter> <aisrael> Specifically, has anyone attempted an annotation-based ORM yet?
<FromGitter> <Blacksmoke16> ooo they are talked about a bit in the PR let me find it
<FromGitter> <aisrael> thanks 👍
<FromGitter> <aisrael> (I'll probably dive into the source of JSON::Serializable when I have time anyway...)
<FromGitter> <aisrael> Ahh... so they used to be called "Attributes" (and still are, in the docs)
<FromGitter> <Blacksmoke16> a `value_only` JSON field would be cool
<FromGitter> <Blacksmoke16> brought this up yesterday
<FromGitter> <Blacksmoke16> that would work similar to the `key` property but keep your instance variable name when encoding object to json
<FromGitter> <Blacksmoke16> that way if you have some third party API you could easily instantiate and transform it into what you use internally
<FromGitter> <Blacksmoke16> and @aisrael is a PR for granite that brings `JSON::Serializable` support, including the annotations
<FromGitter> <Blacksmoke16> e.x. `field name : String, json_options: {ignore: true}`
<FromGitter> <Blacksmoke16> anyone know if you can conditionally apply a `:nodoc:`?
<FromGitter> <bew> with macros?
<FromGitter> <Blacksmoke16> that could be an option
<FromGitter> <Blacksmoke16> ah yea that was easy
DTZUZO has quit [Ping timeout: 260 seconds]