ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.34.0 | 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
deavmi has quit [Ping timeout: 260 seconds]
deavmi has joined #crystal-lang
zorp_ has joined #crystal-lang
rocx has quit [Ping timeout: 260 seconds]
<FromGitter> <Blacksmoke16> @naqvis check this out
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec351bf7da13f3a0ac171a2]
<FromGitter> <Blacksmoke16> edited to remove the generic
<FromGitter> <Blacksmoke16> dont mind the overloaded `skip_property`, debating making the one with the `klass` standard
<FromGitter> <Blacksmoke16> kinda hacky since you cant get read the annotations at runtime, but :shrug:
<FromGitter> <Blacksmoke16> eh nvm, bit too much of a hack for my liking
<FromGitter> <wontruefree> We have a new podcast at Chicago Crystal please check it out and let us know what you think https://podcasts.apple.com/us/podcast/chicago-crystal/id1513656215
zorp_ has quit [Ping timeout: 256 seconds]
_whitelogger has joined #crystal-lang
HumanG33k has joined #crystal-lang
_ht has joined #crystal-lang
<FromGitter> <naqvis> :thumsup: looks very neat
<FromGitter> <naqvis> quick question, will these strategies be added by the framework? or user will need to add them?
<FromGitter> <naqvis> ``````
<FromGitter> <naqvis> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec38349b0256038f9db3be6]
alexherbo2 has joined #crystal-lang
<FromGitter> <naqvis> @wontruefree 👍 only 1 episode?
twistedpixels has quit [Ping timeout: 252 seconds]
twistedpixels has joined #crystal-lang
<raz> hmm. this has been mentioned here before, sometimes it'd be useful if constants could be abstract (require a constant to be defined in inheriting class).
<raz> like when you want to force the implementor to configure something for which there is no meaningful default
<raz> atm the way to go seems to be (if i'm not missing something) to use an abstract method. not sure if it's rational but somehow that feels wrong to me.
<raz> (i think mainly cause in such cases you'd clearly use a const in the parent class if inheritance wasn't needed)
<raz> </micro-rant-of-the-day> :)
alexherbo2 has quit [Ping timeout: 265 seconds]
deavmi has quit [Quit: Eish! Load shedding.]
deavmi has joined #crystal-lang
deavmi has quit [Client Quit]
deavmi has joined #crystal-lang
<jhass> raz: I think you can do {{@type}}:FOO
<jhass> eh ::FOO
<raz> hmmm, with a type restriction even?
* raz should experiment some more
<raz> even w/o a type restriction it'd come in handy for me
<jhass> moar duck typing ;P
<jhass> if it's assigned something that doesn't handle the operations you call it on you'll get a compile time error
<raz> hmm, not sure i understand
<raz> was thinking more along the lines of https://carc.in/#/r/93ku
<jhass> I got that. I didn't get why the heck you would need that
<jhass> seems Javaish again
<jhass> it's not like you can compile a program when a constant is missing where you expect it
<raz> maybe it is. it's just often my default thought when i make an abstract class and want to force the implementor to configure something
<jhass> well I never got abstract classes
<raz> yes, it's mostly about providing a helpful error message
<jhass> I only use them in java and only because I don't have modules
<raz> hm, well, yea, valid point
<raz> perhaps i should just use modules more
<jhass> and if my target platform would allow me even there I'd probably use interfaces with default implementations, so emulating modules
<raz> well, and if my aunt was my uncle... :P
<jhass> honestly I regret not having fought against abstract classes at this point
<raz> it's no big deal anyway, just a detail that comes up here and there and that i haven't yet found a fully satisfying solution for yet
<raz> i'm kinda torn on abstract classes. some of you seem to hate them, but i don't (yet) fully understand why
<raz> i guess most (or even all) of the things i use them for could also be done with modules
<raz> but abstract usually feels more natural to me, so that's what i reach for first
<raz> perhaps i was ruined by my java childhood :/
<FromGitter> <naqvis> raz i won't blame Java for that lol
<FromGitter> <naqvis> its just a matter of preference
<FromGitter> <naqvis> i am not big fan of inheritance so always prefer to go with composition
<raz> i have to admit i actually like java to a degree. ;) it's a bit clumsy but the JVM is great, docs are great. people mostly ruined it with XML hell, dumb patterns and Iot nonsense
<FromGitter> <naqvis> but that might be my preference
<raz> IoC*
<FromGitter> <naqvis> 😆
<jhass> I hate them because a) they're redundant to modules (ignoring some compiler bugs maybe), you can even define abstract methods in them! (but don't, see b) and b) they stand for something that's the opposite of what made Crystal appealing to me in the first place, trying to be a language that brings the implicitness and convention oriented programming from dynamic languages to the static
<jhass> world. They are relict errected by the everything needs to declared mindset. they're just on step away from hungarian notation
<FromGitter> <naqvis> never been a fan of SpringBoot
alexherbo2 has joined #crystal-lang
<FromGitter> <naqvis> though I spent whole lot of time on Struts lol
<raz> oh god struts... (PTSD moment)
<FromGitter> <naqvis> lol
<jhass> and yeah, they also make you too quickly think in inheritance rather than composition
<raz> jhass: yea, i can understand that in principle. i guess i just struggle to imagine crystal w/o abstract.
<jhass> go write ruby for half a year
<jhass> you'll get it
<raz> oh i've done that for about 30 half-years now ;P
<jhass> then I don't get you :P
<raz> well, maybe it's a bounce-back reaction. in ruby everything is liquid, so i love the rigidity that crystal provides (with types, abstract as kinda-interfaces etc.)
<raz> but you are of course right that modules pretty much do the same thing, so it might just be a "eh, this is almost like ruby again" kinda reluctance
<jhass> did you seriously ever miss a abstract def each(&block) in Ruby's Enumerable?
<raz> not on a daily basis, i don't think :p
<raz> but being able to define interfaces in general is def sth i misse
<jhass> it's kinda funny how that's the only Ruby core/stdlib example I can come up with
<raz> method_missing etc. are fun. but we all know where that goes when the app grows
<jhass> it's almost like you can design things without that
<jhass> everything else is just overridable hooks with reasonable default implementations
<raz> well. ruby is clay, crystal is lego. go-lang is lego with only 1x1 pieces. javascript is a pile of sand...
<jhass> "bring your own water?" :D
<raz> can all be used to arrange certain formations, but with different levels of rigidity
<raz> yea, pour water and hope it stays in place for a minute :p
<jhass> I want clay. Clay that tells me whether it cracks before I put it into the oven
<jhass> this is what I initially saw in Crystal
<jhass> I don't want to go out and buy a new lego brick because my idea is not realizable with the standard bricks
<raz> heh... ok, maybe we're stretching that analogy a bit now. but yea, crystal could also be seen as ruby with an oven :p
<raz> anyway, i could prob live w/o abstract if it was to be removed at some point
<raz> but i imagine that would break too many existing code to be realistic
<jhass> unfortunately
<jhass> I mean I guess I'm using this as a proxy discussion for the more general trend anyways
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<raz> nom nom, new commits on gripen
<raz> can't wait for this thing to land
<jhass> I'm really unhappy with the whole Digest/DigestIO API. Maybe we should mark it as experimental for 1.0
alexherbo2 has quit [Ping timeout: 256 seconds]
<FromGitter> <naqvis> you mean https://github.com/crystal-lang/crystal/pull/8426 ?
rocx has joined #crystal-lang
alexherbo2 has joined #crystal-lang
postmodern_ has quit [Quit: Leaving]
<jhass> kindof, and #9292 but I think this is just artifacts of the general API design
<DeBot> https://github.com/crystal-lang/crystal/pull/9292 (Add faster Digest#hexfinal, Digest#hexfinal(dst))
<jhass> which I think should be more IO yielding builder method style
<jhass> this whole #final thing and that changing what you can and should do with the object is terrible
<FromGitter> <naqvis> i guess it just try to mimic how golang has defined Hash (https://pkg.go.dev/hash?tab=doc) interface. Where one need to call `Sum` to get the current hash. In Crystal its called 'final`
<FromGitter> <Blacksmoke16> there are two built in ones, `Groups` and `Version`. But custom ones would need to be added like that
<FromGitter> <naqvis> wouldn't it be good to have kind of registration mechanism where one can restier the strategy implementation, thus each code can use that without instantiating separately?
<FromGitter> <naqvis> just thinking ....
<FromGitter> <naqvis> i assume built-in one would behave like i said above
<FromGitter> <naqvis> where dev don't need to instantiate them
<FromGitter> <naqvis> or my understanding is wrong?
<FromGitter> <Blacksmoke16> my thinking was the user could define their own serializer object in order to abstract this stuff. or even a method to get the context
<FromGitter> <Blacksmoke16> built in ones are like
<FromGitter> <Blacksmoke16> `context.groups = ["one", "two", "three"]` and that would add the group strategy
<FromGitter> <Blacksmoke16> user could also reopen the context to add some method to make adding it easier
<FromGitter> <naqvis> aha
<FromGitter> <naqvis> excellent design choice 👍
<FromGitter> <Blacksmoke16> or in a DI example, define a customer serializer, inject the default serializer, do extra logic and just pass that onto the original
<FromGitter> <naqvis> yeah, make sense
<FromGitter> <Blacksmoke16> i dont really see fancy strategies being used for now, i would rather it be a compile time construct, at least for annotation based approaches
<FromGitter> <Blacksmoke16> but that would depend on some features that dont exist yet
<FromGitter> <Blacksmoke16> we have one at work, `IgnoreOnUpdate` and `IgnoreOnCreate` that allows ignoring properties on PUT and POST requests. is kinda neat
<FromGitter> <naqvis> true , but it does offer these extension points and i'm sure there will be quite few use-cases for people developing framework(s) or similar libraries on top of it
<FromGitter> <Blacksmoke16> ideally it would have both runtime and compile time strategies
<FromGitter> <naqvis> agree and believe what you were asking for is a kind of RTTI or reflection, to retrieve things at run-time. indeed an excellent point, but don't think atm Crystal will plan to support this idea
<FromGitter> <naqvis> your hack is already clean-enough, its just too complicated to manage and add new strategies
<FromGitter> <HankAnderson> it's pretty ugly
<FromGitter> <Blacksmoke16> hack falls down with more than one type that has annotation
<FromGitter> <Blacksmoke16> as you get unions and such. Generics would work, but kinda even more of a hack to have to add a strat for each type ha
<FromGitter> <naqvis> true
<FromGitter> <Blacksmoke16> yea, there was an issue for reflection iirc. But i dont see it coming anytime soon/if at all
<FromGitter> <naqvis> yeah, might be in 2.0 or above
<FromGitter> <Blacksmoke16> *crystal 10.0* 👴
<FromGitter> <naqvis> rofl
woodruffw has joined #crystal-lang
HumanG33k has joined #crystal-lang
woodruffw has quit [Ping timeout: 256 seconds]
woodruffw has joined #crystal-lang
<FromGitter> <naqvis> @Uzay-G Nice post. Thanks for sharing 👍
travis-ci has joined #crystal-lang
travis-ci has left #crystal-lang [#crystal-lang]
<travis-ci> crystal-lang/crystal#c10dbc8 (master - refactor: remove heredoc related code from StringLiteral formatter (#9231)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/688807390
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Max SendQ exceeded]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Ping timeout: 264 seconds]
<repo> is there an svg logo of crystal anywhere i could use on my website?
<raz> does crystal even have a logo?
<raz> it has this spinning glenz vector thingy which looks cool
<raz> but don't remember an actual logo rn
<FromGitter> <Blacksmoke16> https://crystal-lang.org/media/
<repo> sweet thanks Blacksmoke16
<raz> hmm, we should make a better logo for 1.0
<jhass> noo, that would invalidate the stickers I still have :D
<raz> lol
<FromGitter> <naqvis> lol
<FromGitter> <j8r> @naqvis me too, prefer composition
<FromGitter> <naqvis> :handshake:
<FromGitter> <j8r> But sometimes, it is required to have a class
<FromGitter> <naqvis> agree, but those are rare cases :)
flips has left #crystal-lang ["WeeChat 2.7.1"]
<FromGitter> <j8r> yep. And the type system sometimes requires a abstract type over a module
<FromGitter> <j8r> that's not common
<FromGitter> <naqvis> we can just hope type system will evolve and get mature as language progresses
<FromGitter> <j8r> I think it make more sense to have ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec3f54d6773a13b23eeb346]
<FromGitter> <Blacksmoke16> yes
<FromGitter> <Blacksmoke16> user could define their own base class with common utilities
<FromGitter> <j8r> The object is forced to be one thing, and can include optional features
<FromGitter> <j8r> Yes
zorp_ has joined #crystal-lang
<FromGitter> <wontruefree> @naqvis We have 2 more recorded that are being edited and 1 more in the pipeline
<FromGitter> <wontruefree> we should have some more out soon
<FromGitter> <wontruefree> Also people have been asking so we have a website podcast.chicagocrystal.org
<FromGitter> <wontruefree> it has more services and feeds for podcast players
<FromGitter> <didactic-drunk> @jhass How would I incrementally hash streamed data received in a loop with a builder interface?
<jhass> wrap the builder around your receive loop
<jhass> or sender loop
<jhass> you already have a point where you start computing the digest and a point where you finish that. A builder API just enforces the presence of these points with no incompatible calls before or after the end point. Whatever your code between those points, just wrap it into the builder
<FromGitter> <didactic-drunk> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec4034a0c32623a4b438bf8]
<raz> wontruefree: hmm. i can't find your podcast with pocket casts
deavmi has joined #crystal-lang
<jhass> if you already buffer all the parts into one single buffer, why wouldn't you just run the digest once over that buffer?
<FromGitter> <brunto> Hi, I need some help to parse some jsonb data: ⏎ Here is my code: ⏎ ⏎ ```code paste, see link``` ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5ec404560506d43ab1923bb8]
<FromGitter> <Blacksmoke16> what is `roles`
<jhass> I'd argue running a digest over a *partial* stream is not the common usecase
<FromGitter> <Blacksmoke16> its prob just putting everything into the unmapped hash
<FromGitter> <brunto> roles is a jsonb from a postgresql query
<jhass> and even for that it's not too terrible
<FromGitter> <Blacksmoke16> right but what's its structure?
<FromGitter> <Blacksmoke16> you would need to create types that map to the structure in order to use `.from_json`
<FromGitter> <Blacksmoke16> like you dont have any properties within your `A` type, so everything is going into a `JSON::Any` hash due to the `Unampped` module
<FromGitter> <brunto> I want to put everything inside an unmappad hash because I don’t know the structure and the structure can change.
<FromGitter> <Blacksmoke16> ah
<jhass> wrap it into a method from which you can return unless msg and you can save the outer loop state variable
<FromGitter> <Blacksmoke16> so whats the problem then?
<FromGitter> <Blacksmoke16> oh its a string
<FromGitter> <brunto> The errors are:
<FromGitter> <brunto> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec404f40506d43ab1923cc5]
<FromGitter> <Blacksmoke16> possible to create some sample code in https://play.crystal-lang.org/#/cr ?
<FromGitter> <didactic-drunk> @jhass Size of stream is limited to ~200-300GiB without rekeying. Unlimited with rekeying.
<FromGitter> <brunto> ok I will
<FromGitter> <Blacksmoke16> 👍
<jhass> @brunto this looks like the result of Ruby's or Crytals Hash#inspect, not JSON
<FromGitter> <brunto> @Blacksmoke16 https://play.crystal-lang.org/#/r/93nt
<jhass> yeah
<jhass> this ain't json
<FromGitter> <Blacksmoke16> yup
<FromGitter> <Blacksmoke16> ORM is prob converting to a hash for you
<FromGitter> <Blacksmoke16> versus just providing the JSON string
<FromGitter> <brunto> This is returned by postgresql jsonb
<FromGitter> <brunto> :)
<jhass> who writes it?
<jhass> how do you read it?
<FromGitter> <brunto> I get it with a simple query with psql
<FromGitter> <didactic-drunk> @jhass You say it's not a common use case but libsodium secret stream kind of requires this as do other cryptographic streaming protocols.
<jhass> brunto: mind sharing a screenshot of the terminal session or so?
<jhass> or a literal copy paste from it
<FromGitter> <didactic-drunk> `EOM`isn't available until after decryption as the protocol is intentionally opaque.
<jhass> didactic-drunk: I don't say I didn't an extensive case study, just that the API seems brittle and it feels like it should be possible to do a better oen
<jhass> * I did I mean
<FromGitter> <wontruefree> @raz: It should be hosted on itunes spotify and google. I have opened accounts with some other providers but dont know which one pocket cast uses. You can always check out podcast.chicagocrystal.org and grab the RSS feed. I will look into pocketcasts
<raz> wontruefree: yep, it seems to be on literally every other platform except the one i use ;( (it's also a 404 when you click on it on your page)
<FromGitter> <didactic-drunk> I'm not against an `IO` interface even as the default. As long the current interface remains even if it's only recommended for advanced use.
<raz> no biggie, but would be great if it can get on there. i don't think (or don't know how) i can add RSS to pocketcast
<FromGitter> <Blacksmoke16> oh so PG returns that?
<FromGitter> <brunto> yes :D
<FromGitter> <Blacksmoke16> i.e. like nothing to do with crystal
<jhass> brunto: somebody writes the result of #inspect into that, this is a toplevel JSON string
<FromGitter> <brunto> Oh I think you’re right
<FromGitter> <brunto> So the data is wrong inside postgres
<jhass> yeah :)
<FromGitter> <Blacksmoke16> wait im confused now
<jhass> Blacksmoke16: Postgres wouldn't return the outer quotes for a JSON object
<FromGitter> <Blacksmoke16> data stored in PG is wrong or?
<jhass> yes
<FromGitter> <Blacksmoke16> 👍
<jhass> brunto: well I guess it could be to_s too, Hash#inspect and to_s actually don't differ
<FromGitter> <brunto> Ok I’ll try to update the date and I’ll see
<FromGitter> <naqvis> awsome. Thanks Jack
<FromGitter> <wontruefree> @raz: I might have had a typo in there try this link http://podcast.chicagocrystal.org/
<FromGitter> <wontruefree> also I checked it looks like pocketcast pulled from itunes but may be delayed :(
<raz> wonttrue: awesome, it showed up in the app now in iOS.
<raz> subscribed!
<FromGitter> <wontruefree> nice !!
<FromGitter> <wontruefree> I think it had to do a fetch of the itunes directory
<FromGitter> <wontruefree> thanks for hanging in there I hope you like it
<FromGitter> <kinxer> :D There's even a Pocket Casts link.
<FromGitter> <kinxer> I expected to need to use the RSS feed, but this is (marginally) easier!
HumanG33k has joined #crystal-lang
<FromGitter> <rishavs> gui & gpu support coming for wsl apps
<FromGitter> <kinxer> @raz Btw, re RSS on PocketCasts, you should be able to just paste the feed link into the search bar.
<raz> kinxer: ah, gtk thx!
<raz> already added this one now, but might come in handy another time
<FromGitter> <cbortz> Hey y'all, I'm having an issue trying to get the amber framework specs working locally. I'm using crystal v0.34.0 on macOS installed with asdf. When I run the specs, I get the following error: ⏎ ⏎ ```crystal spec ./spec/amber --debug --verbose``` ⏎ ⏎ Notably I can run the specs just fine when I use Cystal v0.34.0 installed via Homebrew. ... [https://gitter.im/cr
<FromGitter> ... ystal-lang/crystal?at=5ec41c6f0c32623a4b43d2b8]
rcvalle_ has left #crystal-lang ["Leaving"]
<FromGitter> <Blacksmoke16> prob some issue with how the version in asdf was built?
<FromGitter> <Blacksmoke16> iirc that was an issue with a specific llvm version
<FromGitter> <Blacksmoke16> @kinxer `nums << num if num.divisible_by? 7` :0
<FromGitter> <sam0x17> is there a way to run a process via `Process.run` and redirect the stdio / stderr to a `Log` instance
<FromGitter> <Blacksmoke16> idt a log is an `IO`, so not directly?
<FromGitter> <kinxer> @Blacksmoke16 I just wanted a conditional there that was simpler than the original code.
<FromGitter> <Blacksmoke16> yea, just meant that as a shortcut to `num % 7 == 0`
<FromGitter> <kinxer> I mean, it's certainly not *shorter*, but I prefer to read it. :)
<FromGitter> <Blacksmoke16> yea, just read better :p
<FromGitter> <kinxer> Oh, okay. I see. I didn't recognize that that's not what I did. ::P
<FromGitter> <kinxer> I think it's fine as-is, just 'cause it's closer to the original code. But I appreciate the suggestion.
<FromGitter> <naqvis> @sam0x17 ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec42ecbb0256038f9dd0a51]
<FromGitter> <Blacksmoke16> well actually could you do something with `IOBackend`?
<FromGitter> <Blacksmoke16> new up a memory io, set that as output/error for the process, then use that io also in the IObackend?
<FromGitter> <naqvis> i doubt, as one need to call those `info`, `debug` methods to write `Entry`
<FromGitter> <naqvis> so passing `IOBackend#io` to `Process#run` might not work
<FromGitter> <naqvis> would be good to extend that DummyWriter and invoke `Log.error` in error
<FromGitter> <naqvis> just my thoughts of hacking around on Sam question lol
<FromGitter> <naqvis> and this might not be the good approach, but it kind of work
<straight-shoota> has anyone noticed this reddit thread: https://www.reddit.com/r/crystal_programming/comments/gmhgxc/whkiogoldimagecrystal/
<FromGitter> <Blacksmoke16> i have
<FromGitter> <Blacksmoke16> didnt really dig into it much hto
<FromGitter> <Blacksmoke16> deleted his reddit account? :thinking:
<straight-shoota> No, user's still there: https://www.reddit.com/user/whk4/
<FromGitter> <Blacksmoke16> ah, was going off of `submitted 15 hours ago by [deleted]`
<straight-shoota> yeah, seems like reddit removes any trace
<straight-shoota> I still had a tab open, so I can see the deleted content and user name :D
<FromGitter> <naqvis> https://github.com/whk-io/goldimage-crystal ⏎ this is that guy github account
<FromGitter> <Blacksmoke16> @naqvis ah, yea `IOBackend` is for writing *TO* an `IO`, duh
<FromGitter> <kinxer> Why do you think it was deleted? Did he email the security email or something?
<FromGitter> <Blacksmoke16> didnt have any good answers? :P
<FromGitter> <naqvis> lol
<straight-shoota> ditched all my questions about specific issues with the official docker image, just mentioned vague rationales
<straight-shoota> So it feels very shady
<FromGitter> <kinxer> I mean, the removeddit link showed me a reply with container vulnerability comparisons. That seems like a decent reason (if it's true).
<straight-shoota> yeah, that's a good point. But you don't need an alternative docker image for that: https://github.com/crystal-lang/distribution-scripts/pull/68
<FromGitter> <kinxer> Oh, okay. I'm seeing @straight-shoota's replies now (missed the tab to show all comments).
<FromGitter> <naqvis> if thats the case, then i think its better to validate those claims by running that Trivy (https://github.com/aquasecurity/trivy)
<FromGitter> <Blacksmoke16> other one seems to be making it so you're not root
<FromGitter> <sam0x17> @naqvis thanks!
<FromGitter> <naqvis> ywc Sam
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec4328ee8153a398060885b]
<FromGitter> <Blacksmoke16> so running the image would plop you into `/crystal-app` as `crystal` user
<FromGitter> <Blacksmoke16> but given its a container does it really matter if you're not root
<FromGitter> <kinxer> Huh. Yeah, after reading the whole thing, I agree that it's pretty sketchy.
<FromGitter> <kinxer> Though, clearly, just deleting the post in the first place after barely any conversation is sketchy.
<FromGitter> <naqvis> agree, but I think one point raised is indeed valid, that we should be running some kind of container scanner to check against vulnerabilities
<FromGitter> <naqvis> i don't know if Crystal current CI system does have any similar check
<FromGitter> <j8r> I don't think it is needed
<FromGitter> <naqvis> why not?
<FromGitter> <j8r> Because we are up-to-date.
<FromGitter> <naqvis> provided you are building against latest distro
<straight-shoota> The crystal images are usually based on the latest LTS release
<FromGitter> <j8r> Using the latest stable distribution, it is near guaranteed to have the latest security patches
<FromGitter> <j8r> But the issue is: what about those built?
<straight-shoota> If Ubuntu can't update their libraries to remove vulnerabilities, how should we be able to do that?
<FromGitter> <j8r> Yeah, OS/package maintainers surely already have means to be informed of news about updates/patches
<FromGitter> <j8r> One issue though:
<FromGitter> <j8r> What's happen if the container built for, e.g., Crystal 0.34.0, now several months old, has security breach discovered now?
<FromGitter> <j8r> It is not really an issue now, because version releases are quite fast paced
<FromGitter> <j8r> But still, more the time between releases is long, bigger the issue of out-of-date "dangerous" packages is
<straight-shoota> We can rebuild the image and push it to dockerhub
<FromGitter> <naqvis> I just ran that Trivy (https://github.com/aquasecurity/trivy) scanner on Crystal latest docker and guess what?
<FromGitter> <naqvis> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec437720506d43ab192c62d]
<FromGitter> <Blacksmoke16> what kind of stuff? like just random libs in ubunut?
<FromGitter> <naqvis> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec437c5e8153a398060972b]
<FromGitter> <naqvis> and so on
<straight-shoota> that's kind of expected
<straight-shoota> there are always vulnerabilities
<FromGitter> <Blacksmoke16> curious to see what latest Go image has :S
<FromGitter> <naqvis> yeah true
<FromGitter> <naqvis> sure
<straight-shoota> The interesting thing is, these are different stats than what that guy on reddit posted
<straight-shoota> the total number is the same, but classification is different
<straight-shoota> TARGETS: 1 : LOW = 45 : MEDIUM = 359 : HIGH = 57 : CRITICAL = 3 : UNKNOWN = 0
<straight-shoota> COUNT: 464
<straight-shoota> Format is also different, so might've been using an older version of that scanner
<straight-shoota> But yeah, it's far less high and no critical vulnerabilities than he claimed
<straight-shoota> And his image has way more vulnerabilities than https://github.com/crystal-lang/distribution-scripts/pull/68
<jhass> but it's golden!
<jhass> its just some guy that found a way to get some attention and then didn't like it
<jhass> don't bother too much :)
<straight-shoota> probably
<FromGitter> <naqvis> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec438e60c32623a4b441dfc]
<FromGitter> <Blacksmoke16> nice
<FromGitter> <naqvis> so question is why Crystal is using `bionic`? is that for some specific reason?
<jhass> copy pasta
<jhass> next up: elixir or python
<jhass> any other bets?
<FromGitter> <naqvis> rofl
<FromGitter> <naqvis> i would bet on elixir 😆
<straight-shoota> naqvis: When Crystal 0.34.0 was released, bionic was the latest LTS release
<jhass> oh look he only pushed two of IDK HOW MANY to github
<FromGitter> <naqvis> thanks straight-shoota, so 0.35.0 would be built against `latest` version of ubuntu?
<FromGitter> <naqvis> jhass what worries me is those download count against images he has built
<FromGitter> <naqvis> though Dockerfile he has shared on github looks harmless, but who knows the one posted on hub is same built from that
<straight-shoota> If https://github.com/crystal-lang/distribution-scripts/pull/68 is merged in time, 0.35.0 will build on 20.04
<FromGitter> <naqvis> great
<jhass> anybody noticed the formatter always forcing ternaries on a single line?
<FromGitter> <j8r> @naqvis I'd be curious about alpine:latest
<FromGitter> <j8r> should not have much
<FromGitter> <sam0x17> anyone familiar with https://github.com/axvm/cake know if it is possible to do nested tasks / tasks with spaces in them e.g. `cake db migrate` rather than `cake db_migrate`
<FromGitter> <sam0x17> eh I'll just do the rails `db:migrate` syntax that seems to work in a string
<travis-ci> crystal-lang/crystal#ea80f4c (master - Always include `lib` directory in the CRYSTAL_PATH (#9315)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/688976415
travis-ci has left #crystal-lang [#crystal-lang]
travis-ci has joined #crystal-lang
<DeBot> https://github.com/crystal-lang/crystal/pull/9315 (Always include `lib` directory in the CRYSTAL_PATH)
<FromGitter> <sam0x17> nvm I lied it strips out the inner ":"
<FromGitter> <Blacksmoke16> @naqvis https://github.com/crystal-lang/crystal/issues/9322 this would work better than that hacky example i had earlier i think
<FromGitter> <j8r> I doubt it is possible: can we get ivars from a given type, without monkey-patching it?
<FromGitter> <j8r> (nor `Object`)
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <Blacksmoke16> it would be fairly easy to implement, we have the data already, just needs to be exposed
<FromGitter> <Blacksmoke16> as currently `.annotation` or `.annotations` require the type of the annotation
<FromGitter> <Blacksmoke16> this would essentially just be like
<FromGitter> <Blacksmoke16> ```def annotation ⏎ @annotations.values ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=5ec448676773a13b23ef9af7]
<FromGitter> <Blacksmoke16> something along those lines
<FromGitter> <j8r> The type cannot be modified
<FromGitter> <Blacksmoke16> so?
<FromGitter> <Blacksmoke16> not sure i follow
<FromGitter> <j8r> Let's say I want ivars from `Path`
<FromGitter> <Blacksmoke16> sorry, to be clear this would still be limited by current limitations
<FromGitter> <Blacksmoke16> i.e. have to be within a method
<FromGitter> <j8r> I would like to have `dosometing(type : T.class) forall T`
<FromGitter> <j8r> this could be a macro
<FromGitter> <Blacksmoke16> thats already a thing
<FromGitter> <Blacksmoke16> and you can get annotations off of `T`
<FromGitter> <Blacksmoke16> and/or ivars
<FromGitter> <j8r> essentially, instead of `{{ @type.instance_vars }}`, something like `{{ sometype.instance_vars }}`
<FromGitter> <Blacksmoke16> can also do that yea, the macro code just has to be within the context of a method
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/93pw
<FromGitter> <Blacksmoke16> *magic* :p
<FromGitter> <j8r> Ha great!
<FromGitter> <j8r> I'd like to use instance instances instead of types ⏎ Like, iterating over ivars of `point = Point.new`
<FromGitter> <Blacksmoke16> mmm
<FromGitter> <j8r> I think I'd need another method
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/93py/edit?
<FromGitter> <j8r> got it https://play.crystal-lang.org/#/r/93q7
<FromGitter> <j8r> thanks :D
<FromGitter> <Blacksmoke16> np
renich has joined #crystal-lang
<FromGitter> <watzon> @Blacksmoke16 with granite would there be a good way to make a model's column an `Array(EnumValue)`?
<FromGitter> <Blacksmoke16> does that not work already?
<FromGitter> <watzon> Does it? I haven't tried yet.
<FromGitter> <Blacksmoke16> it might?
<FromGitter> <Blacksmoke16> have to use pg tho
<FromGitter> <Blacksmoke16> imma give it 60% no, but we'll see
<FromGitter> <watzon> Hmm dang, I was hoping to use SQLite. I could try with PG though.
<FromGitter> <Blacksmoke16> pg is only one that supports actual array types
<FromGitter> <Blacksmoke16> could JSON encode it and use a converter or whatever tho
<FromGitter> <Blacksmoke16> to get the same effect
<FromGitter> <watzon> PG does allow you to query with Array types though doesn't it?
<FromGitter> <Blacksmoke16> yea
<FromGitter> <Blacksmoke16> what support is like for that, no idea
<jhass> what do you mean by "query with"?
<FromGitter> <watzon> Guess that answers my question
<FromGitter> <watzon> @jhass I mean query records based on values in the array
<straight-shoota> that works well
<straight-shoota> with crystal-pg
<FromGitter> <Blacksmoke16> @watzon migrator in granite is very basic. Mainly just for specs
<FromGitter> <Blacksmoke16> I'd create the table manually, and try actually doing something
<FromGitter> <watzon> Idk what query I'd need to create that column
<FromGitter> <Blacksmoke16> Probably the enum name +[]
<FromGitter> <Blacksmoke16> Sec
<jhass> watzon: are you looking for the array operators? https://www.postgresql.org/docs/12/arrays.html#ARRAYS-SEARCHING
<FromGitter> <Blacksmoke16> `CREATE TYPE status AS ENUM ('Active', 'Inactive', 'Pending');`
<FromGitter> <Blacksmoke16> `CREATE TABLE integrations ( id BIGSERIAL, status status[]);` should do it?
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec459ebf7c0af39ee199cf2]
<FromGitter> <Blacksmoke16> anw
<FromGitter> <Blacksmoke16> would need a converter
<FromGitter> <Blacksmoke16> er not even sure if that would help
<FromGitter> <watzon> Meh
<FromGitter> <watzon> I'll just use JSON
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <Blacksmoke16> cant use `Enum` is union so yea
<FromGitter> <Blacksmoke16> in a*
<FromGitter> <watzon> Hmm with `JSON::Field` I always thought that `key` was the elements key, and that `base` would be the root key. But it seems like it's the opposite? So: ⏎ ⏎ ```{ ⏎ "key": { ⏎ "base": "value" ⏎ } ⏎ }``` [https://gitter.im/crystal-lang/crystal?at=5ec46330940fa238d6027529]
<FromGitter> <watzon> Yes?
<FromGitter> <watzon> For instance, right now I have the following JSON: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ec463806773a13b23efea91]
<FromGitter> <watzon> And this model ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ but it doesn't work because there are multiples of the same key. If I comment out all but one of the fields with a `key: "base"` it works though, so I know it's getting the value from the right place. [https://gitter.im/crystal-lang/crystal?at=5ec463cde8153a398061072a]
<FromGitter> <Blacksmoke16> you have it backwards i think
<FromGitter> <Blacksmoke16> root would be `base`, and `key` would be like `HP` and such iirc
<FromGitter> <watzon> I had it the other way around at first, but it doesn't work
<FromGitter> <Blacksmoke16> oh?
<FromGitter> <watzon> This way works, but it complains about multiples of the same key
<FromGitter> <Blacksmoke16> rip
<FromGitter> <watzon> Has to be a bug. There's no way that's intended behavior.
<FromGitter> <j8r> I need your opinion on this API: https://play.crystal-lang.org/#/r/93rt ⏎ Note: I have not implemented annotation yet, I would like to be on par with `JSON::Serializable` (and `YAML`)
<FromGitter> <Blacksmoke16> serializable stuff is implemented with case
<FromGitter> <j8r> Main pros of this are: ⏎ ⏎ 1) No monkey patching at all! ⏎ 2) Work out of the box! [https://gitter.im/crystal-lang/crystal?at=5ec4644a7da13f3a0ac43e50]
<FromGitter> <j8r> @Blacksmoke16 `case` is bad?
<FromGitter> <j8r> never loved the actual the stdlib serialization stuff...
<FromGitter> <j8r> the `#to_json` looks "nice", but this monkey patching approach has its limits
<FromGitter> <j8r> It adds loads of methods everywhere. Furthermore, it can't be generalized: imagine `to_xml`, `to_bson`, `to_toml` (:)
<FromGitter> <watzon> https://carc.in/#/r/93rz
<FromGitter> <watzon> This works, but as soon as you uncomment any of the commented lines it breaks
<FromGitter> <j8r> @Blacksmoke16 I have seen your PR https://github.com/athena-framework/serializer/pull/1, very interesting! Omg lots of work
<FromGitter> <Blacksmoke16> @j8r no, but it cant have duplicate keys, hence the error @watzon is getting
<FromGitter> <Blacksmoke16> would need to add them all in the same when
<FromGitter> <Blacksmoke16> `when "hp", "attack", etc`
<FromGitter> <watzon> Right. `key` and `root` should also probably be reversed.
<FromGitter> <watzon> The naming doesn't make sense as is
<FromGitter> <Blacksmoke16> @j8r and thanks :), indeed. Quite happy with the end result i think tho
<FromGitter> <Blacksmoke16> sadly i dont think it has something to help @watzon yet tho...
<FromGitter> <watzon> Yeah not likely. Especially since I'm dealing with Granite models, which implement JSON::Serializable.
<FromGitter> <Blacksmoke16> i think it would be doable tho
<FromGitter> <watzon> I'm just trying to take a huge JSON document and create models
<FromGitter> <Blacksmoke16> something like
<FromGitter> <Blacksmoke16> ```@[PropertyPath("base", "HP")] ⏎ property hp : Int32``` [https://gitter.im/crystal-lang/crystal?at=5ec4668670f28c384b8672c9]
<FromGitter> <Blacksmoke16> or
<FromGitter> <j8r> @Blacksmoke16 yeah, it is a very simple POC
<FromGitter> <Blacksmoke16> ```@[Accessor(path: {"base", "HP"})]` ⏎ property hp : Int32``` [https://gitter.im/crystal-lang/crystal?at=5ec466a4b8869e38c49b6026]
<FromGitter> <j8r> I will do a `%found{name} = true`
<FromGitter> <Blacksmoke16> sorry, was talking about my thing, doesnt have anything to help either :/
<FromGitter> <Blacksmoke16> downside of using the pull parser is its harder to do dynamic stuff with the data
<FromGitter> <Blacksmoke16> since you dont have it all available, and cant rewind
<FromGitter> <watzon> Well I made an issue #9323 let's see what people say
<DeBot> https://github.com/crystal-lang/crystal/issues/9323 (Confusing naming/functionality in JSON::Serializable)
Nekka has joined #crystal-lang
<straight-shoota> I've made a shard for HTML sanitization: https://github.com/straight-shoota/sanitize
<straight-shoota> I think this is urgently needed to keep Crystal webapps safe
<straight-shoota> Any feedback is appreciated
<oprypin> straight-shoota, did u get some independent test suite for this
<straight-shoota> do you know any?
<oprypin> wait what's run_hrx_samples
renich has quit [Quit: renich]
<straight-shoota> I've extracted test into hrx files
<straight-shoota> So they're independent of the implementation
<oprypin> oh huh that's so weird https://github.com/google/hrx
<straight-shoota> Because that was the problem when reviewing other libraries' test suites. They're all tightly bound to the implementation
<straight-shoota> Yeah, HRX is a bit weird but better than inventing a new format
<straight-shoota> If you have a better idea for storing test cases as data, I'm listening =)
<oprypin> no no it's not bad in any way, just literally felt weird from finding it as "google/hrx"
Nekka_ has joined #crystal-lang
Nekka has quit [Ping timeout: 264 seconds]
Nekka_ is now known as Nekka