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
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
duane has quit [Ping timeout: 256 seconds]
duane has joined #crystal-lang
<FromGitter> <matthewmcgarvey> Is anyone familiar with this bug? https://play.crystal-lang.org/#/r/9jzk
<FromGitter> <Blacksmoke16> maybe some infinite recursion going on there?
<FromGitter> <Blacksmoke16> do you need generics in this context?
<FromGitter> <matthewmcgarvey> The bug is caused by the generics. The example does not represent what I am working with.
f1reflyylmao has joined #crystal-lang
<FromGitter> <Blacksmoke16> ah fair enough
<FromGitter> <matthewmcgarvey> I'm working on this class: https://github.com/luckyframework/lucky_router/blob/master/src/lucky_router/fragment.cr ⏎ trying to extract DynamicFragment as a class that inherits from Fragment but it causes the bug
f1refly has quit [Ping timeout: 256 seconds]
<FromGitter> <Blacksmoke16> https://github.com/crystal-lang/crystal/issues/6482 could prob add anothe way to reproduce to that
alexherbo20 has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 256 seconds]
alexherbo20 is now known as alexherbo2
alexherbo21 has joined #crystal-lang
alexherbo2 has quit [Read error: Connection reset by peer]
alexherbo21 is now known as alexherbo2
duane has quit [Ping timeout: 264 seconds]
duane has joined #crystal-lang
alexherbo2 has quit [Ping timeout: 256 seconds]
<FromGitter> <3n-k1> is there a way to have generic class variables? i tried what i thought was the obvious way and i'm getting a type error https://play.crystal-lang.org/#/r/9jzs
<FromGitter> <3n-k1> damn, there goes that plan lol. thanks!
deavmi has quit [Read error: Connection reset by peer]
deavmi_ has joined #crystal-lang
zorp has joined #crystal-lang
<jhass> acoolstraw: Sorry, didn't find time to look into it yet
alexherbo2 has joined #crystal-lang
r0bby has quit [Read error: Connection reset by peer]
r0bby has joined #crystal-lang
FromGitter has quit [Ping timeout: 244 seconds]
oprypin has quit [Ping timeout: 260 seconds]
oprypin has joined #crystal-lang
FromGitter has joined #crystal-lang
<FromGitter> <alexherbo2> yo
<FromGitter> <alexherbo2> how do you organize your code for cli tool?
<FromGitter> <alexherbo2> i'm not sure of the best approach
<FromGitter> <j8r> For your info, no need to have a subdirectory like that
<FromGitter> <j8r> just put everything in `/src`
<FromGitter> <j8r> then have a `cli.cr`, which is used to build the binary
<jhass> I tend to have an entry point like this https://github.com/jhass/acme_nsupdate/blob/master/bin/acme_nsupdate (ignore the $LOAD_PATH, that's because Ruby)
<jhass> also in your case I would probably go with a single binary and a subcommand structure
<FromGitter> <j8r> I was going to say that :)
<FromGitter> <j8r> also, when possible, avoid back references like `../../`. This is a simple to avoid circle dependencies. (likely won't in such little project)
<FromGitter> <j8r> Not a good deal in this little repo
<FromGitter> <alexherbo2> you would put all commands in a single file?
<FromGitter> <alexherbo2> can you show me?
<FromGitter> <alexherbo2> I felt I have to create independant file and binaries, because the commands where not related
<FromGitter> <alexherbo2> they do very different things
<jhass> https://github.com/jhass/carc.in/blob/master/src/sandbox.cr is an example (note it's old, with OptionParser's new subcommand support I would probably do it a bit different these days)
<FromGitter> <j8r> @alexherbo2 using that https://crystal-lang.org/api/master/OptionParser.html
<FromGitter> <j8r> but they are all related to passwords?
<FromGitter> <alexherbo2> yes
<FromGitter> <j8r> get one, edit one, create one... make sense to have a single binary, no?
<FromGitter> <j8r> sounds like `kubectl get`, `kubectl edit`, `kubectl create`
<FromGitter> <alexherbo2> the structure you suggest me is `src/password.cr` containing a module with the `create`, `edit`, etc. commands, and `src/password/cli.cr` used in shards.yml to build the binary?
<FromGitter> <j8r> you can have `src/cli.cr` or `src/password_cli.cr`
<FromGitter> <j8r> yes, for the binary
<FromGitter> <alexherbo2> `src/cli.cr` requiring `password.cr`?
<FromGitter> <j8r> yes
<FromGitter> <alexherbo2> but how do you implement `kubectl <command>`?
<FromGitter> <alexherbo2> a simple `case..when` is enough?
<FromGitter> <alexherbo2> it's for flags no?
<FromGitter> <j8r> also subcommands
<FromGitter> <alexherbo2> oO
<FromGitter> <alexherbo2> how lol
<FromGitter> <alexherbo2> omg
<FromGitter> <alexherbo2> is it new?
<FromGitter> <j8r> using `while arg = AGV.shift` with a case/when works also, just more boilerplate
<FromGitter> <alexherbo2> last time I checked the subcommands were not documented
<FromGitter> <j8r> it's there since a long time. Don't know for docs
<FromGitter> <alexherbo2> thanks for your kind advices
<FromGitter> <j8r> you're welcome @alexherbo2 :)
<FromGitter> <grkek> How does one reference STD lib modules
<FromGitter> <grkek> when you have defined
<FromGitter> <grkek> a module with the same name
<FromGitter> <grkek> and you have a nested module at the same time
<FromGitter> <Blacksmoke16> `::String`
<FromGitter> <grkek> not working
<FromGitter> <grkek> it redirects it for some reason
<FromGitter> <grkek> > ::Exception
<FromGitter> <grkek> that gets redirected to
<FromGitter> <grkek> > Grip::Core::Exception.new
<FromGitter> <grkek> this
<FromGitter> <Blacksmoke16> :thinking: it shouldnt
<FromGitter> <grkek> Ah I found it
<FromGitter> <grkek> thank you
<FromGitter> <Blacksmoke16> 👍
<FromGitter> <grkek> I was editing the wrong file :')
<FromGitter> <grkek> can I overload the raise/1 function?
<FromGitter> <Blacksmoke16> prob, but why would you want to do that?
<FromGitter> <grkek> I want a custom raise for the context of an http server
<FromGitter> <grkek> trying to make the error handling a bit better
<FromGitter> <grkek> "friendlier"
<FromGitter> <grkek> Each error code handler gets to be a controller with a case pattern matching for errors defined by users
<FromGitter> <grkek> so when you for example
<FromGitter> <grkek> `raise(context, MyProjectWeb::Exceptions::Blah.new("Something"), 400)`
<FromGitter> <grkek> do that
<FromGitter> <grkek> it raises the error
<FromGitter> <grkek> and sends it to the case pattern matcher
<FromGitter> <grkek> where you have a certain error view defined
<FromGitter> <grkek> for the current error
<FromGitter> <Blacksmoke16> could have the error code part of the exception class
<FromGitter> <grkek> that is too much pain
<FromGitter> <Blacksmoke16> if you say so
<FromGitter> <grkek> thank you anyways mate
<FromGitter> <grkek> ;)
<FromGitter> <grkek> https://ibb.co/r4RXdmw
<FromGitter> <grkek> an example of a controller which raises an error
<FromGitter> <Blacksmoke16> but if you have the error code as part of the exception couldnt you make use of overloading?
<FromGitter> <Blacksmoke16> given the exception class would define both of those `error` arguments
<FromGitter> <grkek> What do you mean?
<FromGitter> <Blacksmoke16> nvm, those are controller classes
<FromGitter> <grkek> yup
<FromGitter> <grkek> basically the error handlers are controllers
<FromGitter> <grkek> which can be extended to match over the error types
<FromGitter> <grkek> and provide rich responses to the api clients
<FromGitter> <grkek> case exception ⏎ when this ⏎ when that ⏎ end [https://gitter.im/crystal-lang/crystal?at=5f3a80d4ce98da26ecd1ee3e]
<FromGitter> <grkek> you know what I mean right?
<FromGitter> <Blacksmoke16> yup
<FromGitter> <Blacksmoke16> thats how i handled it at first as well
<FromGitter> <Blacksmoke16> i like the `alias` usage, i could get behind that pattern, maybe `private alias` instead, otherwise all those are going to be added to public docs/usable elsewhere
<FromGitter> <grkek> Yeah I know the alias is global
<FromGitter> <grkek> if defined outside
<FromGitter> <grkek> of the scope
<FromGitter> <grkek> it is a pretty neat thing
<FromGitter> <grkek> reminds me of the elixir alias
<FromGitter> <Blacksmoke16> thing i do for athena is define some short aliases on top level for common stuff
<FromGitter> <Blacksmoke16> `ART::Controller` versus `Athena::Routing::Controller`
<FromGitter> <grkek> right one looks explicit
<FromGitter> <grkek> its nice
<FromGitter> <Blacksmoke16> both work ofc, former is just shorter 😉
<FromGitter> <grkek> Your project is just a gold mine for those who wish to learn crystal
<FromGitter> <Blacksmoke16> doc wise you mean?
<FromGitter> <grkek> The annotations
<FromGitter> <grkek> are just mind boggling
<FromGitter> <j8r> I don't think it is a good start for those wanting to learn crystal, will be too complicated
<FromGitter> <j8r> Annotations and macros are advanced features
<FromGitter> <j8r> For those wanting to learn those and see what's possible, Athena is great indeed
<FromGitter> <grkek> > For those wanting to learn those and see what's possible, Athena is great indeed ⏎ ⏎ That is what I mean my friend
<FromGitter> <grkek> also I released a new version of grip
<FromGitter> <grkek> you should check it out
<FromGitter> <grkek> I stole the file and body parsers from kemal and implemented them as well :p
<FromGitter> <Blacksmoke16> its a good resource for whats possible with annotations, but prob not so good if you dont already have a basic understanding of macros/annotations
<FromGitter> <grkek> I still cant get my head around the annotations
<FromGitter> <grkek> and I hate them because I don't understand them
<FromGitter> <Blacksmoke16> the tl;dr is they are just like markers that store data that can be read at compile time via macros
<FromGitter> <grkek> That just sounds stupid
<FromGitter> <grkek> but useful
<FromGitter> <grkek> :D
<FromGitter> <grkek> That looks a lot nicer
<FromGitter> <Blacksmoke16> yes, would make things a lot easier to work with, since you dont need separate types that are essentially the same thing
<FromGitter> <grkek> Have you tried making anything in Grip?
<FromGitter> <Blacksmoke16> i havent even made anything in athena :D
<FromGitter> <grkek> Omega based
<FromGitter> <grkek> why not?
<FromGitter> <grkek> I really need to write tests for Grip
<FromGitter> <Blacksmoke16> one of those "i want to do project, but to do the project i want to be able to x, y, and z so i have to do those first"
<FromGitter> <Blacksmoke16> is how athena got started...
<FromGitter> <Blacksmoke16> now i have to get it to a point so that i can start the other project 😆
<FromGitter> <Blacksmoke16> yes, tests would be a great idea
<FromGitter> <grkek> that is how grip got started
<FromGitter> <grkek> as well
<FromGitter> <grkek> i hated kemals way of doing things
<FromGitter> <Blacksmoke16> the global namespace is 😢
<FromGitter> <grkek> i circumvented that
<FromGitter> <grkek> at somewhat extent
<FromGitter> <grkek> even if it had no global namespace
<FromGitter> <grkek> the routes are defined in the dsl
<FromGitter> <grkek> so basically each file will have its own route
<FromGitter> <grkek> and youll have to search for the routes
<FromGitter> <grkek> I must say the routing is pretty strong
<FromGitter> <grkek> that is why I chose it
<FromGitter> <grkek> Grip is next to the h2o.cr
<FromGitter> <grkek> on the tech empower
<FromGitter> <grkek> basically taking the 2nd place
<FromGitter> <grkek> in speed
<FromGitter> <Blacksmoke16> speed isnt everything, also should consider testability and maintainability
<FromGitter> <Blacksmoke16> i.e. how would someone go about testing their controllers etc
<FromGitter> <grkek> testing is done by spec grip
<FromGitter> <Blacksmoke16> well there you go
<FromGitter> <grkek> and maintainability is really nice since the structure is great
<FromGitter> <wyhaines> "i havent even made anything in athena :D" ⏎ ⏎ Shhhh. Don't say that too loudly, since I am chest deep in implementing something with it.
<FromGitter> <grkek> depends on how you design it
<FromGitter> <grkek> What do you think making the cookiecutter template was a mistake or nah?
<FromGitter> <dscottboggs_gitlab> I finally tried athena recently. very sold
<FromGitter> <Blacksmoke16> an actual app that explains what the structure/things are would prob be better
<FromGitter> <grkek> > an actual app that explains what the structure/things are would prob be better ⏎ ⏎ I already have that :p
<FromGitter> <grkek> here u go
<FromGitter> <grkek> I need to update it
<FromGitter> <grkek> but yeah it has the 0.26.8 version I think
<FromGitter> <Blacksmoke16> 😬
<FromGitter> <dscottboggs_gitlab> @grkek I'd put up a live demo of it
<FromGitter> <grkek> there is a live demo of a web-chat
<FromGitter> <grkek> based on websockets :p
<FromGitter> <dscottboggs_gitlab> nice
<FromGitter> <grkek> The name is weird but yeah just a random generator name
<FromGitter> <grkek> http://gore-chat.herokuapp.com/
<FromGitter> <grkek> here
<FromGitter> <dscottboggs_gitlab> "gore chat" 😬
<FromGitter> <grkek> Sorry :p
<FromGitter> <Blacksmoke16> :feelsgood:
<FromGitter> <grkek> is that the doom guy
<FromGitter> <Blacksmoke16> yup :P
<FromGitter> <grkek> nice I love doom
<FromGitter> <dscottboggs_gitlab> you should use a `<textarea />` instead of `<input type=text />`
<FromGitter> <dscottboggs_gitlab> my previous messages were being offered to me as auto-fill options
<FromGitter> <Blacksmoke16> you can disable that
<FromGitter> <Blacksmoke16> `autocomplete="off"`
<FromGitter> <dscottboggs_gitlab> yes, but a textarea is more appropriate anyway for a chat
<FromGitter> <Blacksmoke16> for sure
<FromGitter> <grkek> I am horrible at frontend
<FromGitter> <grkek> I hate it to death
<FromGitter> <dscottboggs_gitlab> meh. once I found Bulma I got pretty good
<FromGitter> <dscottboggs_gitlab> CSS is a bitch
<FromGitter> <grkek> that is
<FromGitter> <grkek> why I hate
<FromGitter> <grkek> frontend
<FromGitter> <dscottboggs_gitlab> flexbox makes it a lot better TBH, but I still never want to hand-code CSS ever again
<FromGitter> <grkek> :DDDD
<FromGitter> <grkek> nice
<FromGitter> <grkek> I am happy I am not the only one with PTSD from css
* FromGitter * wyhaines is on week 2 of writing almost exclusively React & CSS.
f1refly has joined #crystal-lang
f1reflyylmao has quit [Ping timeout: 256 seconds]
f1refly has quit [Ping timeout: 260 seconds]
f1refly has joined #crystal-lang
sagax has quit [Ping timeout: 240 seconds]
<oprypin> dang it my plans are foiled
<oprypin> i was pretty excited to make super integrated bindings but it doesnt always work
<oprypin> sure, if i create ImGuiIO as a single object, i can afford to write 4 extra bytes before the start of its memory region
<oprypin> so i'd just be overwriting previous fields
<FromGitter> <alexherbo2> is there a shortcut to `.map` and `.select`?
<FromGitter> <Blacksmoke16> suppose you could do `.compact_map` and use `nil` on things that dont meet your criteria
<FromGitter> <alexherbo2> I want `.select(keys)` returning the result
<FromGitter> <alexherbo2> hm
<FromGitter> <alexherbo2> actually I need to merge the values into a single hash
<FromGitter> <Blacksmoke16> `.each_with_object`?
<FromGitter> <Blacksmoke16> and just dont set anything for ones you want to skip
<FromGitter> <alexherbo2> I have a Hash(String, Hash(String, MyObject))
<FromGitter> <alexherbo2> `snippets[scope_name][snippet_name] # Snippet object`
<FromGitter> <alexherbo2> what is the purpose of `.each.with_object` btw?
<FromGitter> <alexherbo2> I see the interest for `.map.with_index` but not for `with_object`
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/master/Enumerable.html#each_with_object(obj,&)-instance-method
sagax has joined #crystal-lang
<FromGitter> <alexherbo2> does it make sense to specify a method on an alias?
<FromGitter> <alexherbo2> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5f3ad4b087848e2119f078f4]
<FromGitter> <alexherbo2> I want to implement a search for each
<FromGitter> <alexherbo2> the use case is from the command-line, chain the search
<FromGitter> <alexherbo2> `snippets build /path/to/snippets`
<FromGitter> <alexherbo2> with the result
<FromGitter> <alexherbo2> `data | snippets scope ruby ruby/rails/routes | snippets get def`
<FromGitter> <Blacksmoke16> :shrug: i still dont really know what you're doing so i dont have any opinions
<FromGitter> <alexherbo2> XD
<FromGitter> <alexherbo2> with my structures, I want to add `Snippets.scope`, and `Scopes.get`
<FromGitter> <alexherbo2> is that possible with aliases?
<FromGitter> <Blacksmoke16> no
<FromGitter> <Blacksmoke16> aliases are just shortcuts to types, they dont actually exist
<FromGitter> <Blacksmoke16> could have another struct or something to wrap your hashes and expose the data via your custom getter methods
<FromGitter> <alexherbo2> I have to implement real struct then, and make the structs responds to json
<FromGitter> <alexherbo2> ?
<FromGitter> <Blacksmoke16> probably?
zorp has quit [Ping timeout: 256 seconds]
<FromGitter> <jwoertink> Anyone know if there's a way to point to a shard that's not at the root of a git repo?
<jhass> I don't think it's supported, short of adding the repo as a git subtree or submodule and using a path dependency
<FromGitter> <jwoertink> Ok. I'll open an issue about it. Thanks!
<jhass> which of course doesn't work for transitive dependencies
<FromGitter> <Blacksmoke16> @jwoertink https://github.com/crystal-lang/shards/pull/238
<FromGitter> <jwoertink> Interesting. Not quite what I'm looking to do, but that's also good to know
<FromGitter> <jwoertink> Well, I guess it's the same concept, just for a different thing
<deimos_> has anyone ported ruby's sequel gem to crystal? or something like it?
<deimos_> i found clear, but that seems more like ActiveRecord in Ruby
<deimos_> i wonder if i could get budget to fund someone to port it
<deimos_> hmm
<FromGitter> <alexherbo2> is there a shorcut to partition `items, last` of an array?
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <alexherbo2> `partition` + `with_index` or `dup` + `pop` or `[0..-2], [-1]`
<FromGitter> <alexherbo2> I need something like `head, *tail = list`
<FromGitter> <alexherbo2> but in the other sense :p
<FromGitter> <alexherbo2> pop could be ok as I'm working on argv
<FromGitter> <Blacksmoke16> pop would be the way to go, as the array value would inherently be the rest of the elements
alexherbo2 has quit [Ping timeout: 240 seconds]