jhass changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.1 | 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
johnny101 has quit [Ping timeout: 256 seconds]
hightower2 has quit [Ping timeout: 246 seconds]
johnny101 has joined #crystal-lang
hightower2 has joined #crystal-lang
sorcus has quit [Quit: WeeChat 3.0]
<hightower2> hey why can't a block be optional like here: https://carc.in/#/r/a9ol
<oprypin> hightower2: that's just not a thing
<oprypin> the way you wrote it, you expect someone to actually pass a nilable type as the block, which, as it says, is not possible
<hightower2> aha, ok so need two overloads, with block and without. thanks
<oprypin> generally optional blocks are not implemented
<hightower2> great, yeah this part I was familiar with
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 246 seconds]
postmodern has joined #crystal-lang
f1refly has quit [Ping timeout: 246 seconds]
f1refly has joined #crystal-lang
_whitelogger has joined #crystal-lang
avane has quit [Quit: ZNC - https://znc.in]
avane has joined #crystal-lang
deavmi has joined #crystal-lang
issyl0 has quit [Read error: Connection reset by peer]
issyl0 has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
dom96 has quit [Ping timeout: 256 seconds]
dom96 has joined #crystal-lang
_whitelogger has joined #crystal-lang
deavmi has quit [Ping timeout: 256 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 246 seconds]
deavmi has joined #crystal-lang
deavmi has quit [Ping timeout: 272 seconds]
_ht has joined #crystal-lang
DTZUZU has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
Vexatos has quit [Quit: ZNC Quit]
Vexatos has joined #crystal-lang
<FromGitter> <rukkiddo> is there anything like layouts on ecr?
<FromGitter> <rukkiddo> lets say I called <%= ECR.render "./src/views/my-page.ecr" %> can it first call layour.ecr and embed the template to layout
<FromGitter> <Daniel-Worrall> Maybe you could put ECR.render in your ecr file
<Andriamanitra> maybe it's just a kemal thing but i've used <%= content > and then "render my-page.ecr, layout.ecr"
<FromGitter> <asterite> Yes, layout is an app thing, like in Ruby
<FromGitter> <naqvis> @rukkiddo quick approach would be define custom method, which renders the subview, store that to some known variable and have that variable be accessed inside layout. ⏎ ⏎ *subview.ecr* ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=60043660fb85d46e04e9bfe9]
<FromGitter> <rukkiddo> thanks everyone
<FromGitter> <rukkiddo> I think I will use @naqvis solution
deavmi has quit [Quit: No Ping reply in 180 seconds.]
deavmi has joined #crystal-lang
deavmi has quit [Remote host closed the connection]
deavmi has joined #crystal-lang
deavmi has quit [Client Quit]
deavmi has joined #crystal-lang
deavmi has quit [Remote host closed the connection]
deavmi has joined #crystal-lang
deavmi has quit [Quit: No Ping reply in 180 seconds.]
deavmi has joined #crystal-lang
deavmi has quit [Remote host closed the connection]
deavmi has joined #crystal-lang
alexherbo2 has joined #crystal-lang
deavmi_ has joined #crystal-lang
deavmi has quit [Ping timeout: 240 seconds]
deavmi_ has quit [Ping timeout: 246 seconds]
deavmi has joined #crystal-lang
MasterdonX has quit [Ping timeout: 264 seconds]
hightower2 has quit [Ping timeout: 246 seconds]
alexherbo23 has joined #crystal-lang
dom96 has quit [Ping timeout: 256 seconds]
deavmi has quit [Ping timeout: 256 seconds]
alexherbo2 has quit [Ping timeout: 256 seconds]
alexherbo23 is now known as alexherbo2
<FromGitter> <Blacksmoke16> @rukkiddo if you're still using athena theres a macro that does just that, https://athena-framework.github.io/athena/Athena/Routing/Controller.html#render(template,layout)-macro
dom96 has joined #crystal-lang
deavmi has joined #crystal-lang
<FromGitter> <rukkiddo> @Blacksmoke16 I decided to go without any framework (took me around 3 weeks to quit amber and still I have some small stuff missing), but I will borrow parts from Athena or others in situations like this, thanks!
<FromGitter> <Blacksmoke16> 😬 not sure rolling your own is the best option but 👍 gl
<FromGitter> <Blacksmoke16> mainly now you have to maintain that and your actual app code
<FromGitter> <Blacksmoke16> but probably doable if its simple enough
<FromGitter> <rukkiddo> thanks, it is simple really so I think it won't be hard to maintain
<FromGitter> <rukkiddo> my compilation time was 25 seconds, now it is around 3-4 seconds
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <rukkiddo> I was also worried because crystal framework communities are not that active anymore
<FromGitter> <Blacksmoke16> 25 sec, was that with amber or athena?
<FromGitter> <rukkiddo> with amber
<FromGitter> <Blacksmoke16> ah gotcha
<FromGitter> <oprypin:matrix.org> @rukkiddo: make them active then lol
<FromGitter> <rukkiddo> > @rukkiddo: make them active then lol ⏎ ⏎ I thought about it really, but it was only one of the problems that I have
<FromGitter> <rukkiddo> and @Blacksmoke16 you helped me a lot in all other channels, thanks.
<FromGitter> <rukkiddo> btw @Blacksmoke16 I told you my app was so much slower without amber, it turned out I forgot bcrypt code in the middle of the route lol, now it is much faster
<FromGitter> <Blacksmoke16> nice one, that would do it
deavmi has quit [Ping timeout: 256 seconds]
deavmi has joined #crystal-lang
hightower2 has joined #crystal-lang
<FromGitter> <anapsix> Greetings! ⏎ ... ⏎ so, this is crazy ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=60047de95562a61e9ab00a7f]
<FromGitter> <anapsix> yet, no trouble here ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=60047e5e5562a61e9ab00bfd]
<FromGitter> <Blacksmoke16> looks expected
<FromGitter> <Blacksmoke16> the first is a hash, the 2nd is a named tuple
<FromGitter> <Blacksmoke16> types of each namedtuple key/value are known at compile time since they're immutable
<FromGitter> <Blacksmoke16> hashes are dynamic and the compiler cant know what the value of a specific item in the hash is
<FromGitter> <anapsix> yeah.. you can see how I'd expect to be able to use Hash here :)
<FromGitter> <anapsix> me, being naive in compiled lang world
<FromGitter> <Blacksmoke16> coming from ruby/dynamic lang land yea. From Crystal perspective, its the correct behavior
<FromGitter> <anapsix> so, there is no way to work with hash containing other hashes? ⏎ how could I access `obj["b"]["ba"]` from first example?
<FromGitter> <Blacksmoke16> that should work fine
<FromGitter> <Blacksmoke16> i think
<FromGitter> <anapsix> nope ⏎ https://play.crystal-lang.org/#/r/a9pf
<FromGitter> <Blacksmoke16> ah right, would want to do something like `obj["b"].as(Hash)["ba"]`
<FromGitter> <Blacksmoke16> or really, dont use a hash in the first place :)
<FromGitter> <anapsix> yeah.. he-he.. I'm getting that vibe
<FromGitter> <Blacksmoke16> depending on what you're trying to do there might be better options
<FromGitter> <anapsix> building a simple config object after parsing YAML
<FromGitter> <Blacksmoke16> assuming the config cant be mutated at runtime after its been read
<FromGitter> <anapsix> yeah.. already using YAML Serializable
<FromGitter> <Blacksmoke16> then wheres the hash come into play?
<raz> i've found https://app.quicktype.io/ quite convenient to quickly scribble up nested structures
<FromGitter> <anapsix> after `from_yaml` getting parsed object, and saving it as `@data` ⏎ then from another method building hash with elements from `@data`
<FromGitter> <Blacksmoke16> why?
<FromGitter> <anapsix> :shug:
<FromGitter> <Blacksmoke16> you already have the data as a typed obj, why do you need the hash in the first place?
<FromGitter> <anapsix> cause some of the object variables are hashes.. and it gets weird when come I gotta access via `.variable` and nested ones as `.variable["key"]`
<FromGitter> <Blacksmoke16> to be clear serializable works with nested structures
<FromGitter> <Blacksmoke16> so you can define types for each structure then have like `getter sub_obj : SubObj`
<FromGitter> <anapsix> yep yep.. just wanted to make it faster / easier
<FromGitter> <Blacksmoke16> gotcha
<FromGitter> <anapsix> also, having trouble figuring out how to serialize something like this ⏎ ⏎ ```people: ⏎ john: ⏎ hungry: true ⏎ bill: ⏎ hundry: false``` [https://gitter.im/crystal-lang/crystal?at=6004827f81c55b09c713e678]
<FromGitter> <Blacksmoke16> ah, yea if the data is dynamic like that might have to use a hash
<FromGitter> <Blacksmoke16> like `Hash(String, Person)` or something
<FromGitter> <anapsix> this, I understand ⏎ ⏎ ```people: ⏎ - name: john ⏎ hungry: true ⏎ - name: bill ⏎ hundry: false``` [https://gitter.im/crystal-lang/crystal?at=60048315252c0a6ded17b882]
<FromGitter> <anapsix> previous example - I do not know how to serialize other than ⏎ ⏎ ```getter people : Hash(String, Hash(String, Bool))``` [https://gitter.im/crystal-lang/crystal?at=6004831c9632f63d87228d88]
<FromGitter> <anapsix> > like `Hash(String, Person)` or something ⏎ ⏎ ah.. right you are
<FromGitter> <Blacksmoke16> `getter people Array(Person)`
<hightower2> hey straight-shoota , regarding that discussion between you and asterite re --error-trace... did you think of reversing the trace order so that most-recent position is at the bottom? This way it wouldn't be of concern how long the trace is, since person can scroll up only as far as they need to, to see what they want.
<FromGitter> <asterite> That's the way it always was
DTZUZU has joined #crystal-lang
<FromGitter> <watzon> Sometimes while working on Crypto libraries I really wish there was a simpler way to pass around pointers than using `pointerof` and `Pointer#value`
<FromGitter> <watzon> Or a way to pass objects by reference that normally aren't, like Ints
_ht_ has joined #crystal-lang
_ht has quit [Read error: Connection reset by peer]
<FromGitter> <anapsix> > *<raz>* i've found https://app.quicktype.io/ quite convenient to quickly scribble up nested structures ⏎ ⏎ !!!!!
<FromGitter> <anapsix> this is some kind of black magic
<FromGitter> <anapsix> and for YAML, easy enough ⏎ ⏎ ```oq -i yaml . file.yaml | quicktype --lang cr -``` [https://gitter.im/crystal-lang/crystal?at=60049e9f787d8f79c80a8746]
<FromGitter> <Blacksmoke16> nice, `oq` :)
_ht_ has quit [Remote host closed the connection]
<FromGitter> <Daniel-Worrall> I found quicktype a while ago and have been shilling it in here ever since
<raz> anapsix: if you use vscode (or one of the supported editors) make sure to try the editor extension :) - in vscode it's pure bliss
<raz> yea i discovered it only recently, might be from you daniel actually!
<raz> 🙇‍♂️
<raz> (it's a godsent when integrating with some deeply nested JSON api, just paste in the json and bam, almost done)
<FromGitter> <Daniel-Worrall> It can work with multiple files too if you have some variation to refine it
alexherbo26 has joined #crystal-lang
alexherbo2 has quit [Read error: Connection reset by peer]
alexherbo26 is now known as alexherbo2
alexherbo23 has joined #crystal-lang
alexherbo2 has quit [Read error: Connection reset by peer]
alexherbo23 is now known as alexherbo2
alexherbo22 has joined #crystal-lang
alexherbo2 has quit [Read error: Connection reset by peer]
alexherbo22 is now known as alexherbo2
alexherbo25 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 240 seconds]
alexherbo25 is now known as alexherbo2
<FromGitter> <watzon> Man quicktype is like the json_to_crystal project I did years ago, but for all the languages
<FromGitter> <RespiteSage> Quicktype is wonderful. I use it to generate C++ classes from JSON schemas so that I don't have to maintain a manually-written library as a counterpart to the Java one for the same schemas (which I think is actually generated via Jackson, but I don't maintain that).
<FromGitter> <RespiteSage> Minimizing the C++ I have to write is *chefs kiss*.
<FromGitter> <watzon> Now if they could add .tl files as a source
<FromGitter> <watzon> I'd be stoked
<FromGitter> <watzon> Although those are a bit more abstract than JSON
<FromGitter> <RespiteSage> What's that extension?
<FromGitter> <watzon> TypeLanguage. Telegram uses it for their definitions and I'm pretty sure it's been adopted by some other projects.
<FromGitter> <Daniel-Worrall> I believe they also support json schema files
DTZUZU_ has joined #crystal-lang
DTZUZU has quit [Read error: Connection reset by peer]