RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.24.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
qard has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 256 seconds]
faustinoaq has quit [Quit: IRC client terminated!]
return0e has quit [Read error: Connection reset by peer]
return0e has joined #crystal-lang
<crystal-gh> [crystal] lipanski opened pull request #5726: Introduce a parallel! macro to re-raise exceptions from fibers (master...parallel_raise) https://git.io/vAltz
qard has quit [Quit: qard]
<crystal-gh> [crystal] CaDs opened pull request #5727: Handle [CMD/CTRL]+S on Playground (master...feature/playground_binding_cmd_s_and_ctrl_s_to_run_code) https://git.io/vAlqY
maattdd_ has joined #crystal-lang
maattdd_ has quit [Ping timeout: 276 seconds]
devil_tux has quit [Quit: leaving]
maattdd_ has joined #crystal-lang
sevensidedmarble has quit [Quit: WeeChat 2.0-dev]
<watzon> Papierkorb: I fixed several bugs. Arrays now generate correctly. I decided that rather than having them generate classes they'd do NamedTuples
<Papierkorb> NamedTuples aren't storage structures, they're transfer structures.
* watzon sent a long message: watzon_2018-02-18_01:48:21.txt <https://matrix.org/_matrix/media/v1/download/matrix.org/lAGLOaBqCutgAieFAbvVzWbi>
<Papierkorb> don't use them outside of macros or mass-passing (named) arguments to functions
<watzon> Do you think I should use a Hash instead?
<Papierkorb> No, it should simply be a normal class
<Papierkorb> Not to mention that typing stuff[:like_this] isn't crystal-y
radagast_04 has quit [Ping timeout: 268 seconds]
<watzon> True
<watzon> I am pretty happy with how Arrays are working now though. Granted there are probably some edge cases that I haven't found yet, but it works nicely
<watzon> I'm planning on adding some toggles soon so that you can turn on things like `allNillable` to make everything nilable, or `compact` to remove the extra whitespace
<Papierkorb> Ideally, the generated output would be used by the programmer to further enhance it
<Papierkorb> E.g. adding verifications, or transformations (String -> Time)
<watzon> Right, that is the general idea
<maattdd_> Papierkorb: Actually coming from Ruby, I'm more used to foo[:bar] than foo.bar
<Papierkorb> maattdd_: That's a ruby paradigm though, and it has always sucked, even there
<maattdd_> But I think I've found a compiler bug by abusing usage of NamedTuple
<Papierkorb> Typing foo.bar is so much faster
<maattdd_> (a crash during a GC reclaim)
<Papierkorb> maattdd_: Quite possible, if you can reduce it, please open a github issue showcasing it
<maattdd_> I will convert the code to plan class and see if it resolves it
<maattdd_> s/plan/plain
<watzon> Papierkorb: I agree, symbols have never been my favorite thing
alex`` has quit [Ping timeout: 276 seconds]
hightower2 has quit [Ping timeout: 260 seconds]
<watzon> The only problem I have with having an object inside of an array generate a class is that said object doesn't have a key attached to it, which means I have to generate a random name for the class
<watzon> It's also a lot harder to merge similar ones, so if two objects are just one property off they'll become completely different classes
<Papierkorb> just count upwards, or maybe something like "<Parent>Child<Count>"
<Papierkorb> Of course, but even if you'd merge, you wouldn't know if they're actually supposed to inherit from one another anywa
<Papierkorb> y
<watzon> True
maattdd_ has quit [Ping timeout: 260 seconds]
faustinoaq has joined #crystal-lang
radagast_04 has joined #crystal-lang
woodruffw has quit [Ping timeout: 276 seconds]
woodruffw has joined #crystal-lang
woodruffw has joined #crystal-lang
woodruffw has quit [Changing host]
mooe has quit [Quit: Connection closed for inactivity]
vivus has quit [Quit: Leaving]
maattdd_ has joined #crystal-lang
maattdd_ has quit [Ping timeout: 260 seconds]
<watzon> Well the overall experience should be a bit better now https://watzon.me/projects/json-to-crystal
<FromGitter> <bararchy> I hate it when I need HEAD but it breaks half the shards I use
<FromGitter> <bararchy> :(
radagast_04 has quit [Ping timeout: 240 seconds]
radagast_04 has joined #crystal-lang
alex`` has joined #crystal-lang
hightower2 has joined #crystal-lang
<watzon> Just generated this and modified some parts. https://github.com/watzon/docker-api/blob/master/src/docker/service.cr
<watzon> The past 24 hours of working on that tool just saved me so much time here haha
<watzon> Most of that was autogenerated based on this json https://docs.docker.com/engine/api/v1.24/#create-a-service
mooe has joined #crystal-lang
TakeYourFreedom has joined #crystal-lang
alex`` has quit [Ping timeout: 276 seconds]
TakeYourFreedom has quit [Remote host closed the connection]
hightower2 has quit [Ping timeout: 248 seconds]
hightower2 has joined #crystal-lang
alex`` has joined #crystal-lang
alex`` has quit [Ping timeout: 276 seconds]
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 240 seconds]
jnyw has quit [Quit: WeeChat 2.0.1]
maattdd has quit [Ping timeout: 248 seconds]
mooe has quit [Quit: Connection closed for inactivity]
sz0 has joined #crystal-lang
hightower has joined #crystal-lang
hightower3 has quit [Ping timeout: 268 seconds]
pta2002 has quit [Quit: ZNC 1.6.5+deb2build2 - http://znc.in]
pta2002 has joined #crystal-lang
pta2002 has left #crystal-lang [#crystal-lang]
radagast_04 has quit [Ping timeout: 264 seconds]
<FromGitter> <r00ster91> did I found an wrong example? ⏎ https://crystal-lang.org/api/0.24.1/Random.html
<FromGitter> <r00ster91> Random.new_seed isnt existing
<oprypin> r00ster91, it seems you're right
<FromGitter> <bararchy> oprypin, thanks for the help at StackOverflow, great example
<FromGitter> <r00ster91> ok will make a PR!
<oprypin> r00ster91, i would recommend not using new_seed then
<FromGitter> <r00ster91> its giving me an error. Cant really use it
rohitpaulk has joined #crystal-lang
<crystal-gh> [crystal] r00ster91 opened pull request #5728: Fix Random example (master...patch-3) https://git.io/vA8kg
<FromGitter> <bararchy> Are we in for 25 or 24.2 ?
<RX14> both?
<RX14> but I dislike it all
<RX14> we should just merge that darn 0.24.2 branch
<RX14> and release 0.25 or whatever
<RX14> there are commits in the 0.24.1 branch that are not in master
<RX14> and that's stupid
<FromGitter> <bararchy> I really need this JSON change in hahah
<FromGitter> <bararchy> I'm using master but it breaks multiple shards
<RX14> what json change
<RX14> why not just monkeypatch it?
<FromGitter> <bararchy> I do, but it breaks lots of stuff all over the place
<RX14> oh yeah
<RX14> thatd not monkeypatchable
<RX14> why do you need it?
<FromGitter> <bararchy> direct link: https://stackoverflow.com/a/48795245/1526733
<FromGitter> <bararchy> without this change I can't make this example work
<RX14> but you can do it
<FromGitter> <bararchy> and with it, half of Crystal breaks
<FromGitter> <bararchy> how ?
<RX14> i mean what's the usecase anyway
<Papierkorb> I still wonder why that dumpsterfire got merged
<RX14> because it's not a dumpsterfire and it makes a lot of practical sense
<FromGitter> <bararchy> well, I need to "shove" a `Char|String` instead of each parts of the JSON schema values, and then get back an array of each new "composition"
<RX14> we need to go up a level of "why"
<RX14> maybe quite a few
<FromGitter> <bararchy> if you mean "what I need it for", then it's part of NexPloit, our solution for vunrebility scanning, this is an easy way to inject payloads into a JSON schema to test API's for crashes
<FromGitter> <bararchy> part of REST fuzzing
<FromGitter> <bararchy> I did it until now using gsub and string replacment, but it's a pain
<FromGitter> <bararchy> and Regexp will crash sometimes when getting wierd payloads
<RX14> i mean i'd probably reach for a pullparser here
<FromGitter> <bararchy> pullparser ?
<RX14> yeah
<RX14> it's simple
<RX14> you just use a pullparser and json writer in sync
<RX14> and you count the "value" tokens
<RX14> such as strings, numbers, etc and keep replacing them when pushing out json
<RX14> hmm
<RX14> it's harder than that
<RX14> but it's simpler in my head than oprypin's solution
<Papierkorb> modifying the pull parser isn't fun. Question is how that's formatted, if that's still even JSON or not
<RX14> i didn't mean modify anything
<RX14> @bararchy do you even fuzz by removing keys entirely?
<RX14> because that solution doesn't cover that
<FromGitter> <bararchy> yeha
<RX14> good
<RX14> @bararchy in 0.24.1 you'd use `JSON::Type` and parse_raw
<FromGitter> <bararchy> so I will need to use https://crystal-lang.org/api/0.24.1/JSON/PullParser.html and see when I get any value at all and change it?
<RX14> and then s/JSON::Any/JSON::Type/
<RX14> and then `as_h` would be `as?(Hash)`
<RX14> @bararchy you can do it just fine with 0.24.1 without a pullparser
<RX14> except the memory usage is far higher
<RX14> since you're creating every single permutatin in memory
<RX14> which is fairly ugly
<FromGitter> <bararchy> it's fine, we got "endless" amount of it :)
rohitpaulk has quit [Ping timeout: 255 seconds]
<RX14> ...
<RX14> try that with a 1gb json document
<FromGitter> <bararchy> each instance is 128Gb of RAM
<RX14> you will end up with more memory usage than there are atoms in the universe
<RX14> i suspect
<RX14> the whole thing "feels" O(2^n) memory usage or something insane
<FromGitter> <bararchy> For now this is the least of my worries, but TBH I still didn't understand how you would suggest to do it, can you show me a small example? or did you just meant change those little things in oprypin's example (JSON::Any, JSON::Type) and the .to_h
<RX14> yes
<RX14> i'm suggesting two things
<RX14> how to adapt oprypin's example for 0.24.1
<Yxhuvud> otoh, rehashing after every change seems also very expensive
<RX14> and how I would do it
<RX14> rehashing?
<FromGitter> <bararchy> RX14 something like this?
<FromGitter> <bararchy> it seems the JSON::Type does not have a "new" method
<RX14> fuck
<RX14> my solution works perfectly
<RX14> if only for that darned compiler
<FromGitter> <bararchy> XD
<FromGitter> <bararchy> oprypin also had an issue this is why he moved to try with Master I think https://carc.in/#/r/3l32
radagast_04 has joined #crystal-lang
<RX14> done
<FromGitter> <bararchy> Nice !
<FromGitter> <bararchy> thanks RX14
<RX14> downgraded the compiler to 0.23.1
<RX14> gave a proper error message
<RX14> and so I fixed it
<RX14> and the solution worked in 0.24.1
<FromGitter> <bararchy> RX14 it works great, thanks for that :)
<RX14> np
<hightower2> If I want to "alias" method Some::Module::long_name() to shortname(), what's my best bet to do that?
alex`` has joined #crystal-lang
<lvmbdv> hightower2: proc assignment
<lvmbdv> but you can only call it with shortname.call()
<lvmbdv> shortname = ->A::B::long_name()
<hightower2> Yes, that doesn't allow me to call just shortname(), it requires me to do .call()
rohitpaulk has joined #crystal-lang
<RX14> no
<RX14> hightower2, just private alias Foo Some::Module
<RX14> then use Foo.long_name
<RX14> you can alias out long module chains
<RX14> but nothing more
<hightower2> Ok, thanks
radagast_04 has quit [Ping timeout: 240 seconds]
hightower2 has quit [Ping timeout: 255 seconds]
hightower2 has joined #crystal-lang
<FromGitter> <aisrael> Pardon my ignorance, but what’s the easiest way to convert an `Array` to a `Tuple`? Use case: dynamic arguments to `DB#exec(sql, *args)`
<oprypin> aisrael, you can't, that's kinda the point
<oprypin> on the other hand, db exec has no business accepting only a tuple
<oprypin> aisrael, does it perhaps have a different way to accept arguments?
olbat has joined #crystal-lang
olbat has joined #crystal-lang
olbat has quit [Changing host]
<hightower2> yo olbat
<olbat[m]> Hi :)
<FromGitter> <r00ster91> actually you can convert array to tuple. ⏎ something like this: (i know this probably doesnt works) ⏎ ⏎ tuple = {} ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5a899bf00202dc012e4f8b3b]
faustinoaq has quit [Quit: IRC client terminated!]
<oprypin> thx.
<oprypin> aisrael, so it accepts an array as well
<FromGitter> <aisrael> Ahh! ☝️ I didn’t realize that overload existed, thanks!
<FromGitter> <aisrael> Yeah. At some point I was doing ⏎ ⏎ ```case values.size ⏎ when 1 ⏎ exec(sql, values[0]) ⏎ …``` [https://gitter.im/crystal-lang/crystal?at=5a899d42c3c5f8b90dd0e221]
<FromGitter> <aisrael> Which is probably the only way to go if whatever you’re calling only accepts `*args` but not `args : Array)`
<oprypin> aisrael, glad that you went through the experience because even if there was an automated way to convert an array to a tuple, that's what it would boil down to
rohitpaulk has quit [Ping timeout: 240 seconds]
rohitpaulk has joined #crystal-lang
<FromGitter> <aisrael> Is there an easy way for a class with declared `YAML.mapping(…)` to be built/constructed from a `YAML::Any`? That is, am mid way through (manually) parsing a complex YAML, but I want to extract a simple object from it (that has a `YAML.mapping(…)`)...
faustinoaq has joined #crystal-lang
<FromGitter> <aisrael> Can I create a `YAML::PullParser` from an already parsed YAML node (a `YAML::Any`), or do I have to dump that node and its children to a string, then `Foo.from_yaml(s)` it?
<FromGitter> <aisrael> Ok, I just found out I could do `Foo.from_yaml(node.to_yaml)` which actually makes a lot of sense when you read it :D Just has some string conversion & parsing overhead but I’ll live with that for now
<oprypin> well it's what you said "dump that node and its children to a string, then ..."
<oprypin> yes it's bad and yes it should be improved
<FromGitter> <aisrael> Gotcha. Just wondering if there was a better way than brute force ;)
alex`` has quit [Ping timeout: 255 seconds]
alex`` has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
sz0 has quit [Quit: Connection closed for inactivity]
faustinoaq has quit [Quit: IRC client terminated!]
woodruffw has quit [Ping timeout: 256 seconds]
woodruffw has joined #crystal-lang
woodruffw has quit [Changing host]
woodruffw has joined #crystal-lang
faustinoaq has joined #crystal-lang
ua has quit [Remote host closed the connection]
ua has joined #crystal-lang
faustinoaq has quit [Quit: IRC client terminated!]
faustinoaq has joined #crystal-lang
rohitpaulk has joined #crystal-lang
faustinoaq has quit [Quit: IRC client terminated!]
DTZUZU has quit [Ping timeout: 240 seconds]
rohitpaulk has quit [Ping timeout: 276 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 256 seconds]
DTZUZU has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 256 seconds]
rohitpaulk has joined #crystal-lang
faustinoaq has joined #crystal-lang
bijan_ has joined #crystal-lang
moei has joined #crystal-lang
woodruffw has quit [Ping timeout: 264 seconds]
bijan_ has quit [Quit: Shutting Down Interwebs...Done.]
woodruffw has joined #crystal-lang
woodruffw has joined #crystal-lang
woodruffw has quit [Changing host]
alex`` has quit [Ping timeout: 255 seconds]
hightower2 has quit [Ping timeout: 248 seconds]
rohitpaulk has quit [Ping timeout: 276 seconds]
faustinoaq has quit [Ping timeout: 260 seconds]
ome has joined #crystal-lang
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 260 seconds]