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
dkh has joined #crystal-lang
notdaniel has quit [Ping timeout: 252 seconds]
dkh has quit [Remote host closed the connection]
_whitelogger has joined #crystal-lang
alexherbo23 has joined #crystal-lang
alexherbo2 is now known as Guest22637
Guest22637 has quit [Killed (card.freenode.net (Nickname regained by services))]
alexherbo23 is now known as alexherbo2
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
<FromGitter> <pynixwang> get it
laaron has joined #crystal-lang
<FromGitter> <pynixwang> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ce0e2276366992a94e2b2e9]
<FromGitter> <pynixwang> json does not handle 16 base number
<FromGitter> <watzon> No, you need to convert hex numbers into decimal numbers for JSON to parse them. See https://en.wikichip.org/wiki/JSON#Numbers
<FromGitter> <watzon> I wish the documenter was a little more robust. I miss rdoc things like `@see`
<FromGitter> <pynixwang> it works as string.
<FromGitter> <pynixwang> I deserialize twice.
<FromGitter> <watzon> What's does your code look like? @pynixwang
<FromGitter> <pynixwang> resp = HTTP::Client.post(@url, body: req.to_json) ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ce102120ec37966a1951b0b]
<FromGitter> <pynixwang> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ce1021883ae782aee92c9fe]
<FromGitter> <pynixwang> ``
<FromGitter> <pynixwang> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ce1024e509b1035c773a7a7]
<FromGitter> <watzon> What does `req` look like though?
<FromGitter> <pynixwang> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ce102826366992a94e37ca6]
<FromGitter> <pynixwang> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ce102c27c363c75a7065ed1]
<FromGitter> <watzon> Actually it looks like `result` is the culprit
<FromGitter> <watzon> Do you have an example of the raw json getting parsed into result?
<FromGitter> <pynixwang> result is deserialized
<FromGitter> <pynixwang> now works
<FromGitter> <watzon> Huh, ok lol
<FromGitter> <pynixwang> I serialize it again
<FromGitter> <pynixwang> with `to_json`
<FromGitter> <watzon> Anyway back to my griping about the documentation generator
<FromGitter> <watzon> > I wish the documenter was a little more robust. I miss rdoc things like `@see` ⏎ ⏎ As it is if I want to replicate `@see` I have to do so manually, which is kind of annoying ⏎ ⏎ ```# **See Also:** ⏎ # - [https://something.com](https://something.com)``` [https://gitter.im/crystal-lang/crystal?at=5ce10336879f4478c7a4714a]
<FromGitter> <watzon> Maybe we just need an external shard that's a little more like rdoc
DTZUZO has joined #crystal-lang
DTZUZO has quit [Ping timeout: 268 seconds]
ashirase has quit [Ping timeout: 246 seconds]
ashirase has joined #crystal-lang
<FromGitter> <watzon> Is the following at all possible? ⏎ ⏎ ```c = String ⏎ a =[] of c``` ⏎ ⏎ Currently I'm getting the error: `expecting token 'CONST', not 'c'` [https://gitter.im/crystal-lang/crystal?at=5ce122bd0ec37966a195e846]
<FromGitter> <watzon> I think I found my answer with #2926
<FromGitter> <r00ster91> I would use a constant or alias instead of a local variable
vegai has joined #crystal-lang
DTZUZO has joined #crystal-lang
laaron has quit [Remote host closed the connection]
alexherbo21 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 258 seconds]
<FromGitter> <watzon> @r00ster91 unfortunately wasn't really possible in my case
<FromGitter> <r00ster91> why isn't it possible to a constant in your case? constants are accessible everywhere
JuanMiguel has joined #crystal-lang
<FromGitter> <pynixwang> initialize can be override?
<FromGitter> <pynixwang> overload.
<FromGitter> <pynixwang> not override.
laaron has joined #crystal-lang
<FromGitter> <r00ster91> yes, you can have multiple overloads for `initializer` if you mean that: https://carc.in/#/r/6xxb
laaron has quit [Remote host closed the connection]
<FromGitter> <vegai> hey!
<FromGitter> <tenebrousedge> hello
laaron has joined #crystal-lang
_whitelogger has joined #crystal-lang
JuanMiguel has joined #crystal-lang
<FromGitter> <pynixwang> hi
JuanMiguel has quit [Quit: Saliendo]
<FromGitter> <Blacksmoke16> o/
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter> <zhenfeng-zhu> my vs code with crystal-ide plugin can't jump to source?
<FromGitter> <zhenfeng-zhu> what ide do you use?
<FromGitter> <Blacksmoke16> sublime
<FromGitter> <yorci> @Blacksmoke16 how can i pass variable to block in macro ? ⏎ ⏎ something like this https://carc.in/#/r/6xyv
<FromGitter> <Blacksmoke16> hmm
ashirase has quit [Ping timeout: 244 seconds]
<FromGitter> <yorci> possible?
ashirase has joined #crystal-lang
<FromGitter> <Blacksmoke16> sec
<FromGitter> <Blacksmoke16> https://carc.in/#/r/6xyx is closer
<FromGitter> <Blacksmoke16> but question is how to pass them to the block
<FromGitter> <yorci> yep
ashirase has quit [Ping timeout: 245 seconds]
<FromGitter> <yorci> define proc in method and pass variables to it and the content from block body, that makes sense?
ashirase has joined #crystal-lang
<jhass> https://carc.in/#/r/6xz1 you can just refer to them
<jhass> but ugh
<jhass> maybe a bit nicer https://carc.in/#/r/6xz4
<FromGitter> <yorci> @jhass that looks what i want to do, thank you
DeBot has joined #crystal-lang
<FromGitter> <Blacksmoke16> is it a bug protected defs dont show up in api docs when defined in modules?
<FromGitter> <Blacksmoke16> I could see private methods being excluded since they are most often used internally, but protected methods should prob be documented as children could override them
<FromGitter> <Blacksmoke16> thoughts? ^
<FromGitter> <dscottboggs_gitlab> > protected methods should prob be documented as children could override them ⏎ ⏎ 👍
<alexherbo21> What is the Crystal equivalent to unpack a message length as 4 byte integer
<alexherbo21> in Ruby, I’ve do: text_length = text_length_bytes.unpack('i').first
<alexherbo21> I read the message length (first 4 bytes) from stdin with STDIN.gets(4)
<jhass> STDIN.read_bytes(Int32)
<jhass> Or Int32.from_io(STDIN)
<alexherbo21> jhass: I'm not sure I get how to read the proper message https://developer.chrome.com/extensions/nativeMessaging#native-messaging-host-protocol
<alexherbo21> and send it back
<alexherbo21> for example, if I have a string length of '{"test":"ok"}' (.lenght == 12), how to write it to stdout as 32-bit message length in native byte order
<alexherbo21> hm, length is not the good method with utf8 character no?
<jhass> they don't say very explicitly but I guess they mean byte count, yeah
<jhass> so STDOUT.write_bytes(string.bytesize); STDOUT.write(string)
<jhass> eh, STDOUT << string I mean
<alexherbo21> and for receiving: length = STDIN.read_bytes(4); message = STDIN.read_bytes(length)?
<jhass> read_string, not read_bytes
<jhass> and read_bytes(Int32), it takes the type
<alexherbo21> when reading bytes, I get a str no?
<jhass> no
<alexherbo21> :(
<jhass> https://crystal-lang.org/api/0.28.0/IO.html#read_bytes%28type%2Cformat%3AIO%3A%3AByteFormat%3DIO%3A%3AByteFormat%3A%3ASystemEndian%29-instance-method
<jhass> https://crystal-lang.org/api/0.28.0/IO.html#read_string%28bytesize%3AInt%29%3AString-instance-method
<alexherbo21> jhass thanks ^^
<jhass> you're welcome
ashirase has quit [Ping timeout: 252 seconds]
ashirase has joined #crystal-lang
alexherbo213 has joined #crystal-lang
alexherbo21 has quit [Ping timeout: 244 seconds]
alexherbo2137 has joined #crystal-lang
alexherbo213 has quit [Ping timeout: 258 seconds]
alexherbo21372 has joined #crystal-lang
alexherbo2137 has quit [Ping timeout: 268 seconds]
<alexherbo21372> command = ["echo", "tchou", "tchou"]; system(*command) how to do that in Crystal with the splat?
<FromGitter> <Blacksmoke16> Replace the brackets with curly braces, then you could splat
<FromGitter> <Blacksmoke16> Can't splat an array
<alexherbo21372> the command comes from JSON
<alexherbo21372> so I can’t I guess
<FromGitter> <j8r> you still can
<FromGitter> <j8r> but you'll need to use a case/when
<FromGitter> <j8r> and support X number of elements
<FromGitter> <mistergibson> Anyone have a link to some intermediate-to-advanced use of fibers and channels. The basic docs get you started, but I could use more research on the topic. Thanks in advance.
<FromGitter> <Blacksmoke16> https://github.com/Blacksmoke16/crylog/tree/develop/docs been working on a logging framework based on one we use at work. if anyone wants to glance thru the docs and give thoughts/suggestions while its still young
<alexherbo21372> I can't figure out Array(String).from_json(request) to call with system
<alexherbo21372> I have an array of strings and want to call sytem(...array)
<FromGitter> <Blacksmoke16> you cant splat an array
<FromGitter> <Blacksmoke16> so prob have to go to plan b
<FromGitter> <Blacksmoke16> is the number of elements known, or could the request return diff size arrays?
<alexherbo21372> the number of elements is not known in advance
<alexherbo21372> it could be: ['mpv', '--no-config', 'https://youtu.be/SXUrlO_Br-Y']
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/0.28.0/toplevel.html#system(command:String,args=nil):Bool-class-method it just takes a string
<FromGitter> <Blacksmoke16> so just join each item by `' '`
<FromGitter> <watzon> Loooooooong way to go, but I'm getting there https://github.com/watzon/octokit.cr
<FromGitter> <Blacksmoke16> does github have like a swagger API docs?