RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.27.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> @straight-shoota The config file isn't editable via code so having it be compiled once to allow for the ECR rendering is fine. I'm also using it for extending the `HTTP::Handler`, like: ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ so that each handler has access to the context, the action (if one was matched) and the config object that gets read and passed in at run time
<FromGitter> <Blacksmoke16> but yea i suppose it limits the useability of the config file outside of this, but :shrug:
<FromGitter> <Blacksmoke16> would be diff it was writable, prob not a big deal
<FromGitter> <johnjansen> its very normal to interpolate env variables into config files, and infact ideal in many cases. here is a common use case in ruby on rails (in this case Gitlab CI) - rails uses yaml extensively for config so there are tons of good examples of this kind of config modification in the ruby world ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c9580ca8126720abc29b59a]
<FromGitter> <johnjansen> and another example from AWS ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c958132a21ce51a20a64eaf]
<FromGitter> <johnjansen> like i said, all very normal and correct
<FromGitter> <Blacksmoke16> yea, is where i got the idea
<FromGitter> <johnjansen> so its a totally valid idea, go with it!
<FromGitter> <johnjansen> especially if you want to commit the config file to a repo and dont want to include credentials
<FromGitter> <johnjansen> obviously that would be bad …
<FromGitter> <Blacksmoke16> indeed
<FromGitter> <Blacksmoke16> also wanted to have something like env specific config files that can inherit from a base
<FromGitter> <Blacksmoke16> but prob leave that for future iteration
<FromGitter> <johnjansen> take a look at rails database.yml
<FromGitter> <Blacksmoke16> why delete?
<FromGitter> <Blacksmoke16> im just not a fan of that syntax, works fine for that one file, but would get messy if each env was in one file
<FromGitter> <johnjansen> have a look at this https://learnxinyminutes.com/docs/yaml/
<FromGitter> <johnjansen> under EXTRA YAML FEATURES / anchors
<FromGitter> <Blacksmoke16> hmm
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6jy2 neat
<FromGitter> <johnjansen> yep
<FromGitter> <Blacksmoke16> good call :P
<FromGitter> <Blacksmoke16> i was about to make some like `merge` method to handle this ha
<FromGitter> <johnjansen> dont reinvent the wheel
<FromGitter> <johnjansen> you may want to use https://github.com/straight-shoota/crinja rather than ecr though
<FromGitter> <Blacksmoke16> maybe, in its early stages atm
<FromGitter> <johnjansen> maybe
<FromGitter> <Blacksmoke16> @girng `the more I need to focus and have that confidence of writing good code. Why? Because this will allow me to write more instead of writing 1 line, then “compile and test”.` would help if you wrote tests :trollface:
<FromGitter> <girng> Yeah, that too. I used to stop after 1 line and compile and test, just for the sole reason to make sure the code is legit and I get no compiler errors. Now, not so much. Because a) I know subconsciously about the compile time. and b) That line will work because I've used it before, and understand the language better
<FromGitter> <girng> Compile times have made me into a better programmer with Crystal
_whitelogger has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e_ has joined #crystal-lang
<FromGitter> <Blacksmoke16> dont think there is a way to generate those default tags tho?
<FromGitter> <Blacksmoke16> could just use custom to_yaml, wouldnt be that bad for my use case
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6jye oh nice
<FromGitter> <Blacksmoke16> 💯
chemist69 has quit [Ping timeout: 252 seconds]
chemist69 has joined #crystal-lang
Kixune has joined #crystal-lang
Kixune has quit [Ping timeout: 255 seconds]
Kixune has joined #crystal-lang
Kixune has quit [Client Quit]
return0e_ has quit [Ping timeout: 255 seconds]
return0e has joined #crystal-lang
Kixune has joined #crystal-lang
Yxhuvud has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
Kixune has quit [Quit: Kixune]
laaron has quit [Remote host closed the connection]
laaron has joined #crystal-lang
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron- has joined #crystal-lang
_whitelogger has joined #crystal-lang
_whitelogger has joined #crystal-lang
return0e has quit [Read error: Connection reset by peer]
return0e_ has joined #crystal-lang
<FromGitter> <straight-shoota> @johnjansen @Blacksmoke16 Crinja would really work for this, but it's also a bit heavy for a simple task like inserting a few environment variables, which could probably be implemented similar to `yaml_source.gsub('<%= ENV_VAR %>', ENV['ENV_VAR'])`
ashirase has quit [Ping timeout: 252 seconds]
laaron- has quit [Remote host closed the connection]
laaron has joined #crystal-lang
ashirase has joined #crystal-lang
_whitelogger has joined #crystal-lang
DTZUZO has quit [Ping timeout: 246 seconds]
<Groogy> Morning! O/
_whitelogger has joined #crystal-lang
Yxhuvud has joined #crystal-lang
<FromGitter> <TheOnlyArtz> Hey!
<FromGitter> <TheOnlyArtz> How can I access an object in an Array by itself?
<FromGitter> <TheOnlyArtz> Let's say I've got an object ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c960d9c52c7a91455e0df02]
<FromGitter> <TheOnlyArtz> I thought it would work just like delete ⏎ ⏎ ```array.delete(client) #=> works ⏎ array[client] => doesn't work``` [https://gitter.im/crystal-lang/crystal?at=5c960db7d0133e21e5fff2dd]
BaldEagleX02 has joined #crystal-lang
<Yxhuvud> What do you expect as output of array[client] ?
<FromGitter> <TheOnlyArtz> To get the client
<Yxhuvud> But you obviously already have the client?
<FromGitter> <TheOnlyArtz> No, I have an array of clients (custom objects) who all have the properties of `tcp` which includes their own `tcp connection`
<FromGitter> <TheOnlyArtz> I need to find the client who has the specific `tcp` connection
<Yxhuvud> something like array.find {|client| client.connection == something } ?
<FromGitter> <TheOnlyArtz> Basically I'm working with packets here and every tcp connection gets it's own object ⏎ Whenever a player moves (It's a gameserver) I will need to fetch that specific tcp connection from the clients array ⏎ and update his position
<FromGitter> <TheOnlyArtz> But that will cause an error at compilation time, trying to access certain properties of `CustomObject | Nil`
<Groogy> then that means you have the union type of CustomObject | Nil in the array so you have to first check that the object you testing against is not nil
<FromGitter> <TheOnlyArtz> It's for sure won't be Nil but Crystal assumes that since it's a `find` method and it can cause Nil in certain cases
<FromGitter> <TheOnlyArtz> like `[1].find {|o| o == 2}` => nil
<FromGitter> <TheOnlyArtz> Oh so basically ⏎ `if desired_player = clients_arr.find {|o| o.tcp == client} ... end`
<FromGitter> <TheOnlyArtz> Well yea that fixed it
<FromGitter> <TheOnlyArtz> What can cause a broken pipe to occur when using TCPSockets?
<FromGitter> <straight-shoota> When the connection closes, `#accept` will return nil
<FromGitter> <straight-shoota> Oh sry, you're talking about an established client connection
<FromGitter> <straight-shoota> Well then, any read or write to that socket will fail
<FromGitter> <TheOnlyArtz> Which causes a broken pipe
<FromGitter> <TheOnlyArtz> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c9615d452c7a91455e111d2]
<FromGitter> <straight-shoota> ```rescue ex : Errno ⏎ if ex.errno == Errno::ECONNRESET``` [https://gitter.im/crystal-lang/crystal?at=5c96163af3dbbd230ca3339c]
<FromGitter> <TheOnlyArtz> Perfect, thank you very much
azuri5 has joined #crystal-lang
_whitelogger has joined #crystal-lang
azuri5 has quit [Ping timeout: 250 seconds]
<FromGitter> <TheOnlyArtz> My net code works really great! this is a proof of concept ^
<FromGitter> <TheOnlyArtz> https://github.com/amit-gguurr-gamedev/Server This is the source (Crystal does an amazing job)
<FromGitter> <bew> @TheOnlyArtz what's this https://github.com/amit-gguurr-gamedev/Server/blob/master/src/server/classes/entity.cr#L6 Oo `@id = id` what is `id` ?? (and at the end you set `@id = 0`..
<FromGitter> <TheOnlyArtz> Oh yea my bad
<FromGitter> <TheOnlyArtz> Thank you for that
<FromGitter> <TheOnlyArtz> Eventually Entities will have IDs too, right now we are using the ID's for the Player where there we generate a random UInt32 number
<FromGitter> <bew> That method could be written (if you change initialize to `def initialize(@tcp : TCPSocket, @id); ...`: ⏎ ⏎ ```player_id = Random.new.rand(1e7).to_u32 ⏎ new(socket, player_id)``` [https://gitter.im/crystal-lang/crystal?at=5c96365af3dbbd230ca40198]
lucasb has joined #crystal-lang
<FromGitter> <TheOnlyArtz> I guess it's possible
<FromGitter> <TheOnlyArtz> I will look into it layer
<FromGitter> <TheOnlyArtz> How's everything else looking though? @bew
edcragg has quit [Quit: ZNC - http://znc.in]
moei has joined #crystal-lang
DTZUZO has joined #crystal-lang
crystal-lang564 has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> is there any way to query all system users in crystal besides parsing `/etc/passwd` and `/etc/shadow`?
<FromGitter> <j8r> a system call?
<FromGitter> <dscottboggs_gitlab> yes I was just about to look for the answer for C and just use that from crystal
<FromGitter> <j8r> don't known, not sure, but I created https://github.com/j8r/libcrown
<FromGitter> <j8r> We have to parse it to modify it anyway
<FromGitter> <dscottboggs_gitlab> oh cool that's great :D
<FromGitter> <j8r> I was a bit afraid to use it at first, system users are sensitive. I had no problem with it so far on my systems
<FromGitter> <dscottboggs_gitlab> There's no `User#groups` :/ but I can work with it
<FromGitter> <j8r> what do you want? Alls groups?
<FromGitter> <j8r> of an user?
<FromGitter> <j8r> yes, this doesn't work like that. Groups have users, not the other way around
<FromGitter> <j8r> I can create an helper method for this
<FromGitter> <j8r> I have to make a new release anyway, to close the Files IO
<FromGitter> <dscottboggs_gitlab> it's ok I already got it set up like I wanted, but I'm confused, why does `User#password` return a `PasswordState` instead of a `Password`?
<FromGitter> <dscottboggs_gitlab> WAIT do we have algebraic enums like Rust??
<FromGitter> <dscottboggs_gitlab> *Sweet*
<FromGitter> <dscottboggs_gitlab> yeah no I'm confused
<FromGitter> <dscottboggs_gitlab> never mind I see... there is `Libcrown#passwords` or `#get_password` for that. A very functional way to do it but ok
<FromGitter> <j8r> I've wanted to stay as close as possible to the actual API provided by the files
crystal-lang564 has quit [Quit: Konversation terminated!]
f1refly has joined #crystal-lang
<f1refly> Is there a way to sort a hash by its values?
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6k29 i suppose something like that would work
<FromGitter> <Blacksmoke16> not sure i would rely on a hash to maintain order tho
<f1refly> Hmm yes, that should work i think
<f1refly> Thank you :)
<FromGitter> <Blacksmoke16> what are you trying to do?
<f1refly> Creating a word counter that also sorts the words by occurances after its done
<f1refly> I thought the best approach to that is by creating a hash(String, Int32) and sorting it for the output
Kixune has joined #crystal-lang
flaviodesousa has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> ever seen something like this before? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c9690a8f3dbbd230ca668e2]
<FromGitter> <wontruefree> if you are in the Chicago area we are launching a meetup and would like to see people in the crystal community there
pabs has quit [Ping timeout: 245 seconds]
<FromGitter> <r00ster91> @dscottboggs_gitlab the bug is fixed in master. It's because you required a file that does not exist
<FromGitter> <dscottboggs_gitlab> hm, ok thank you
Kixune has quit [Quit: Kixune]
sz0 has joined #crystal-lang
<FromGitter> <dscottboggs_gitlab> still can't figure out what I'm forgetting to require https://github.com/DFabric/dppm-rest-api
<FromGitter> <Blacksmoke16> whats the error?
_whitelogger has joined #crystal-lang
<FromGitter> <Blacksmoke16> @johnjansen thanks again for that yaml tip
<FromGitter> <Blacksmoke16> made this *much* easier :P
<FromGitter> <Blacksmoke16> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c96b73052c7a91455e52999]
<FromGitter> <dscottboggs_gitlab> ☝️ March 23, 2019 4:01 PM (https://gitter.im/crystal-lang/crystal?at=5c9690a8f3dbbd230ca668e2) @Blacksmoke16
<FromGitter> <Blacksmoke16> hm
moei has quit [Quit: Leaving...]
<FromGitter> <Blacksmoke16> strange
<FromGitter> <Blacksmoke16> `require "libcrown"` prob has something to do with this?
<FromGitter> <Blacksmoke16> `Caused by: can't find file 'libcrown'`\
<FromGitter> <Blacksmoke16> @dscottboggs_gitlab
<FromGitter> <dscottboggs_gitlab> that was it
<FromGitter> <dscottboggs_gitlab> how did you get that `Caused by:` output?
<FromGitter> <Blacksmoke16> is what came up when i ran `crystal spec`
<FromGitter> <dscottboggs_gitlab> weird I got that totally different thing above
<FromGitter> <Blacksmoke16> https://paste.ee/p/4Kadb
<FromGitter> <Blacksmoke16> is what i get
<FromGitter> <dscottboggs_gitlab> oh I didn't get that because I had installed libcrown. I bet the issue was in libcrown
<FromGitter> <dscottboggs_gitlab> oh but @j8r said he uses it all the time without issue so idk
<FromGitter> <Blacksmoke16> :shrug:
<FromGitter> <Blacksmoke16> its not in your shard.yml
<FromGitter> <dscottboggs_gitlab> yeah, and also not required since we decided against associating users with system users
<FromGitter> <Blacksmoke16> fair enough