ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.31.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
<FromGitter> <Blacksmoke16> add the worker as a target to your shard.yml, then use the same base docker image as you do for your webapp (i.e. that has crystal and stuff) but just uses a diff command
<FromGitter> <tenebrousedge> πŸ‘
<FromGitter> <nsuchy> I can run multiple files?
<FromGitter> <nsuchy> can you show an example?
<FromGitter> <nsuchy> assume the worker is named worker.cr
<FromGitter> <nsuchy> in the src folder
<FromGitter> <Blacksmoke16> ```targets: ⏎ app: ⏎ main: src/app.cr ⏎ mosquito: ⏎ main: src/mosquito.cr``` [https://gitter.im/crystal-lang/crystal?at=5d9e76f3874aeb2d231b2e43]
<FromGitter> <Blacksmoke16> which when doing `shards build` would add 2 binaries into `./bin`
<FromGitter> <nsuchy> will it be automatically launched when I run amber watch
<FromGitter> <Blacksmoke16> i doubt it?
<FromGitter> <Blacksmoke16> but i dunno what that does so maybe?
<dwdv_> What's our `cumulativeFold`/`scan` equivalent?
<FromGitter> <tenebrousedge> `scan` ?
<FromGitter> <tenebrousedge> `reduce` ?
<FromGitter> <tenebrousedge> what are you trying to do?
<dwdv_> [1,2,3].cycle.cumulativeFold!((a,b) => a + b) => [1,3,6,...]
<dwdv_> .each and outer sum var is the closest in crystal, right?
<FromGitter> <tenebrousedge> don't use `each` >_<
<FromGitter> <Blacksmoke16> `while 1 == 1` :trollface:
<FromGitter> <tenebrousedge> you do need an outer variable
<FromGitter> <tenebrousedge> you could do something ugly using `reduce`
<dwdv_> How ugly, good sir?
<FromGitter> <tenebrousedge> using `{int, []}` as your accumulator
<dwdv_> Ah, the good old tuple. Let me see.
<FromGitter> <Blacksmoke16> `[1,2,3]map_with_index { |v, idx| idx = (idx.zero? ? 0 : idx - 1); v + arr[idx] || 0 }`?
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <tenebrousedge> you can always use `reduce` in some way. It can be used to write all other higher-order iterators
<FromGitter> <tenebrousedge> but sometimes it ain't pretty
<FromGitter> <Blacksmoke16> dont actually need the `|| 0`
<FromGitter> <Blacksmoke16> but i just realized thats not what you want
<dwdv_> Hm, this might be a good candidate for a PR, right? Want would you call it? Rust and haskell go with `scan`, others call it `cumulativeFold/-sum`.
<FromGitter> <Blacksmoke16> `arr..map_with_index { |v, idx| v + arr[0...idx].sum }`
<FromGitter> <Blacksmoke16> what about that? :p
<FromGitter> <tenebrousedge> I think a `cumulativeFold` wouldn't necessarily go amiss. What would you implementation be?
<FromGitter> <Blacksmoke16> id make an issue first
<dwdv_> `[1,2,3].map_with_index { |v, idx| v + arr[0...idx].sum }.first(10) => [1, 3, 6]`
<FromGitter> <Blacksmoke16> why the first 10?
<dwdv_> Should be an infinite list.
<dwdv_> Oops, missed cycle.
<FromGitter> <Blacksmoke16> ah interesting
<FromGitter> <tenebrousedge> if you want an infinite list, I would write an `Iterator`
<FromGitter> <Blacksmoke16> `1..Int64::MAX`
<dwdv_> I settled on a sum var even though you hate it, rather clean. ;)
<FromGitter> <Blacksmoke16> er well i guess thats not infinite
<FromGitter> <Blacksmoke16> dont mind me imma go back to eating my 🍝
<FromGitter> <tenebrousedge> I don't mind sum vars. I think `each` should only be used when there are no alternatives
<dwdv_> Sum var holds the intermediate sum, Blacksmoke16.
<dwdv_> ALright, thanks for your time you two.
<FromGitter> <tenebrousedge> dwdv have you done more exercisms?
<dwdv_> Not yet, doing AoC18 atm. Maybe tomorrow. Is your mentoring queue empty? :)
<FromGitter> <tenebrousedge> it usually is
<FromGitter> <tenebrousedge> someone submitted ten at once yesterday, kept me busy for a whole half hour
<dwdv_> Via mentoring requests?
<FromGitter> <tenebrousedge> yes
cpt_yossarian has quit [Ping timeout: 265 seconds]
woodruffw has joined #crystal-lang
dwdv_ has quit [Ping timeout: 240 seconds]
f1refly has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 240 seconds]
chemist69 has quit [Ping timeout: 276 seconds]
chemist69 has joined #crystal-lang
DTZUZU has quit [Quit: WeeChat 2.2]
DTZUZU has joined #crystal-lang
DTZUZO_ has quit [Quit: WeeChat 2.0]
DTZUZO has joined #crystal-lang
absolutejam4 has joined #crystal-lang
ht_ has joined #crystal-lang
<FromGitter> <andrius> Say we have an app, that listening on TCP socket or whatever and trigger some action based on certain events. Like `on_ping`, `on_connect`, whatever... When and why you will call it a hooks, callbacks or observers? ;)
<FromGitter> <andrius> It is more about style. My app does use a lot of individual event handlers
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
absolutejam4 has quit [Ping timeout: 250 seconds]
absolutejam4 has joined #crystal-lang
ht_ has quit [Quit: ht_]
absolutejam4 has quit [Ping timeout: 265 seconds]
absolutejam4 has joined #crystal-lang
<FromGitter> <mavu> morning, how do I disable certificate checking in a http/client?
<FromGitter> <mavu> I can pass a ssl context to HTTP::Client.new but what (and why) do i have to pass required key and cert options? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9edcb07aa5602ffc9ed501]
<FromGitter> <absolutejam_gitlab> `OpenSSL::SSL::Context::Client.insecure`?
<FromGitter> <mavu> is that what it does? ⏎ the description was not clear to me
<FromGitter> <mavu> "Returns a new TLS client context with only the given method set."
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
<FromGitter> <mavu> @absolutejam_gitlab yes, OpenSSL::SSL::Context::Client.insecure is the right thing.
<FromGitter> <mavu> (or at least it works, no idea if I am using it right :)
<FromGitter> <absolutejam_gitlab> It's right, it's just not clear in the docs
<FromGitter> <absolutejam_gitlab> and I can't find some of the type refs now that I look haha
<FromGitter> <absolutejam_gitlab> It'd be awesome if we got GitHub/IntelliJ style lookups
<FromGitter> <absolutejam_gitlab> click on a type in the docs
<FromGitter> <naqvis> @mavu you need to set `context.verify_mode = OpenSSL::SSL::VerifyMode::None` to disable certification validation. Just an example ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9ee3400459254672267115]
dwdv_ has joined #crystal-lang
absolutejam4 has quit [Ping timeout: 264 seconds]
absolutejam4 has joined #crystal-lang
<FromGitter> <mavu> @naqvis what is the difference between that and using the OpenSSL::SSL::Context::Client.insecure suggested above?
<FromGitter> <naqvis> @mavu Just verified in play, its same as above ⏎ ⏎ ```context = OpenSSL::SSL::Context::Client.insecure ⏎ pp context.verify_mode # => None``` [https://gitter.im/crystal-lang/crystal?at=5d9f0064e8de6f3ca070b500]
<FromGitter> <sam0x17> I'm getting this on alpine with crystal 0.31.0 and 0.31.1 (doesn't happen in previous versions): ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ When I ld each of those, it just warns that symbol_entry cannot be found. openssl-dev, etc, are all installed. What should I try? [https://gitter.im/crystal-lang/crystal?at=5d9f014d37073b36a0a229f9]
<FromGitter> <sam0x17> aha I got it!! seems like alpine has made some changes and separated out some packages into distinct -static versions, so the following dockerfile worked: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9f064a97358746732b03c1]
_whitelogger has joined #crystal-lang
hypercore has quit [Remote host closed the connection]
user2 has joined #crystal-lang
<FromGitter> <asterite> dwdv_ please create an issue for cumulative fold, we can probably add cumulative reduce. It's not the first time someone asks for it, and it seems pretty straightforward to implement :)
<dwdv_> How about cumulativeSum/Product helpers in the spirit of enumerable#sum/product?
user2 has quit [Ping timeout: 260 seconds]
<FromGitter> <yxhuvud> isn't reduce already cumulative? That is sortof the point of it, no?
user2 has joined #crystal-lang
<FromGitter> <ilanpillemer> could scratch work as well as alpine?
<FromGitter> <Daniel-Worrall> Once you have a static binary, yeah
user2 has quit [Ping timeout: 260 seconds]
user2 has joined #crystal-lang
alex`` has joined #crystal-lang
alex`` has quit [Ping timeout: 240 seconds]
alex`` has joined #crystal-lang
masterdonx2 has joined #crystal-lang
MasterdonX has quit [Ping timeout: 240 seconds]
alex`` has quit [Ping timeout: 265 seconds]
alex`` has joined #crystal-lang
user2 has quit [Ping timeout: 260 seconds]
<FromGitter> <repromancer_gitlab> looking for help with compiler error beautification
<FromGitter> <repromancer_gitlab> I've written up an example with a spec to sort of describe my goal (this compiles and runs successfully): https://play.crystal-lang.org/#/r/7rfz
<FromGitter> <repromancer_gitlab> If I pass the wrong number of arguments to an OrderRequest, I get a pretty informative message which points out the location of the error: https://play.crystal-lang.org/#/r/7rg4
<FromGitter> <repromancer_gitlab> However, passing in the wrong type for one argument gives an error pointing to the abstract class definition, not the location of the mistake: https://play.crystal-lang.org/#/r/7rg9
<FromGitter> <repromancer_gitlab> If I move the type annotations from the `property` statements to the initializer, I again get a better error pointing to the actual mistake: https://play.crystal-lang.org/#/r/7rgo
<FromGitter> <tenebrousedge> that seems correct to me
<FromGitter> <repromancer_gitlab> Right. My only gripe now is that this error says that the `data` argument must be of type `T`, not `Order`.
Human_G33k has joined #crystal-lang
<FromGitter> <tenebrousedge> because that's how it's defined
<FromGitter> <repromancer_gitlab> I wish I could get an error in between the first (non-informative regarding where the error is, but tells exactly which type is required) and the last (points out the location, but you have to go looking for what the type should actually be)
Human_G33k has quit [Remote host closed the connection]
Human_G33k has joined #crystal-lang
<FromGitter> <tenebrousedge> it's like that because you could define another initializer as `initialize(data : Order, time : Timestamp)`
<FromGitter> <repromancer_gitlab> it feels like I may have to write a macro which expands to a non-generic class definition in order to achieve this
<FromGitter> <tenebrousedge> it's pointing to the actual implementation. It can't do otherwise
<FromGitter> <tenebrousedge> you could use a macro, certainly
HumanG33k has quit [Ping timeout: 268 seconds]
<FromGitter> <r00ster91> How does this work? https://carc.in/#/r/7ri4 ⏎ Is `hello` copied before it's being iterated through?
<FromGitter> <tenebrousedge> blocks create a new scope
<FromGitter> <tenebrousedge> you're creating a local variable inside the loop which is nil, shadowing the outer variable
<FromGitter> <r00ster91> oh, right yeah
<FromGitter> <r00ster91> although when printing the variable outside then it is `nil` which makes it seem like that it did actually modify the existing variable instead of creating a new one: https://carc.in/#/r/7rib
<FromGitter> <tenebrousedge> hmm. So let's look at the `each_char` source then
<FromGitter> <r00ster91> I guess when the method finished then the state of the `hello` in the new scope is translated over to the old `hello`
<FromGitter> <tenebrousedge> no, it's calling `to_slice` internally
<FromGitter> <r00ster91> ah so it is actually making a copy
<FromGitter> <tenebrousedge> looks like it
<FromGitter> <tenebrousedge> and for non-ascii strings it uses a reader
<FromGitter> <tenebrousedge> which I guess means that it traverses the entire string and makes a copy before iteration begins
<FromGitter> <r00ster91> well the `to_slice` doesn't really mean anything actually: https://carc.in/#/r/7rjk ⏎ the same thing happens without a `to_slice`
<FromGitter> <tenebrousedge> ...huh
<FromGitter> <r00ster91> I think it's related to that internally when the function is called, the arguments are pushed to a stack
<FromGitter> <r00ster91> or maybe the compiler simply prevents the `string = nil` silenty
* FromGitter * tenebrousedge pokes it with a stick
<erdnaxeli> but the final print shows that 'string = nil'
<FromGitter> <r00ster91> it's probably doing the `string = nil` when the method finishes
<FromGitter> <r00ster91> wait nevermind
<FromGitter> <r00ster91> I think it's really creating a new variable but then passing the state of the new variable back to the old variable
<FromGitter> <tenebrousedge> that would be weird
<FromGitter> <r00ster91> ..at the end
<FromGitter> <r00ster91> weird? why?
<FromGitter> <r00ster91> that would probably be the smartest way to do it
<FromGitter> <r00ster91> I wish we could just look at the assembly but unfortunately Godbolt doesn't support crystal yet: https://github.com/mattgodbolt/compiler-explorer/issues/673
<FromGitter> <tenebrousedge> you could look at the llvm-ir
<FromGitter> <j8r> @bararchy for your Errno issue, it can't be solved.
<FromGitter> <j8r> Edit: @bararchy the Errno issue can be solved, but the code will be more verbose
<FromGitter> <j8r> We will see if it's accepted
<FromGitter> <j8r> Hum I think it can't be easily solved, to catch all `Errno*`
<FromGitter> <Daniel-Worrall> I'm worried. My app was giving me invalid memory accesses, and now it's just not without changing anything
<FromGitter> <tenebrousedge> you have mastered Crystal, and now the code fears you too much to throw exceptions
<FromGitter> <Daniel-Worrall> ah, nope, just wasn't reaching the code because part of it ran and filled in the db, so further runs relied on the db
<FromGitter> <tenebrousedge> :(
<FromGitter> <Daniel-Worrall> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9f418837073b36a0a40ab4]
<FromGitter> <Daniel-Worrall> not a very useful trace
<FromGitter> <tenebrousedge> it's always some sort of normal explanation, not magic <___<
<FromGitter> <Daniel-Worrall> I wish it was magic
<FromGitter> <Daniel-Worrall> it would make more sense to me
<FromGitter> <tenebrousedge> make it be magic
<FromGitter> <tenebrousedge> crystals should be magic
<FromGitter> <tenebrousedge> but yeah you may want to comment some things out until they stop going boom
<FromGitter> <Daniel-Worrall> This is an odd one
<FromGitter> <ImAHopelessDev_gitlab> good morning
absolutejam4 has quit [Ping timeout: 268 seconds]
absolutejam4 has joined #crystal-lang
<FromGitter> <Daniel-Worrall> This is baffling me
<FromGitter> <Daniel-Worrall> I can't reproduce it outside my app
<FromGitter> <tenebrousedge> what's your error trace look like?
<FromGitter> <Daniel-Worrall> gist above
<FromGitter> <tenebrousedge> what's `new_app.cr` look like? line 153 +- context
<FromGitter> <Daniel-Worrall> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9f4a127aa5602ffca1e5da]
<FromGitter> <Daniel-Worrall> https://github.com/sledgang/twitch/tree/webhooks and this is the lib I'm using (which I'm also writing)
<FromGitter> <Daniel-Worrall> I added a file to the gist
<FromGitter> <Daniel-Worrall> actually nevermind
<FromGitter> <Daniel-Worrall> I'm making a new one
<FromGitter> <Daniel-Worrall> Here we go
<FromGitter> <tenebrousedge> finding some way to tell OpenSSL to use `cipers -ALL` is probably a good idea
absolutejam4 has quit [Ping timeout: 250 seconds]
<FromGitter> <wontruefree> kind of crazy
<repo> i think i've asked about this already but maybe there's been some development on the matter: running a crystal program inside docker ignores any signint
<FromGitter> <wontruefree> I ahve been trying to run the crystal debugger in vscode
<FromGitter> <wontruefree> it is really hard to get it all to work on OSX
<FromGitter> <wontruefree> has anyone else gotten it to work
<repo> if you add Signal::INT.trap { exit } to your code manually it will work
<FromGitter> <Daniel-Worrall> I feel like I've run into that before repo
<FromGitter> <Daniel-Worrall> Which Docker
<repo> ?
<repo> version?
<FromGitter> <Daniel-Worrall> OS
<repo> Docker version 19.03.2-ce, build 6a30dfca03
<FromGitter> <Daniel-Worrall> Since Windows and *nix work very different in docker engining
<repo> arch
<repo> (linux)
<repo> it's very easy to reproduce
<FromGitter> <Daniel-Worrall> Oh wait I think I reproduced it
<FromGitter> <Daniel-Worrall> `Content-Length header is 207 but body had 0 bytes`
<FromGitter> <Daniel-Worrall> oh wait
<repo> also there's some other weirdness with docker
<repo> stdout and stderr not being flushed
<FromGitter> <tenebrousedge> there might be an issue related to that
<FromGitter> <Daniel-Worrall> I'm confused, this wasn't happening a couple weeks ago
<FromGitter> <Daniel-Worrall> and I don't think I changed anything
<FromGitter> <tenebrousedge> your openssl version may have changed
<FromGitter> <tenebrousedge> they occasionally deprecate or remove ciphers
<FromGitter> <tenebrousedge> docker would probably help you keep tabs on this sort of thing
<FromGitter> <Daniel-Worrall> it's on docker tho
<FromGitter> <tenebrousedge> so if you have an image from two weeks ago, check what openssl version it's using
<FromGitter> <Daniel-Worrall> which is why I'm extra confused
<FromGitter> <tenebrousedge> if necessary, pin it to a specific version
<FromGitter> <Daniel-Worrall> Actually, I'm technically using alpine:latest
<FromGitter> <Daniel-Worrall> so let's fix that
<FromGitter> <Daniel-Worrall> But it happens on static builds
<FromGitter> <tenebrousedge> did the openssl version change?
<FromGitter> <Daniel-Worrall> I don't believe so
<FromGitter> <j8r> @bararchy I think I did it, I submit a PR soon
ht__ has joined #crystal-lang
<FromGitter> <kinxer> @ImAHopelessDev_gitlab Good morning.
<FromGitter> <kinxer> @Blacksmoke16 Have you done anything with JSON schema in Crystal?
<FromGitter> <Daniel-Worrall> It happened again.
<FromGitter> <Daniel-Worrall> I didn't change anything and now it works
<FromGitter> <kinxer> Y'all asked for magic, and lo!
<FromGitter> <Blacksmoke16> not really no, not too familiar with it
<FromGitter> <kinxer> Gotcha. It looks like quicktype (https://app.quicktype.io/#l=schema) has support for generating Crystal from a JSON schema.
<FromGitter> <kinxer> It looks like JSON Schemas are used to validate json data, so I thought you might've come across it, since JSON validation is in your wheelhouse.
<FromGitter> <Daniel-Worrall> I like the idea of JSON schemas, but I see so many applications violate them
<FromGitter> <Daniel-Worrall> Damned lazy js devs
<FromGitter> <Blacksmoke16> maybe something for the future
<FromGitter> <ilanpillemer> SOAP required a schema.
<FromGitter> <Blacksmoke16> currently the validation lib is generic enough that it shouldn't be tied to JSON
<FromGitter> <kinxer> That makes sense.
<FromGitter> <Blacksmoke16> can be integrated with any format, as the validations are based on the properties
<FromGitter> <Blacksmoke16> could prob use `class_property` with a default
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Object.html#class_property(*names,&block)-macro repo
<FromGitter> <kinxer> I've been looking at Rust for the first time recently... Am I remembering correctly that you and someone else (maybe \@j8r) were thinking of making a shard along the lines of Serde?
<FromGitter> <kinxer> (Trying not to ping them, but I don't know if it worked...)
<FromGitter> <Blacksmoke16> he has a gist of a prototype
<FromGitter> <kinxer> It's an appealing idea, for sure.
<FromGitter> <Blacksmoke16> my shard is still a WIP a bit, serialization side of things is pretty much complete, however it only supports JSON atm
<FromGitter> <Blacksmoke16> https://github.com/Blacksmoke16/CrSerializer/tree/refactor if you wanted to take a look can download the zip and build the docs, everything is documented in there
<FromGitter> <Blacksmoke16> or checkout the models/specs
<FromGitter> <tenebrousedge> @kinxer have you seen JSON ORM ? https://github.com/jsonapi-suite/jsorm
<FromGitter> <Blacksmoke16> https://github.com/Blacksmoke16/CrSerializer/blob/refactor/src/annotations.cr includes all the features so far
<FromGitter> <kinxer> @tenebrousedge No, I haven't. I've (thankfully) avoided javascript for the most part, since I don't do web work (and so have not used TypeScript).
<FromGitter> <kinxer> I've actually never used an ORM.
<FromGitter> <tenebrousedge> typescript is optional
<FromGitter> <kinxer> Right, but it's for use in JavaScript or TypeScript, right?
<FromGitter> <tenebrousedge> yes
<FromGitter> <kinxer> The link to their docs is broken...
<FromGitter> <tenebrousedge> yeah, I think they do have docs online somewhere
<FromGitter> <kinxer> @Blacksmoke16 I think the docs aren't building right for some reason:
<FromGitter> <Blacksmoke16> 😬
<FromGitter> <Blacksmoke16> whats under them?
<FromGitter> <Blacksmoke16> as i said its a WIP so prob just didnt do a doc pass on the deserialization stuff yet
<FromGitter> <Blacksmoke16> i.e. add `:nodoc`
<FromGitter> <tenebrousedge> but it's a neat project if you're working with a JS frontend and something vaguely like ActiveRecord on the backend
<FromGitter> <kinxer> @tenebrousedge I'll keep that in mind. Thanks.
<FromGitter> <kinxer> @Blacksmoke16 Lots of links to nonexistent pages (e.g. `CrSerializer::Annotations`).
<FromGitter> <Blacksmoke16> really?
<FromGitter> <Blacksmoke16> sec
<FromGitter> <Blacksmoke16> i pushed a fix
<FromGitter> <Blacksmoke16> at least makes it work :S
<FromGitter> <Blacksmoke16> had a rouge `:nodoc:` on the modules that broke everything
<FromGitter> <kinxer> I just used `sed` to get rid of all the `:nodoc:` :P
<FromGitter> <kinxer> Your solution is probably better.
<FromGitter> <Blacksmoke16> that works too
<FromGitter> <kinxer> Your fix works. :)
<FromGitter> <Blacksmoke16> πŸ‘
<FromGitter> <kinxer> So in order to define a serialization format you have to `include CrSerializer::Format` and implement some functions?
<FromGitter> <Blacksmoke16> pretty much yea
<FromGitter> <kinxer> That seems pretty straightforward.
<FromGitter> <kinxer> Though I'm sure it's not exactly trivial.
<FromGitter> <Blacksmoke16> look at the json one
<FromGitter> <Blacksmoke16> basically just adding a bunch of methods to various types to support it
<FromGitter> <Blacksmoke16> some of it might be reusable between formats tho, but for now been mainly going off of what the current JSON::Serializable did
<FromGitter> <Blacksmoke16> the actual implementation of it is kept separate from the shard, i.e. all the annotations/exclusion strategies are used between all formats
<FromGitter> <Blacksmoke16> from the format*
<FromGitter> <Blacksmoke16> i.e. don't need `JSON::Field` and `YAML::Field`
<FromGitter> <Blacksmoke16> `@[CRS::Name(serialize: "myAddress")]` would work for both
<FromGitter> <kinxer> That's pretty cool.
<FromGitter> <Blacksmoke16> the exclusion strategies are one of the cooler parts of it, as you can define custom ones
<repo> Blacksmoke16: good point. will do
<FromGitter> <Blacksmoke16> at work we use the PHP version that it was inspired from with some custom strats, where you can do `@IgnoreOnUpdate` on a property which will prevent that value from changing on PUT
<FromGitter> <Blacksmoke16> but allows it to be set on POST
<repo> hm although
<repo> nah i'll rather leave it
<repo> it's nicer to assign the trap procs with a block
<FromGitter> <Blacksmoke16> fair enough
<FromGitter> <kinxer> `CrSerializer::ExclusionStrategies::Version` is very cool.
<FromGitter> <Blacksmoke16> also groups ^
<FromGitter> <kinxer> Yeah. This is a really slick interface.
<FromGitter> <Blacksmoke16> i made it in such a way other frameworks would implement it, similar to what i did for athena
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9f643249c7720aaf9d04e7]
<FromGitter> <Blacksmoke16> easily could define group/version on a route/controller and it just gets passed to the serializer
<FromGitter> <Blacksmoke16> or add a post deserialize callback to run validations
<FromGitter> <Blacksmoke16> thanks :p im quite happy with it so far
masterdonx2 has quit [Ping timeout: 265 seconds]
MasterdonX has joined #crystal-lang
<FromGitter> <Blacksmoke16> serialization groups would also pair well with validation groups from https://blacksmoke16.github.io/assert/Assert/Assertions/Assertion.html
<FromGitter> <didactic-drunk> Does anyone use sqlite in crystal?
MasterdonX has quit [Ping timeout: 250 seconds]
MasterdonX has joined #crystal-lang
dannyAAM has quit [Quit: znc.saru.moe : ZNC 1.6.2 - http://znc.in]
dannyAAM has joined #crystal-lang
<FromGitter> <nsuchy> @didactic-drunk i'm sure there's at least one person πŸ€ͺ - jokes aside I have used it - what do you need help with?
sagax has quit [Remote host closed the connection]
<FromGitter> <nsuchy> How do I run several targets in my shards file at the same time?
<FromGitter> <didactic-drunk> Do you use enforced foreign keys constraints?
<FromGitter> <nsuchy> Do I need seperate docker containers or can I have shards run bother targets after builds
<FromGitter> <Blacksmoke16> should use separate containers
<FromGitter> <nsuchy> I need to rework my VPN logic to handle multiple containers
<FromGitter> <Blacksmoke16> you can use the same base image
<FromGitter> <Blacksmoke16> just have two services run diff commands from that image
<FromGitter> <nsuchy> issue there is that it'll need one connection per container)
<dwdv_> Is `{{ @type.ancestors.select ... }}` the proper introspection tool to print all modules a certain class includes?
<FromGitter> <Blacksmoke16> does that work? there is a PR to get that
<FromGitter> <Blacksmoke16> er nvm it does the other direction
<FromGitter> <Blacksmoke16> sec
<FromGitter> <nsuchy> @Blacksmoke16 looked at https://docs.docker.com/config/containers/multi-service_container/ but it's messy
<FromGitter> <Blacksmoke16> well yea, you should have 1 container for each service you want to run
<FromGitter> <Blacksmoke16> i.e. web app, db, worker
<FromGitter> <nsuchy> That leads me with Web App, Redis Cache, Redis Job Queue, Worker, we have a centralized database server for auditing purposes (not dockerized).
<FromGitter> <nsuchy> just seems like a lot of containers
<FromGitter> <Blacksmoke16> thats how it works
sagax has joined #crystal-lang
<FromGitter> <nsuchy> Won’t it slow down the server if I have a bunch of Debian containers
<FromGitter> <Blacksmoke16> prob not, each container is really only doing 1 thing
<FromGitter> <Blacksmoke16> imagine size is really the main consideration
<FromGitter> <Blacksmoke16> as i mentioned before you can use "inheritance" to define base images that others could inherit from
<FromGitter> <Blacksmoke16> i.e. your db/worker containers dont need amber installed
<FromGitter> <Blacksmoke16> ideally using debian slim or alpine images can help with that
absolutejam4 has joined #crystal-lang
<FromGitter> <jwoertink> Anyone got a sec to look at this? https://play.crystal-lang.org/#/r/7rxu
<FromGitter> <lsymonds_gitlab> It's also worth noting that layers (basically each separate line in a Dockerfile) are also cached. So if you have `RUN apt update` in more than one Dockerfile (which you probably do), that layer will be cached and shared amongst all images.
<FromGitter> <jwoertink> > undefined constant T
<FromGitter> <jwoertink> My guess is because I'm calling the `go` method before it has a chance to define what `T` is
<FromGitter> <jwoertink> but I'm not sure another way to write this
<FromGitter> <tenebrousedge> does H need to be a class constant?
<FromGitter> <tenebrousedge> can you maybe use a method instead?
<FromGitter> <jwoertink> hmm... I think it makes most sense as either a constant or a class variable... but maybe I could do a class instead of a module, and then use an instance variable?
<FromGitter> <tenebrousedge> it probably would make the most sense, but there's no way for T to exist when the macro is being expanded, as far as I know
<FromGitter> <tenebrousedge> you could maybe write a bigger macro rather than using generics
<FromGitter> <jwoertink> alright, did a little test, and that might work. Gonna give that a shot. Thanks!
MasterdonX has quit [Ping timeout: 265 seconds]
MasterdonX has joined #crystal-lang
MasterdonX has quit [Quit: ZNC 1.7.4 - https://znc.in]
MasterdonX has joined #crystal-lang
<FromGitter> <wontruefree> has anyone here used lldb on a crystal program
<FromGitter> <wontruefree> I can get source mapping and breakpoints
<FromGitter> <wontruefree> but cannot seem to print variables
<FromGitter> <wontruefree> nevermind I just found this https://github.com/crystal-lang/crystal/issues/4457
alex``` has joined #crystal-lang
alex`` has quit [Ping timeout: 265 seconds]
alex``` has quit [Ping timeout: 250 seconds]
alex``` has joined #crystal-lang
<FromGitter> <tenebrousedge> general web app question: so I wasn't planning on having an admin user role. Now I need a way for certain user actions to be approved. So I want to introduce an admin user system to do that, and I am thinking about using two separate models for this, and potentially later splitting this into its own app or micro-service. If anyone has any horror stories about a web app with two user models (not roles, but
<FromGitter> ... separate classes) then it would be great to hear about it before I do something potentially stupid
<FromGitter> <jwoertink> @tenebrousedge I have an app that uses a `User` and a `Admin` as separate models with separate tables in the DB, and it works great for what I do. They log in to different systems though
<FromGitter> <tenebrousedge> yes, I was thinking of insisting on 2FA for admins
<FromGitter> <tenebrousedge> it's probably only going to be me for the forseeable future
<FromGitter> <Blacksmoke16> why not just have an admin roel?
<FromGitter> <Blacksmoke16> could always just add a column to the users table like `is_admin` :shrug:
<FromGitter> <tenebrousedge> because the admin user has zero to do with the rest of the app
<FromGitter> <Blacksmoke16> quick, simple
<FromGitter> <tenebrousedge> approval is literally the only functionality planned, and I wouldn't even go that far if there was another way to do it
<FromGitter> <jwoertink> Anyone familiar with crystal-db understand the query cache stuff? https://github.com/crystal-lang/crystal-db/blob/master/src/db/string_key_cache.cr
<FromGitter> <jwoertink> I'm running `db.query` with the same SQL, and it hits my postgres 4 times. My understanding is that it should hit it once
<FromGitter> <jwoertink> I also tried `db.prepared.query`, but same deal
<FromGitter> <tenebrousedge> πŸ‘€ it really looks like it should cache the query
<FromGitter> <tenebrousedge> is it closing the connection between queries?
<FromGitter> <jwoertink> I don't think so
<FromGitter> <jwoertink> I call `DB.open` once
<FromGitter> <jwoertink> but I don't use the block
<FromGitter> <tenebrousedge> if you do, does it cache the queries?
<FromGitter> <jwoertink> I added db.close after each one, but it doesn't seem to cache it
<FromGitter> <tenebrousedge> but closing clears the cache?
<FromGitter> <tenebrousedge> if you use the block form, and do two `select * from whatever`, how many times does that hit the db?
<FromGitter> <jwoertink> Yeah. Hits the DB each time. I also checked that it's shoving data in to that query hash, and it is
<FromGitter> <tenebrousedge> the same key each time?
<FromGitter> <jwoertink> checking
absolutejam4 has quit [Ping timeout: 268 seconds]
<FromGitter> <jwoertink> ok, turned on extra logging, and simplified my example
<FromGitter> <jwoertink> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9fb50a92920c36a14942d8]
<FromGitter> <jwoertink> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5d9fb5327aa5602ffca4fb1f]
<FromGitter> <tenebrousedge> I'd lose a finger for a `pry` for Crystal
<FromGitter> <elorest> @tenebrousedge https://github.com/elorest/cry
<FromGitter> <tenebrousedge> hey, I need those fingers!
<FromGitter> <tenebrousedge> dangit
<FromGitter> <elorest> lol. It's not exactly pry but it has some of my favorite features of it.
<FromGitter> <tenebrousedge> created by some guy named @elorest
<FromGitter> <elorest> The ability to edit and execute code repeatably.
<FromGitter> <tenebrousedge> I don't know if I can trust that sort of thing
<FromGitter> <tenebrousedge> so how does it work?
<FromGitter> <elorest> Rather well. You can also import include your application file if you want to use it like a console for Amber or probably lucky.
<FromGitter> <tenebrousedge> ah, I mean mechanics rather than quality
<FromGitter> <tenebrousedge> `icr` continually recompiles things
<FromGitter> <elorest> Yes. In amber we were originally using ICR. This was a huge problem because if someone were to run `User.last.delete` as their first statement it would get called every time without the users knowledge.
<FromGitter> <elorest> For every new line I mean.
<FromGitter> <elorest> So we wrote Cry to bring up and editor and let you run commands against your code and run as soon as you exited.
<FromGitter> <elorest> It also has a command to come back to the editor after it runs so you can modify it and go again.
<FromGitter> <elorest> It's about the best case scenario I can think of for a compiled language.
<FromGitter> <elorest> Plus the edit command is pretty much how I use Pry anyway.
<FromGitter> <tenebrousedge> I use `pry` as a step-by-step debugger, with the ability to poke at any value in memory
<FromGitter> <tenebrousedge> so in this case I would be following the execution of the query and making sure that values were hitting the query cache, or finding out why not by examining it between queries
MasterdonX has quit [Ping timeout: 240 seconds]
MasterdonX has joined #crystal-lang
return0e has quit [Remote host closed the connection]
dwdv_ has quit [Ping timeout: 245 seconds]