<renich>
Blacksmoke16: thanks a ton, man. You rock.
<FromGitter>
<Blacksmoke16> np
<renich>
I have another question: https://play.crystal-lang.org/#/r/6yex. In that case, I get my NICs as arrays. How can I get the name of them and put it in Nic?
<FromGitter>
<Blacksmoke16> if you're stuck with your previous format then might be a bit trickier
<FromGitter>
<Blacksmoke16> because currently you eth0:` etc are just keys in type `Nic` that are empty strings
<renich>
Blacksmoke16: Thanks again, mate!
<FromGitter>
<Blacksmoke16> if you control the format of the yaml, just do like `name: eth0`, that would be the best option
<renich>
Blacksomke16: I do control both ends. I'm generating the yaml and they asked for a csv parser so no worries
<FromGitter>
<Blacksmoke16> π
<renich>
Thanks a lot, man. You're really helping me get through it. :D
<FromGitter>
<Blacksmoke16> np
<FromGitter>
<Daniel-Worrall> Is anyone else getting Invalid memory access' from `crystal spec -d`
<alexherbo23>
what is the idiomatic way to handle optional values? I have a JSON message { id, command, arguments, shell, input }, and from that message I call Process.run(command, arguments, ...), how I can handle JSON arguments, input, or shell can not be given when calling Process.run
laaron has quit [Remote host closed the connection]
alexherbo2 has joined #crystal-lang
laaron has joined #crystal-lang
<alexherbo2>
re
<FromGitter>
<pynixwang> whats the faas usage sense?
<FromGitter>
<pynixwang> background job?
<FromGitter>
<pynixwang> image processing?
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
renich has quit [Remote host closed the connection]
<FromGitter>
<watzon> So I republished my Doing Crystal articles on dev.to since Medium has set up that stupid ass paywall. Anyone who wants to take a look can check out my profile https://dev.to/watzon
<alexherbo20>
if I donβt use input, I need to close it when passing Process.run(..., input: input)?
<alexherbo20>
if request.input; stdin << request.input; stdin.rewind; else; input.close; end
<alexherbo20>
or I can leave input open
<FromGitter>
<bew> @Blacksmoke16 about dark themes, use Stylus (an extension fro chrome & firefox iirc) then install https://github.com/StylishThemes/GitHub-Dark :D I can't do without it
<FromGitter>
<Blacksmoke16> whoa
<FromGitter>
<Blacksmoke16> life changing
<FromGitter>
<bew> there is a very good one for stackoverflow too ;)
<FromGitter>
<Blacksmoke16> noice
<FromGitter>
<Blacksmoke16> good call
<FromGitter>
<mwlang> I'm stuck on transforming JSON to array of different objects. https://play.crystal-lang.org/#/r/6ygn is a minimum play with all the components I'm working with. I know why it's doing what it's doing, but not having any luck changing it to do what I'd like, which is to instantiate different "filter" classes depending on value of "filterType" key.
<FromGitter>
<mwlang> @Blacksmoke16 you helped me along by providing a play using #from_array and by itself, I was able to spec that out, but once I'm already in a JSON::PullParser flow, not sure how to "jump out" to having just the "filters" as a string representation of the Array to feed into the ExchangeFilter's #from_array method.
<FromGitter>
<mwlang> or more to the point, that actually seem inefficient, so my real attempt was to "pull.read_array" and pass on an already parsed array, but couldn't pull that off, either.
<FromGitter>
<Blacksmoke16> i was thinking about this more, sec
alexherbo207 has joined #crystal-lang
<FromGitter>
<Blacksmoke16> the main issue is once you are in pull parser land you, AFAIK no longer have access to the full obj as a string
<FromGitter>
<Blacksmoke16> as pull parser goes token by token
alexherbo20 has quit [Ping timeout: 258 seconds]
<FromGitter>
<Blacksmoke16> so you need to like abstract your logic to *KNOW* what they key is *BEFORE* doing from_json
<FromGitter>
<Blacksmoke16> hence why i was using the `from_array` outside of the normal deserialization flow
<alexherbo207>
If I need to convert to JSON, should I use { status.exit_status } instead?
<FromGitter>
<mwlang> yeah, that's definitely where I'm hung up...I was feeling like I needed a lookahead or peek capability.
<alexherbo207>
Blacksmoke16 if it exits with error
<alexherbo207>
?
<FromGitter>
<Blacksmoke16> that would still be exit code 1 no?
<FromGitter>
<Blacksmoke16> easiest way would be to wrap it in a `typeof()` and see what you get
<alexherbo207>
def exit_code doesnβt have ": Int32" part
<FromGitter>
<Blacksmoke16> the docs are generated from the code, so that method is just missing a return type restriction
<FromGitter>
<Blacksmoke16> which isn't required persay
<FromGitter>
<mwlang> one thing that does work...it'll read it all in as an array of ExchangeFilter, so I thought maybe just assign that to a "private" getter (if there's such a thing) and then another method that, on first access, transforms each filter to a specific classs.
<alexherbo207>
what would be the difference / more appropriate JSON return between .exit_code and .exit_status?
<FromGitter>
<Blacksmoke16> :shrug:
<FromGitter>
<Blacksmoke16> is the structure of the json what you're going to be dealing with for reals/
<FromGitter>
<vladfaust> I get `Invalid memory access (signal 11) at address 0x0` upon de-serializing from a YAML string after my code is statically build on Alpine. Is this a known issue?
<FromGitter>
<mwlang> So, how do you pass an instantiated JSON::PullParser to another class's #from_json method?
<FromGitter>
<mwlang> for example, ```when "PRICE_FILTER" then PriceFilter.from_json pull```
<FromGitter>
<Blacksmoke16> could prob pass it to `.new pull`
<FromGitter>
<Blacksmoke16> that would prob work
<FromGitter>
<mwlang> that wasn't having the desired affect of letting PriceFilter utilize the PullParser to extract it's own properties.
<FromGitter>
<mwlang> so it works, but definitely a bit of inefficiency since it's going from json to string then back to json, so I'm going to see if I can improve with ```.new(pull)```
<FromGitter>
<Blacksmoke16> π
<FromGitter>
<Blacksmoke16> id be curious to see if you find a solution
<FromGitter>
<j8r> @vladfaust no, still empty stack traces
<FromGitter>
<j8r> I plan to move out from raising exceptions, because of not very friendly and performance penalty: https://github.com/j8r/error.cr/
<FromGitter>
<vladfaust> > I get `Invalid memory access (signal 11) at address 0x0` upon de-serializing from a YAML string after my code is statically build on Alpine. Is this a known issue? β β Is that the same thing? Given that absolutely the same YAML file is working normally w/o static build
<FromGitter>
<vladfaust> If so, error.cr can't help, as the thing is happening in stdlin
<FromGitter>
<mwlang> doesn't look like it's going to be easy...once you open the array and begin reading enough to get the "filterType" out of the hash, passing the pull in that state to #from_json of the selected class leads to parsing error: "Expected begin_object but was string at 7:19 parsing PriceFilter at 7:9"
<FromGitter>
<Blacksmoke16> yea, since you're now parsing it token by token
<FromGitter>
<Blacksmoke16> hence the need to parse json, then pass the json string back to it :/
<FromGitter>
<mwlang> need a #read_hash to go along with #read_array. :-p
ua_ has quit [Quit: Leaving]
<FromGitter>
<mwlang> I'll keep the test_spec file around and toy with this again another day...for now, I can move on with wrapping binance API with current working solution.
<FromGitter>
<Blacksmoke16> π
<FromGitter>
<vladfaust> So any error raised leads to Invalid Access
<FromGitter>
<vladfaust> Even if it's rescued
<FromGitter>
<vladfaust> That's shit.
ua has joined #crystal-lang
<FromGitter>
<j8r> @vladfaust partially, we can replace `raise` by `throw`, then having a trace
<FromGitter>
<j8r> because it doesn't involves stack unwinding, which is broken
<FromGitter>
<vladfaust> I understand what you say, @j8r, but it doesn't help
<FromGitter>
<j8r> If on the stdlib, we have to rescue it :/
<FromGitter>
<vladfaust> > Even if it's rescued
<FromGitter>
<j8r> have you done `require "llvm/lib_llvm"; require "llvm/enums"`?
<FromGitter>
<vladfaust> Yes, it requires libstdc++-dev, which is absent on Alpine
alexherbo207 has quit [Read error: Connection reset by peer]
<FromGitter>
<asterite> I think docs before annotation and method should work, and if not we should fix it
<FromGitter>
<j8r> > LLD is very fast. When you link a large program on a multicore machine, you can expect that LLD runs more than twice as fast as the GNU gold linker. Your milage may vary, though. β :O
<FromGitter>
<vladfaust> That'so strange. Binaries built on Ubuntu statically work within an alpine image
<mps>
vladfaust: that is how static works, but full static
<FromGitter>
<vladfaust> Awesome!
<mps>
some build 'static' binaries where most libs are statically linked and base libs are dinamically linked (libc, for example) and still call this static build
<FromGitter>
<vladfaust> And what do we have in Crystal?
<FromGitter>
<j8r> the static binary built on Alpine is smaller than the Ubuntu one
<FromGitter>
<vladfaust> Why? And what's the actual size difference?
<mps>
yes, musl is smaller (and usually faster) than glibc
<mps>
I didn't tested differences with crystal, but when I played with go-lang I built some binaries on debian with musl and they were smaller although I didn't test speed
<mps>
and, that was one of reasons to switch to alpine
alexherbo2078 has quit [Ping timeout: 258 seconds]
alexherbo2078 has joined #crystal-lang
<FromGitter>
<mwlang> > I think docs before annotation and method should work, and if not we should fix it β β I'll double-check that it doesn't work and if not, open an issue on it.
<FromGitter>
<asterite> Thanks!
<FromGitter>
<renich> Good $tod, Crystalians!
<FromGitter>
<renich> I have a question. I have a YAML map. How can I get it's keys?
<FromGitter>
<Blacksmoke16> close to what you want? idk
<FromGitter>
<Blacksmoke16> should be able to reorder by changing the order in your yaml mappings
DTZUZO_ is now known as DTZUZU
<FromGitter>
<Blacksmoke16> i feel like csv isnt the best format for something like this tho...
<FromGitter>
<renich> awesome! Dude, I owe you a beer!
<FromGitter>
<renich> @Blacksmoke16 the man wants it in a spreadsheet... I know...
<FromGitter>
<Blacksmoke16> welp
<FromGitter>
<renich> @Blacksmoke16 many thanks for this. I hope I can learn the crystal way of things
<FromGitter>
<Blacksmoke16> np
<FromGitter>
<renich> @Blacksmoke16 your example is really exciting. Now, let's see if I can do the same for values and the work is done! ;D I'll see if I can implement it myself based on your example.
<FromGitter>
<jwoertink> > wrong number of arguments for 'Array(String)#initialize' (given 1, expected 2, 0)
<z64>
i saw the issue you were working on. https://carc.in/#/r/6yk5 works as-is (Union(Array(String)).new(pull)); generally what i would be looking for is some kind of conflicting array constructor
<FromGitter>
<jwoertink> hmm That's a good idea.
<z64>
i mean, what you could maybe do quickly, is set up an environment where you can require all the relevant deps and run exactly what i had in my carc.in above, outside of json::serializable and whatnot, to reduce the scope if possible
<FromGitter>
<jwoertink> Yeah, I did that and it works fine
<FromGitter>
<jwoertink> seems to only fail when it's inside of lucky
<FromGitter>
<Blacksmoke16> do the blacksmoke way of debugging
<FromGitter>
<jwoertink> but maybe I can break that down even more since it's technically only lucky_cli
<FromGitter>
<Blacksmoke16> just start deleting shit till it goes away
<FromGitter>
<Blacksmoke16> then ctrl+z and you have a clue :P
<FromGitter>
<jwoertink> lol! Yup, that's my favorite way
<FromGitter>
<Blacksmoke16> works quite well haha
<FromGitter>
<Blacksmoke16> id also suggest maybe trying it against master
<FromGitter>
<Blacksmoke16> rule out any bugs that have been fixed since last release
<z64>
@jwoertink just based on the samples (i cant pull code and test right now..) the first place i would look is whatever is driving database code. maybe it defines an Array(T) ctor to construct an array from a db set, and it accepts extra arguments for some kind of database context. wild guess tho:)
<FromGitter>
<Blacksmoke16> oh
<FromGitter>
<Blacksmoke16> oh, nvm
<FromGitter>
<jwoertink> I didn't consider that, but that could be a good spot to look too
<FromGitter>
<jwoertink> thanks for the suggestion
alexherbo20783 has joined #crystal-lang
alexherbo2078 has quit [Ping timeout: 248 seconds]
alexherbo207831 has joined #crystal-lang
alexherbo20783 has quit [Ping timeout: 268 seconds]
<FromGitter>
<jwoertink> Would this be considered a crystal bug?
<FromGitter>
<jwoertink> I'm not really sure how the inheritance is supposed to work. It seems like in this case, since it's never calling `Collection.new`, that initialize override should never be touched
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
<FromGitter>
<jwoertink> Maybe I'll file the bug just in case
<FromGitter>
<kinxer> It looks like a bug to me. I'd never really want a `Klass < Array(String)` to affect my use of `Array(String)` itself, entirely apart from the question of whether the `initialize` should even be relevant from a compilation standpoint.
<FromGitter>
<jwoertink> Yeah. My thought was that the subclass should act on it's own. Calling the parent shouldn't be affected by it's children
<FromGitter>
<jwoertink> now if my kids would just understand that, things would be great