ChanServ changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
<FromGitter> <roduquen> Hi guys, a simple one, is there a possibility to go from JSON::Any to natural crystal ?
<FromGitter> <roduquen> Not by hand because I have nested and nested objects
<FromGitter> <roduquen> Without knowing how deep it can be
hendursa1 has quit [Quit: hendursa1]
hendursaga has joined #crystal-lang
hendursaga has quit [Quit: hendursaga]
hendursaga has joined #crystal-lang
andremedeiros has quit [Read error: Connection reset by peer]
andremedeiros has joined #crystal-lang
andremedeiros has quit [Read error: Connection reset by peer]
f1reflyylmao has joined #crystal-lang
andremedeiros has joined #crystal-lang
f1refly has quit [Ping timeout: 260 seconds]
f1reflyylmao is now known as f1refly
andremedeiros has quit [Read error: Connection reset by peer]
andremedeiros has joined #crystal-lang
DTZUZU has joined #crystal-lang
<FromGitter> <gdotdesign> Hi folks, anyone has any idea why the second one with `Å` is that much slower? https://play.crystal-lang.org/#/r/aitg
<FromGitter> <caspiano> g'day crystal friends, i need a nice way to profile runtime allocations (not via MacOS Instruments). ⏎ i tried hooking into `new` and `finalize`of `Class` and `Struct` to not much success. from an inexperienced read of the compiler, it looks like the `new` method is generated at compile-time and no level of macro hacks allowed me to do a `previous_def` hack. ⏎ ⏎ has anyone had success in this, or have
<FromGitter> ... any suggestions for further investigations? ⏎ thanks :) [https://gitter.im/crystal-lang/crystal?at=60485975120cd84f7806cfd2]
<FromGitter> <gdotdesign> I've just recently pointed to Valgrind https://valgrind.org/ which I believe can do that
<FromGitter> <gdotdesign> I've used it's callgrind tool with kcachegrind https://kcachegrind.github.io/html/Home.html to visualize
<FromGitter> <naqvis> @gdotdesign its because `[]` operator perform some checks on the validity of characters, as UTF chars might be greater than one byte. For your use case it would be better to first invoke `chars` on input string and then follow the same `[]` call . ⏎ ⏎ https://play.crystal-lang.org/#/r/aith
<FromGitter> <gdotdesign> nice, thank you!
<FromGitter> <caspiano> i've used valgrind for c in the past. I'll give it a shot with crystal! thanks for your help :)
<FromGitter> <gdotdesign> With this optimization the parsing of 20K LOC Mint code went from 20 seconds to 6 🎉
<FromGitter> <naqvis> 👏
<FromGitter> <naqvis> I'm sure you can further improve that by replacing `[]' call with `unsafe_fetch`
fifr` has quit [Ping timeout: 260 seconds]
_ht has joined #crystal-lang
hendursa1 has joined #crystal-lang
hendursaga has quit [Ping timeout: 268 seconds]
<FromGitter> <gdotdesign> I think it's fine for now, but good to know :)
<FromGitter> <gdotdesign> What is weird is that using the `--release` flag actually makes the parsing slower for some reason.
<FromGitter> <naqvis> that sounds weird
alexherbo21 has joined #crystal-lang
<sorcus> Hi.
<sorcus> `Error: undefined constant Schema::Parameter` - compiler returns this.
alexherbo21 has quit [Ping timeout: 260 seconds]
<FromGitter> <Blacksmoke16> because `Parameter` isn't in the `Schema` module, it cant find it
<FromGitter> <Blacksmoke16> because `getter! schema : Array(List)` is essentially `getter! schema : Array(Schema::List)` afaik
<FromGitter> <Blacksmoke16> i would have thought it would try and look it up on the top level, but apparently not?
alexherbo2 has joined #crystal-lang
<FromGitter> <Blacksmoke16> first one would prob work if you did `Array(::List)` maybe?
<FromGitter> <Blacksmoke16> er `Array(::Parameter)`
<FromGitter> <Daniel-Worrall> He said the first one works though, not doesn't
<FromGitter> <Blacksmoke16> oh
<FromGitter> <Daniel-Worrall> Broken when it's inside the module
<sorcus> Yeap. Maybe i'm doing something wrong, but i can't find what exactly.
deavmi has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
<FromGitter> <Blacksmoke16> ah i know why
<FromGitter> <Blacksmoke16> your `Schema` namespace is prob conflicting with YAML's
<FromGitter> <Blacksmoke16> renaming it to like `Schemaa` works too
<sorcus> Blacksmoke16: Yeap, you right. You're a genius :-D
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
yxhuvud has quit [Read error: Connection reset by peer]
deavmi has quit [Quit: Eish! Load shedding.]
yxhuvud has joined #crystal-lang
deavmi has joined #crystal-lang
_ht has quit [Remote host closed the connection]
_ht has joined #crystal-lang
DTZUZU has quit [Remote host closed the connection]
_ht has quit [Remote host closed the connection]
DTZUZU has joined #crystal-lang
<FromGitter> <asterite> @gdotdesign `String#[]` is optimized for the ascii case, because an ascii char is always one byte. If there's non-ascii then `#[]` is much, much slower, it basically needs to iterate it from the beginning to find it. Alternatives are: call `.chars` and work with that (as suggested) or use `Char::Reader`
teardown has quit [Remote host closed the connection]
teardown has joined #crystal-lang
<FromGitter> <gdotdesign> @asterite thanks! I've used `.chars` and that solved that specific problem still have the one where the parsing is slower using `--release` (but only since 0.36.0) I'll try to narrow it down some and make a benchmark.
fifr` has joined #crystal-lang
drakonis has joined #crystal-lang
_ht has joined #crystal-lang
chachasmooth has joined #crystal-lang
chachasmooth_ has quit [*.net *.split]
riffraff169 has quit [*.net *.split]
riffraff169 has joined #crystal-lang
alexherbo2 has quit [Quit: Ping timeout (120 seconds)]
alexherbo2 has joined #crystal-lang
postmodern has joined #crystal-lang
teardown has quit [Ping timeout: 268 seconds]
teardown has joined #crystal-lang
<f1refly> when using the sqlite3 shards based on crystal-db, is there a best way to generate tables that will store my models?
<f1refly> Thought I'd ask before trying to figure something out myself
<f1refly> My program creates a new db if it doesn't find one, so if it could read how the tables should look like from the model classes that would be pretty cool
<FromGitter> <Blacksmoke16> https://github.com/amberframework/micrate
<FromGitter> <Blacksmoke16> maybe not the best option then, but could just store the schemas and have your thing execute them against the connection
<f1refly> Better than nothing I guess, yeah
<drakonis> say, is there any soap library or would i have to roll out my own thing?
<FromGitter> <Blacksmoke16> or at least have some of setup script/instructions. Idk if your app really needs to handle doing that on its own
<FromGitter> <Blacksmoke16> like would the db really be changing/moving that often?
<FromGitter> <Blacksmoke16> drakonis i dont know of any
<f1refly> It's a very small database, <20 tables with not too many columns
<FromGitter> <RespiteSage> @drakonis I don't think there's anything for SOAP. In general, it doesn't seem like there's a lot of XML library support.
<drakonis> there's xml in the standard library
<FromGitter> <RespiteSage> The standard library has a functional XML library, but outside of that I haven't seen much.
<f1refly> And I'm still developing and adding more and changing things around, so currently I'm deleting the dev db and generate a new one with test data every launch
<FromGitter> <Blacksmoke16> fair enough
<drakonis> there's two incomplete soap libraries that i'm not aware of their current state of completion
<drakonis> porting one from ruby would be outside of my current level of expertise
<FromGitter> <RespiteSage> One of my "one day if I get the motivation" ideas is an XLM::Serializable library, which I think would make it easier to create libraries using XML.
<FromGitter> <RespiteSage> *`XML::Serializable`
<drakonis> i'm on a bit of a deadline as well
<drakonis> so that's out of question
<FromGitter> <RespiteSage> Oof. If you're using SOAP, are you interfacing with legacy software?
<FromGitter> <RespiteSage> Could you find a C library and write Crystal bindings? That's usually easier than re-implementing complex stuff like this.
_ht has quit [Remote host closed the connection]
alexherbo25 has joined #crystal-lang
alexherbo2 has quit [Read error: Connection reset by peer]
alexherbo25 is now known as alexherbo2
<drakonis> yes i am lol
<drakonis> i wish they had a rest endpoint
<FromGitter> <oprypin:matrix.org> if you have a deadline, can you just not use Crystal then?
<drakonis> well, yes
<drakonis> i can not use crystal
<drakonis> hmm but it actually has one
<drakonis> interesting.
<drakonis> i should check whether it works tho
<FromGitter> <oprypin:matrix.org> straight-shoota, well hello there indeed 👌
<straight-shoota> oh it works really well and integrates nicely with mkdocs-material =)
<FromGitter> <oprypin:matrix.org> straight-shoota, why do you have the generated site in master branch https://github.com/straight-shoota/carcin-play/blob/master/samples/hello-world/index.html but not have the source for it
<straight-shoota> cause it's just a sample for the playground thing
<straight-shoota> which operates on HTML
<straight-shoota> adding a site generator to build that sample would just complicate things and is absolutely unnecessary
alexherbo26 has joined #crystal-lang
<FromGitter> <oprypin:matrix.org> i -- what?
<FromGitter> <oprypin:matrix.org> just plopping the generated output and leaving it to the reader to figure out what you changed?
alexherbo2 has quit [Ping timeout: 245 seconds]
alexherbo26 is now known as alexherbo2
<FromGitter> <oprypin:matrix.org> i'd also say something about a javascript-less fallback but i suppose carc.in itself is hopeless in that regard
alexherbo2 has quit [Ping timeout: 246 seconds]
<FromGitter> <jrei:matrix.org> coding in Lua... it feels between Shell and Ruby
deavmi has quit [Ping timeout: 272 seconds]
<FromGitter> <oprypin:matrix.org> oh god... that about summarizes it
<straight-shoota> oprypin I don't understand. What do you want to know about what changes?
<straight-shoota> I just took a rendered page from mkdocs-material, stripped a few things that are irrelevant for the demonstration and placed it as a sample.
<FromGitter> <oprypin:matrix.org> straight-shoota, you clearly did something to make these lines appear https://github.com/straight-shoota/carcin-play/blob/2aedcafa78497fc20c7a40d668c56efd419d11c8/samples/hello-world/index.html#L197-L206
<FromGitter> <oprypin:matrix.org> why do i need to figure that out myself?
<straight-shoota> I just patched those lines in manually. You don't need to figure that out.
<FromGitter> <oprypin:matrix.org> ok i don't need to figure out what the sample is
<FromGitter> <oprypin:matrix.org> then just delete it i guess?
<straight-shoota> It's just an example for how to use the carc-in script, not how to integrate it with mkdocs
<FromGitter> <oprypin:matrix.org> how do i know that this line isn't an integral part of that example? https://github.com/straight-shoota/carcin-play/blob/2aedcafa78497fc20c7a40d668c56efd419d11c8/samples/hello-world/index.html#L150
<FromGitter> <jrei:matrix.org> in this file new lines are weird
<straight-shoota> you don't
<straight-shoota> but the integral parts are all mentioned in the usage instructions in the readme
<straight-shoota> there's nothing more to it, the example just places it in a realistic environment
<straight-shoota> the sample is a usage demonstration, not a guide
<straight-shoota> btw. what would be the best way to pull the js/css files into the crystal-book repo? git-submodule? Or does mkdocs have some tooling for that?
<straight-shoota> Or just plain checkout via makefile
<FromGitter> <oprypin:matrix.org> straight-shoota, i'd prefer less code to copypaste on the user side - i like https://highlightjs.org/usage/ approach. `CarcinPlay.insertAll(selector)` and even the selector can have the default ".crystal-play"
<FromGitter> <jrei:matrix.org> npm : haha
<FromGitter> <oprypin:matrix.org> straight-shoota, i don't have a good suggestion right now hmm. `npm` isn't even that funny..
<FromGitter> <jrei:matrix.org> a shell script that wget
<FromGitter> <oprypin:matrix.org> submodule seems like the perfect approach, other than the fact that submodules suck
<FromGitter> <jrei:matrix.org> subtree?
<straight-shoota> sure, such a simple api can be added for convenience
<straight-shoota> ah yeah, I meant subtree
<FromGitter> <jrei:matrix.org> but it is a bit worse to pin versions
<FromGitter> <oprypin:matrix.org> i don't even know about subtree. isn't submodule much more common?
<FromGitter> <jrei:matrix.org> don't know. subtree is more transparent, it is easy to not notice it
<straight-shoota> Idk but subtree is the brother that actually doesn't suck
<FromGitter> <jrei:matrix.org> suck less I would day.
<FromGitter> <oprypin:matrix.org> i'd like to see any real example of its use
<straight-shoota> it solves most if not all problems with submodules
<FromGitter> <jrei:matrix.org> my dotfiles (lol)
<FromGitter> <jrei:matrix.org> If you work with repositories you just want to sync and not bother with tags/versions - subtree it is definitely the best
<FromGitter> <oprypin:matrix.org> because `shards` doesn't support submodules, i have this awesome fallback... https://github.com/oprypin/crystal-imgui-sfml/blob/f1e8dc977ae2fe31d9042205a6454275e2bd2948/Makefile#L35
<FromGitter> <jrei:matrix.org> you don't even have to --recursive
<FromGitter> <jrei:matrix.org> I'd say in this repo you better use subtree
<FromGitter> <oprypin:matrix.org> how does a subtree look on github?
<FromGitter> <jrei:matrix.org> it looks like regular code
<FromGitter> <oprypin:matrix.org> that's a pass from me
<straight-shoota> yeah, subtree should work with shards because the entire content is checked into the host repo
<FromGitter> <jrei:matrix.org> pulled with subtree
<FromGitter> <jrei:matrix.org> nvm the history of the repo, I mess with it
<FromGitter> <oprypin:matrix.org> thanks
<FromGitter> <oprypin:matrix.org> no i actually think submodules are a better idea than subtree. just annoying implementation
<FromGitter> <jrei:matrix.org> it really depends.
<FromGitter> <jrei:matrix.org> On advantage of submodules is to have pinned versions/tags in a file
<straight-shoota> but subtree has the actual content pinned
<FromGitter> <jrei:matrix.org> but in your case you just want to use a repo at a given commit
<straight-shoota> (plus the commit sha ofc)
<FromGitter> <jrei:matrix.org> yeah
<FromGitter> <jrei:matrix.org> but some people may find the file more convenient
<FromGitter> <oprypin:matrix.org> Chromium project found actual custom files more convenient :D https://chromium.googlesource.com/chromium/src/+/master/DEPS#482
<FromGitter> <jrei:matrix.org> don't mind this... you know, that's Google - if in doubt: reinvent the wheel
<straight-shoota> Well, sometimes a new wheel might actually do better than the old triangular ones we have... :P