jhass changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.28.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
<FromGitter> <Blacksmoke16> `Time.utc(2019, 28, 4)` why is this in invalid time?
<FromGitter> <Blacksmoke16> nvm
<FromGitter> <Blacksmoke16> :S
<FromGitter> <dscottboggs_gitlab> :D
alex```1368 has joined #crystal-lang
alex```136 has quit [Ping timeout: 244 seconds]
rohitpaulk has joined #crystal-lang
lucasb has quit [Quit: Connection closed for inactivity]
return0e has joined #crystal-lang
laaron has quit [Remote host closed the connection]
return0e has quit []
<woodruffw> okey doke, opened #7725 to add `System::User` and `System::Group` -- @jaydorsey, this might interest you ;)
<DeBot> https://github.com/crystal-lang/crystal/pull/7725 ([WIP] Introduce System::User and System::Group)
return0e has joined #crystal-lang
laaron has joined #crystal-lang
laaron has quit [Remote host closed the connection]
<FromGitter> <tenebrousedge> wordruffw, how are you handling euid vs uid ?
rohitpaulk has quit [Ping timeout: 245 seconds]
<woodruffw> @tenebrousedge: `euid` vs `uid` are filesystem/`setuid` constructs, `System::User` and `System::Group` are just mapping the `passwd` and `group` structures returned by POSIX calls like `getgrnam_r` and `getpwnam_r`
<woodruffw> sorry, not filesystem, process (was thinking of `fsuid`)
<FromGitter> <tenebrousedge> so do you provide a mechanism for changing those? can I drop permissions on a process? can I execute a block with a different uid?
<woodruffw> not at the moment, no. previous attempts to add these to crystal (#5627 and #5615) stalled because they added too much API surface at once, my thought here was to start with the basics and then add process/filesystem interaction later
<DeBot> https://github.com/crystal-lang/crystal/pull/5627 (Adds System Users and Groups) | https://github.com/crystal-lang/crystal/pull/5615 (Adds System Users and Groups)
<woodruffw> IIRC, one of those previous PRs added `Process#owner=` and `Process#group=`, which is probably the kind of interface that'll be added in a future PR
rohitpaulk has joined #crystal-lang
<FromGitter> <tenebrousedge> Ruby provides a Process::UID.switch method that I've previously found convenient https://ruby-doc.org/core-2.6.1/Process/UID.html#method-c-switch
<woodruffw> neat, that would be nice to have
<FromGitter> <tenebrousedge> but, this was arguably doing something inherently stupid, and I'm not necessarily the most informed person about these matters, so don't take me too seriously
<woodruffw> switching the `uid` and `euid` is a bit unorthodox, but something like `Process.as_user(uid) { ... }` would be nice (and is a generalization of the above)
laaron has joined #crystal-lang
<FromGitter> <tenebrousedge> yeah, I was creating files under a user account while the overall process ran as root. I'm not sure how much of that code was eventually discarded. It would be nice to be able to do something similar in Crystal though
rohitpaulk has quit [Remote host closed the connection]
laaron has quit [Remote host closed the connection]
f1refly has quit [Ping timeout: 250 seconds]
laaron has joined #crystal-lang
f1refly has joined #crystal-lang
<FromGitter> <jaydorsey> @woodruffw thanks that would be a great feature
rohitpaulk has joined #crystal-lang
_whitelogger has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
alex```13685 has joined #crystal-lang
alex```1368 has quit [Ping timeout: 246 seconds]
waheedi has joined #crystal-lang
hightower2 has joined #crystal-lang
alex```13685 has quit [Ping timeout: 246 seconds]
alex```13685 has joined #crystal-lang
<FromGitter> <bararchy> How Can I do something like this: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5cc6bcb8a975f145e79634c6]
<FromGitter> <bararchy> I want to know if `a` type is in the alias or not
ashirase has quit [Ping timeout: 246 seconds]
<FromGitter> <c910335> ```a < BuildTypes::Core```
ashirase has joined #crystal-lang
<FromGitter> <j8r> `p BuildTypes::Core.is_a?(typeof(a))`?
<FromGitter> <j8r> `p a.is_a? BuildTypes::Core` won't do what we expect :/
alex```13685 has quit [Ping timeout: 246 seconds]
alex```13685 has joined #crystal-lang
<FromGitter> <bararchy> yeha :
<FromGitter> <bararchy> I wish I could use Enum members as types
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 250 seconds]
hightower2 has quit [Ping timeout: 244 seconds]
_whitelogger has joined #crystal-lang
waheedi has quit [Quit: waheedi]
<FromGitter> <Blacksmoke16> You can
<FromGitter> <Blacksmoke16> At least for this example
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6t0a
<FromGitter> <Blacksmoke16> @bararchy ^
<FromGitter> <bararchy> @Blacksmoke16 -> https://play.crystal-lang.org/#/r/6t0l
<FromGitter> <bararchy> It's still not a tpye though
<FromGitter> <bararchy> type*
<FromGitter> <Blacksmoke16> ah right
<FromGitter> <Blacksmoke16> could still do something like:
<FromGitter> <Blacksmoke16> ``` ⏎ def test(types : BuildTypes) ⏎ return unless types.any?``` [https://gitter.im/crystal-lang/crystal?at=5cc6ebc9a4ef0974711bd9f8]
<FromGitter> <Blacksmoke16> or raise or whatever, but yea. restricting a method to a specific enum value would be neat
<FromGitter> <bararchy> right? that would be so nice, I want to do method signitures based on enum members
<FromGitter> <bararchy> :)
<FromGitter> <Blacksmoke16> indeed
<FromGitter> <Blacksmoke16> if anyone has some any ideas...
waheedi has joined #crystal-lang
<FromGitter> <bararchy> why can't I do this? -> https://play.crystal-lang.org/#/r/6t14
<FromGitter> <Blacksmoke16> because your restirction is for an instance of bar and you're passing the type Bar
<FromGitter> <Blacksmoke16> would have to set the restriction to `Bar.class` which would allow you to pass `Bar`
<z64> that's probably helpful; i don't see why not. it shouldn't default to BigEndian though; the rest of IO defaults to System and it should probably be consistent
<z64> woops.. was scrolled back. @vladfaust
lucasb has joined #crystal-lang
<FromGitter> <bew> @bararchy https://carc.in/#/r/6t1a ? (based on your initial code)
<FromGitter> <bew> https://carc.in/#/r/6t1c (missed an include for Any)
<FromGitter> <bew> or a bit different, using abstract structs: https://carc.in/#/r/6t1e
<FromGitter> <bararchy> thanks @bew :)
<FromGitter> <bew> @bararchy for enum members as types, I like how rust does it
<FromGitter> <bew> and it's 'easy' to do in crystal too: https://gist.github.com/bew/38d8089cb5526f4e1f001e6e97db72e6
<FromGitter> <bararchy> Oh WOW
<FromGitter> <bew> 😜
<RX14> Since JSON::Serializable is a bit of a mess right now I've been thinking of perhaps tying automatic JSON deserialization to constructor named arguments instead of instance variables
<RX14> then probably introduce an auto_constructor macro to automatically create constructors for all ivars
<RX14> actually thinking about it some more that creates problems for metadata like converters :(
<RX14> so perhaps nevermind, although I think it would be neater if it could be made to work
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron has joined #crystal-lang
<FromGitter> <j8r> RX14 what do you think of https://gist.github.com/j8r/7d8395b1c37977ebcf568ea28cd08167
laaron has quit [Quit: ZNC 1.7.1 - https://znc.in]
laaron- has joined #crystal-lang
<RX14> isn't that just what we have now with different method names?
<FromGitter> <forkev_twitter> New to Crystal Syntax, and obviously missing something with XOR. I'm looking to zipper two byte arrays or strings together with xor. Any suggestions? https://play.crystal-lang.org/#/r/6t1h
<FromGitter> <tenebrousedge> `Enumerable#zip` is probably going to be useful
<FromGitter> <tenebrousedge> If you don't pass a block to `each_byte` you get a more useful result https://crystal-lang.org/api/0.28.0/String.html#each_byte-instance-method
<FromGitter> <tenebrousedge> So you could do e.g. `string.each_byte.map {|b| [b, b ^ 3] }`
<FromGitter> <j8r> not really RX14, this is a standard API which is format agnostic
<FromGitter> <j8r> and you can serialize any object out of the box
<FromGitter> <j8r> what problem do we want to solve? I thought it was avoiding to have to include modules for each format, that have their own annotations `JSON::Field`, `YAML::Field`, `Whatever::Field`
<FromGitter> <straight-shoota> RX14, I think we should look at Rust's serde for ideas
<RX14> meh, the rust people tend to overcomplicate
<FromGitter> <schoening> Does anyone know the name for the "import style" crystal is using? I mean where u just require and it gets the entire namespace, in opposition to something like for example TypeScript where you import alias from "location"
ua_ has quit [Ping timeout: 255 seconds]
<FromGitter> <r00ster91> @forkev_twitter I'm not sure you need `Atomic` for that. Can't you use the bitwise xor operator `^` for that?
ua_ has joined #crystal-lang
<FromGitter> <j8r> Whatever the technical solution, we should be able to serialize/deserialize any object out of the box
lucasb has quit [Quit: Connection closed for inactivity]
<FromGitter> <forkev_twitter> Very cool, thank you @tenebrousedge
<FromGitter> <forkev_twitter> @r00ster91 , i think so. i'm just not sure of the syntax, and what that would look like.
<FromGitter> <forkev_twitter> https://play.crystal-lang.org/#/r/6t2l does what I expect. Thank you, everyone.
alex```136855 has joined #crystal-lang
alex```13685 has quit [Ping timeout: 268 seconds]
rohitpaulk has joined #crystal-lang
rohitpaulk has quit [Remote host closed the connection]
hightower3 has joined #crystal-lang
ua_ has quit [Ping timeout: 250 seconds]
ua has joined #crystal-lang
waheedi has quit [Quit: waheedi]
waheedi has joined #crystal-lang
Yxhuvud has quit [Ping timeout: 264 seconds]
waheedi has quit [Quit: waheedi]
Yxhuvud has joined #crystal-lang
alex```1368555 has joined #crystal-lang
alex```136855 has quit [Ping timeout: 255 seconds]
<FromGitter> <Blacksmoke16> https://play.crystal-lang.org/#/r/6t5s :thinking:
<FromGitter> <Blacksmoke16> wait what
<FromGitter> <Blacksmoke16> im lost of what is going on
<FromGitter> <Blacksmoke16> *that* playground link fails, but if you copy paste it into a new one it doesnt?
<FromGitter> <straight-shoota> might be one of these weird non-deterministic errors
teardown has quit [Ping timeout: 255 seconds]
<FromGitter> <Blacksmoke16> adding `.inspect` to end of both seems to cause the error reliably
<FromGitter> <Blacksmoke16> defining an initializer in the parent struct seems to be a workaround as well. Will have to try when i get home and see if it fixes it in the real code
<FromGitter> <jwoertink> oh that's interesting. My app gets that Invalid memory error all the time, but since the app doesn't ever seem to be down, I've just always ignored it
hightower3 has quit [Ping timeout: 250 seconds]
_whitelogger has joined #crystal-lang