RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.26.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
DTZUZO has joined #crystal-lang
ua has joined #crystal-lang
non-aristotelian has quit [Quit: non-aristotelian]
vikaton has quit [Quit: Connection closed for inactivity]
moei has quit [Ping timeout: 252 seconds]
<FromGitter> <dscottboggs_gitlab> @bajro17 omb that video was hilarious
moei has joined #crystal-lang
sevensidedmarble has joined #crystal-lang
sevensidedmarble has quit [Quit: WeeChat 2.2]
<FromGitter> <KevinSjoberg> Do yo
<FromGitter> <vusaalab> what is the best way to call command console , do i want to user process?
<FromGitter> <dscottboggs_gitlab> what
<FromGitter> <codenoid> backtick (?)
<FromGitter> <vusaalab> yes
<FromGitter> <bararchy> @Sija listening to Metal doesn't mean one is childish. There are a lot of bands out there with much more adult minded lyrics then "fuck the system", take a look at 'tool' for example , listen to 'sober' or 'parabole' those are amazing songs which are metal genere but aim at much deeper topics. Also, another favorite of mine is " mars red sky - arcedia"
<FromGitter> <vusaalab> io = MemoryIO.new ⏎ Process.run(command, shell: true, output: io) may be this will work
<FromGitter> <codenoid> yes
<FromGitter> <codenoid> so you want read process stdout
<FromGitter> <codenoid> ok
<FromGitter> <dscottboggs_gitlab> isn't there a Process.run "command" { |io| ... } ?
<FromGitter> <dscottboggs_gitlab> the problem with backticks is there's no stderr/exit code.
<FromGitter> <vusaalab> I want read and write
<FromGitter> <dscottboggs_gitlab> or stdin
<FromGitter> <dscottboggs_gitlab> https://crystal-lang.org/api/0.26.1/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> <dscottboggs_gitlab> so the code would be like
<FromGitter> <dscottboggs_gitlab> ```Process.run "command", input: "input" do....```
<FromGitter> <codenoid> Process.run
<FromGitter> <vusaalab> Thanks yes this will works
<FromGitter> <codenoid> heavy metal - high octane band
shmibs has joined #crystal-lang
DTZUZO has quit [Ping timeout: 260 seconds]
<FromGitter> <vusaalab> why i am getting this error, undefined method '[]' for JSON::Any.class (compile-time type is (JSON::Any | JSON::Any.class))
<FromGitter> <vusaalab> @metadata[:stream]
moei has quit [Ping timeout: 252 seconds]
<FromGitter> <fusillicode_twitter> Hi guys, sorry as always for the bother, quick question. Is there a way to get the name of the method when you're inside it? I couldn't find anything aside from `self.class` 🤔
ashirase has quit [Ping timeout: 245 seconds]
ashirase has joined #crystal-lang
<FromGitter> <j8r> That's a strange question, why do you need this?
<FromGitter> <j8r> Perhaps with macros it's possible, don't know
<FromGitter> <fusillicode_twitter> Well I would like to log something inside an object instance method and considering that `self.class` is available I was wondering if there was something similar for methods :)
<FromGitter> <fusillicode_twitter> @j8r btw I was able to solve the problem I had yesterday with the hashes with something like this ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5baf4342435c2a518e2598c8]
<FromGitter> <fusillicode_twitter> jftr the first problem was related to the type inference that wasn't able to properly infer the one line conditional I had before these 3 lines: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5baf43c4ef4afc4f28f15bad]
<FromGitter> <fusillicode_twitter> the second one was related to uninitialized arrays (i.e. Array(Tuple(String, JSON::Any))) for the new hashes keys and I had it solved with an explicit check: ⏎ `acc[prop1] = Array(Tuple(String, JSON::Any)).new unless acc.has_key?(prop1)`
<FromGitter> <fusillicode_twitter> :)
<FromGitter> <bajro17> best song on world I work with this one 4 days without stop https://www.youtube.com/watch?v=J0N1yY937qg
<FromGitter> <vusaalab> @vusaalab ⏎ why i am getting this error, undefined method '[]' for JSON::Any.class (compile-time type is (JSON::Any | JSON::Any.class)) ⏎ @metadata[:stream]
<FromGitter> <vusaalab> @metadata = JSON.parse(output.to_s).as_a
<FromGitter> <vusaalab> @metadata[:stream]
<FromGitter> <bajro17> @vusaalab I have same problem with JSON::Any
<FromGitter> <bajro17> I fix it with .to_a
<FromGitter> <vusaalab> @bajro17 thanks you i will check that
<FromGitter> <r00ster91> try `.as(JSON::Any)`
<FromGitter> <vusaalab> tried but no luckOverloads are: ⏎ ⏎ 1) JSON::Any# (index : Int) ⏎ 2) JSON::Any# (key : String) ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5baf46f9640179275b6d1ae7]
<FromGitter> <vusaalab> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5baf476e3844923661ba351c]
<FromGitter> <r00ster91> try `p @metadata["streams"]`
<FromGitter> <vusaalab> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5baf47d11e23486b93605ce5]
<FromGitter> <r00ster91> can you show you how initialized `@metadata`
<FromGitter> <vusaalab> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5baf4825640179275b6d22ab]
<FromGitter> <vusaalab> code look like this
<FromGitter> <vusaalab> what is the wrong with this
<FromGitter> <r00ster91> you assigned `@metadata` to the JSON::Any class. You didnt create an instance of this. ⏎ try: JSON::Any.new
<FromGitter> <vusaalab> i tried that previously there was error wrong number of arguments for 'JSON::Any.new' (given 0, expected 1)
<FromGitter> <r00ster91> here are the constructors: https://crystal-lang.org/api/0.26.1/JSON/Any.html#new%28raw%3AType%29-class-method
<FromGitter> <r00ster91> you could give a Type
<FromGitter> <r00ster91> so for example String
<FromGitter> <r00ster91> `@metadata = JSON::Any.new(String)`
moei has joined #crystal-lang
<FromGitter> <codenoid> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5baf4959435c2a518e25b516]
<FromGitter> <vusaalab> @r00ster91 Thank you it is working now, coming from ruby little hard
<FromGitter> <r00ster91> understandable, youre welcome
moei has quit [Ping timeout: 240 seconds]
<FromGitter> <girng> never seen **, https://crystal-lang.org/api/0.26.1/NamedTuple.html#from%28hash%3AHash%29-instance-method
<FromGitter> <girng> what's `**` doing in that example??
<FromGitter> <vusaalab> sorry guys any idea undefined method 'key?' for JSON::Any .
Tortice has quit [Read error: Connection reset by peer]
<FromGitter> <girng> thanks!
<FromGitter> <r00ster91> @vusaalab the method `key?` is not defined on JSON::Any: you cant find it anywhere on this page: https://crystal-lang.org/api/0.26.1/JSON/Any.html ⏎ you probably want this method: https://crystal-lang.org/api/0.26.1/JSON/Any.html#%5B%5D%3F%28index%3AInt%29%3AJSON%3A%3AAny%3F-instance-method
<FromGitter> <r00ster91> @vusaalab the method `key?` is not defined here: https://crystal-lang.org/api/0.26.1/JSON/Any.html ⏎ you probably want `JSON::Any#[ (https://crystal-lang.org/api/0.26.1/JSON/Any.html#%5B%5D%3F%28index%3AInt%29%3AJSON%3A%3AAny%3F-instance-method)
<FromGitter> <vusaalab> @r00ster91 thanks it works @metadata["streams"]?
Raimondii has joined #crystal-lang
tilpner_ has joined #crystal-lang
davic has quit [Ping timeout: 240 seconds]
ashirase has quit [Ping timeout: 240 seconds]
johndescs has quit [Ping timeout: 240 seconds]
Raimondi has quit [Ping timeout: 240 seconds]
tilpner has quit [Ping timeout: 240 seconds]
Raimondii is now known as Raimondi
tilpner_ is now known as tilpner
johndescs has joined #crystal-lang
davic has joined #crystal-lang
moei has joined #crystal-lang
ashirase has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 240 seconds]
Tortice has joined #crystal-lang
<Tortice> $ ls /usr/lib/lib{pcre,gc,event}.so works for me, but --linker-flags="-static" says ld can't find them
moei has quit [Ping timeout: 252 seconds]
<FromGitter> <Sija> @bararchy yeah, that was a generalization, of course it doesn’t apply in all cases, yet I’ve found it pretty repeatable throughout my aquitance-base ;)
DTZUZO has joined #crystal-lang
<FromGitter> <drum445> God bless Crystal
<FromGitter> <Aaron-JM> Anyone have any crystal Lang shards they wanna see made?
<FromGitter> <proyb6> @Aaron-JM
<FromGitter> <proyb6> You mean https://crystalshards.xyz/
<FromGitter> <Aaron-JM> I mean like any new library ideas @proyb6
hightower3 has joined #crystal-lang
<FromGitter> <j8r> enjoy :)
hightower3 has left #crystal-lang ["Leaving"]
<FromGitter> <proyb6> R
<FromGitter> <proyb6> Enjoy
<FromGitter> <codenoid> is it work for non english language ? ⏎ https://github.com/watzon/cadmium#sentiment-analysis
DTZUZO has quit [Ping timeout: 268 seconds]
<FromGitter> <fenicks> What is the best way to set `timeout` with `HTTP::Client` ?
<FromGitter> <bajro17> @Aaron-JM IPFS api is easy one you can make it :)
<FromGitter> <Sija> @Aaron-JM vips bindings (for super fast and efficient image manipulation)! :)
<FromGitter> <Sija> @fenicks I’m not sure if it’s the “best way”, but there’s `HTTP::Client#{connect,read}_timeout` you can use
<FromGitter> <fenicks> @Sija Ok, thanks
<FromGitter> <codenoid> crystal/kemal doesn't have google recaptcha library
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 272 seconds]
JuanMiguel has joined #crystal-lang
<JuanMiguel> hello all
<JuanMiguel> is this class https://crystal-lang.org/api/0.19.3/HTTP/WebSocket.html complete?
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/0.26.1/HTTP/WebSocket.html you're using an outdated version of the docs
<FromGitter> <Blacksmoke16> notice the `0.19.3`
<JuanMiguel> sorry, I tried days earlier with the right one. The mistake has been now. Sorry for that
<JuanMiguel> I tried to connect to the kemal WS example as a client and I didn't manage to make it work
<FromGitter> <Blacksmoke16> hmm, examples in the kemal docs didnt work?
<JuanMiguel> kemal as a server works perfectly. I failed to make a non JS client in crystal
<JuanMiguel> it can totally be my fault, but I think I was doing the right think. So I though that maybe the client library was not finished yet
<JuanMiguel> *thought
<FromGitter> <Blacksmoke16> ah, never used stblib stuff so couldnt say :/
<JuanMiguel> don't worry, I'll try again tomorrow. thx
<FromGitter> <bajro17> JuanMiguel do you have github repo to we can check code its so hard to say like that
<JuanMiguel> it was just a quick test. I will try to write it again... I will come back later with a pastebin
mjblack has quit [Ping timeout: 252 seconds]
<JuanMiguel> this is the client code and the error in the kemal side
<JuanMiguel> it will be my fault, but I don't see the problem
<JuanMiguel> the server is the kemal example
<FromGitter> <dscottboggs_gitlab> is there a way to define type restrictions on an abstract method?
mjblack has joined #crystal-lang
<JuanMiguel> this one is working: https://pastebin.com/ivKafApq
<FromGitter> <bajro17> I think both of this will not work
<FromGitter> <bajro17> because you need put it in block (I think its called like that)
<JuanMiguel> the problem was twofold, one it lacked the run call, and that the callback has to be defined before the send
<JuanMiguel> thx for the help guys
<FromGitter> <Sija> @dscottboggs_gitlab if you mean argument type restrictions, then yes, return type - no
<FromGitter> <dscottboggs_gitlab> Interesting! that's the opposite of how I thought it would be! Is there documentation you can refer me to or could you provide me with a quick example of the syntax?
<FromGitter> <Sija> syntax is the same of for the normal methods, i.e. `abstract def foo(name : String)`, aside of `abstract` at the beginning :)
<FromGitter> <dscottboggs_gitlab> ah, ok
<FromGitter> <dscottboggs_gitlab> I'm curious, is there a reason return type restrictions aren't allowed?
<FromGitter> <Sija> you were quicker, I was just writing that :)
<FromGitter> <Sija> see #6771
<FromGitter> <dscottboggs_gitlab> actually, for the case I was thinking of, I think I can just define the actual method on the abstract class, so no need, but I'll definitely check that out. Thanks! :)
<FromGitter> <Sija> tl;dr - because semantics are somewhat messy around the corners ;)
<FromGitter> <Sija> if you need it implemented explicitly by each of the subclasses you gonna need to use `abstract def`
<FromGitter> <Sija> but you might know that already, all the best :)
DTZUZO has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> @Sija woohoo that is a fun problem
<FromGitter> <Sija> yep, you’ve touched a sore point ;)
<FromGitter> <dscottboggs_gitlab> I was really dismayed to see type restriction syntax being used as documentation. That could lead to some terrifically nasty bugs
<FromGitter> <Sija> true, current state of things is messed-up in this regard, as you might see in before mentioned PR there’s a will to change that :) question is - to which version? removing them would “fix” the issue at hand, while removing quite useful feature, 2nd option is more ambitious and as asterite pointed out, would call for sorting out the logic behind (and likely a decent language spec)
<FromGitter> <dscottboggs_gitlab> is there a language spec at all?
<FromGitter> <Sija> I don’t think so
<FromGitter> <Sija> of course aside of `spec/`
Tortice has quit [Remote host closed the connection]
<FromGitter> <j8r> Dumb question: what is the main pros of inheritance in Crystal vs composition? I always hand up by using compoistion over inheritance, because of the flexibility, multiple includes and structs
<oprypin> composition is popular these days. if it works well for you, just go for it
JuanMiguel has quit [Quit: This computer has gone to sleep]