RX14 changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.25.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
akaiiro has quit [Ping timeout: 260 seconds]
zachk has quit [Quit: Leaving]
<crystal-gh> [crystal] chris-huxtable reopened pull request #5627: Adds System Users and Groups (master...users-groups) https://git.io/vNVfn
wontruefree has joined #crystal-lang
duane has quit [Ping timeout: 264 seconds]
<woodruffw> is there an idiomatic way to handle envelopes with `JSON.mapping`? i.e., if i have an API that wraps every response, what's the right way to declare a mapping that only returns the relevant inner data?
<FromGitter> <Blacksmoke16> i.e. ignore certain fields from `to_json`?
<woodruffw> well, the problem is that i can't quite ignore them -- the envelope includes a TTL field, which i need to check against for staleness
<FromGitter> <Blacksmoke16> no i mean still consume the value into the object when using .from_json but ignore the field when outputting the object using .to_json
<FromGitter> <Blacksmoke16> or do i not follow what you are asking?
<woodruffw> yeah, i think you're solving a different problem. i'm not emitting any JSON, i just want to strip away some of the layers of this object before handing it to the user
<FromGitter> <Blacksmoke16> do you have an example?
<woodruffw> e.g., `object.data.things.first` should just become `object.things.first`
<FromGitter> <Blacksmoke16> ah
<woodruffw> i might be explaining myself poorly
<FromGitter> <Blacksmoke16> and how are you returning it to the user? just like return object.things.first?
<woodruffw> yup, ideally
<FromGitter> <Blacksmoke16> could you define a method that news up a new object based on params in main object and returns the other object with what you want to return?
<woodruffw> yeah, i'm trying something like that now
<woodruffw> it feels a little unidiomatic, but i guess it'll work
<FromGitter> <Blacksmoke16> not sure you have a choice since you dont want to return the whole thing
<woodruffw> mhm
<FromGitter> <Blacksmoke16> if you returned JSON there is some neat things you could do
<FromGitter> <Blacksmoke16> but would be same concept, defining a custom deserialization
<woodruffw> i'll give this approach a shot and report back ;)
<woodruffw> maybe it'll end up being cleaner than i think
<FromGitter> <Blacksmoke16> 👍
duane has joined #crystal-lang
duane has quit [Ping timeout: 260 seconds]
<wontruefree> is there an `ri` for crystal?
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 240 seconds]
<FromGitter> <Blacksmoke16> ri?
moei has quit [Quit: Leaving...]
<wontruefree> the ruby commandline doc
<wontruefree> ri File
<wontruefree> something like thiat
<wontruefree> that*
<FromGitter> <Blacksmoke16> ah not that i know of
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/0.25.1/ would be your best bt
<wontruefree> yeah I was hoping to have something more local to my machine
<wontruefree> there is an html dir you can create
<wontruefree> but I was hoping there was something not as dependent on the browser
<FromGitter> <mtn> Hey -- just trying out crystal and I have a few (probably very straightforward) questions
<FromGitter> <mtn> I have a integer array, Array(Int32), and I want to read a character from stdin, cast it to an integer, and set a value to be it in the array. However, the type of the result of reading from stdin is Char | Nil.
<FromGitter> <mtn> I thought to put it in a begin/rescue block, and call`.to_i` on `STDIN.raw &.read_char`, but we can't call `.to_i` on nil of course, so that fails at compile time
<FromGitter> <mtn> What's the straightforward way to do what I'm attempting
<FromGitter> <mtn> I also see that `not_nil` is a thing -- not sure if that's appropriate
<FromGitter> <mtn> (fwiw, I used `not_nil` and compiled my first program -- a brainfuck interpreter!) but definitely interested in potentially better ways of doing things
moei has joined #crystal-lang
akaiiro has joined #crystal-lang
<FromGitter> <Timbus> You can use `.is_a` and/or `.nil?` on a variable to ensure a type is not nil.
snsei has quit [Ping timeout: 256 seconds]
<FromGitter> <Timbus> You can also use `.try` in a lot of scenarios where you're okay with the final result still being potentially nil, eg: `result = STDIN.raw &.read_char.try &.to_i` (`result` is now an `Int | Nil`)
snsei has joined #crystal-lang
akaiiro has quit [Remote host closed the connection]
<FromGitter> <Timbus> ah.. and of course there's just the classic `if result`. Only `false` or `nil` will fail that check. hope that helps @mtn
early has quit [Quit: Leaving]
early has joined #crystal-lang
wontruefree has quit [Quit: bye]
khubo has joined #crystal-lang
<FromGitter> <mjago> wontruefree: run crystal docs in a local crystal source directory and you have local crystal api docs (localhost)
<FromGitter> <mjago> ah you don't want browser
<FromGitter> <talbergs> I just saw a talk from 2017february there is said that until 1.0 windows support and paralellism is needed. Same as today. Im curious what sidetracked the team? Or does it really takes so much time, or we miss more coders?
<FromGitter> <talbergs> If sidetracked, what is gained
<FromGitter> <mjago> @talbergs a big backer with deep pockets would surely help 😏
mindcrimes has joined #crystal-lang
<mindcrimes> hi, im trying to make a hash with String and Functions
<mindcrimes> is that possible?
<FromGitter> <rishavs> Need some advice on implementing dyamic routes in my simple case-when based router. ⏎ ⏎ ``` case path ⏎ when {"/about/", "GET"}``` ⏎ ⏎ Does the case-when support regex or pattern matching? [https://gitter.im/crystal-lang/crystal?at=5b406e2be534eb69a5cf6d9b]
<FromGitter> <mjago> mindcrimes: You can do this, if this is what you mean? https://play.crystal-lang.org/#/r/4grm
<mindcrimes> yes
<FromGitter> <rishavs> > *<mindcrimes>* hi, im trying to make a hash with String and Functions ⏎ ⏎ Isn't that just a class? Maybe classes would be better here
* mindcrimes shrugs
<mindcrimes> was trying to think of a way to handle events and thats the first thing that came to mind
<mindcrimes> idk if classes would work well
<FromGitter> <mjago> I guess it depends on your usecase. I use that technique in a state-machine with a Hash(Enum, Proc(String)) within a class which works for me
<FromGitter> <mjago> But there may be better ways 😄
<mindcrimes> ah
_whitelogger has joined #crystal-lang
<FromGitter> <kolyaio> Do you know any library in cr that deals with dates ?
<FromGitter> <kolyaio> Date format
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 264 seconds]
Raimondii is now known as Raimondi
alex`` has joined #crystal-lang
alex`` has quit [Ping timeout: 256 seconds]
alex`` has joined #crystal-lang
alex`` has quit [Ping timeout: 264 seconds]
alex`` has joined #crystal-lang
alex`` has quit [Ping timeout: 256 seconds]
alex`` has joined #crystal-lang
<FromGitter> <decal> 0plll
<crystal-gh> [crystal] sdogruyol closed pull request #6347: Error if using `return` inside a constant's value (master...bug/5391-return-from-constant) https://git.io/fNeAi
<FromGitter> <asterite> woodruffw just define class Wrapper(T), see for example
<woodruffw> @asterite: that's what i ended up doing :)
<FromGitter> <asterite> Ah, cool :-)
<FromGitter> <asterite> Ah, and it can be a struct, I don't know why I used a class in my code (I'll change it later)
<woodruffw> oh, that's cool! i'll see if i can work that into mine
<travis-ci> crystal-lang/crystal#fa8a586 (master - Error if using `return` inside a constant's value (#6347)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/401202930
<DeBot> https://github.com/crystal-lang/crystal/pull/6347 (Error if using `return` inside a constant's value)
TCZ has joined #crystal-lang
andre144k has joined #crystal-lang
andre144k has left #crystal-lang ["Leaving"]
sz0 has joined #crystal-lang
TCZ has quit [Quit: Leaving]
alex`` has quit [Ping timeout: 255 seconds]
<FromGitter> <asterite> Oh, thre's also `Type.from_json(string_or_io, root)`: https://github.com/crystal-lang/crystal/blob/master/src/json/from_json.cr#L24
alex`` has joined #crystal-lang
DTZUZO has quit [Read error: Connection reset by peer]
<FromGitter> <fridgerator> this is kind of cool : https://akr.am/languages/
snsei has quit [Ping timeout: 255 seconds]
<crystal-gh> [crystal] chris-huxtable opened pull request #6350: Switches Darwin to arc4Random (master...darwin-arc4random) https://git.io/fNv8l
snsei has joined #crystal-lang
alex`` has quit [Ping timeout: 268 seconds]
alex`` has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
olbat has quit [Ping timeout: 264 seconds]
olbat has joined #crystal-lang
olbat has joined #crystal-lang
olbat has quit [Changing host]
alex`` has quit [Ping timeout: 260 seconds]
alex`` has joined #crystal-lang
<rocx> is there anything involving reading formatted input like c's scanf()?
<rocx> then again, maybe if the data is stricly line-oriented, maybe IO#each_line would be a better idea and check what the first token is.
zachk has joined #crystal-lang
zachk has joined #crystal-lang
<crystal-gh> [crystal] asterite opened pull request #6351: Revert: Don't automatically virtualize two types in the same hierarchy, unless one is deeper than the other (master...feature/revert-dont-virtualize) https://git.io/fNvEs
<FromGitter> <fridgerator> whose going to bind these ? http://kripken.github.io/emscripten-site/docs/api_reference/index.html
<FromGitter> <fridgerator> though I think those are just header files, I dont see any libs
<FromGitter> <fridgerator> so nvmd
wontruefree has joined #crystal-lang
duane has joined #crystal-lang
jcs has left #crystal-lang [#crystal-lang]
<wontruefree> when I try to use HTTP::Client on some urls it fails but I can curl them and they are fine
<wontruefree> so HTTP::Client.get("https://www.facebook.com") fails with #=> Unhandled exception: Invalid encoding: "utf-8" (ArgumentError)
<wontruefree> am I doing something wrong?
<FromGitter> <asterite> it's a bug, the content-type header is `text/html; charset="utf-8"` and crystal chokes on it... I didn't know quotes were allowed there
<FromGitter> <asterite> Submitted: https://github.com/crystal-lang/crystal/issues/6353
<FromGitter> <asterite> I'll fix it now
<crystal-gh> [crystal] asterite opened pull request #6354: HTTP: consider quoted charset (master...bug/6353-quoted-charset) https://git.io/fNv20
<wontruefree> thanks
<wontruefree> I tried to add accpet with `text/html; charset="utf-8"` but I must of had it wrong
<wontruefree> oh interesting
<FromGitter> <asterite> You can maybe patch your program with that change, in the meantime... or patch `IO#set_encoding` to remove the quotes :-P
<wontruefree> I might just have crystal build from HEAD
<wontruefree> have not figured it out yet
<livcd> Are crystal apps behaving correctly in docker containers ? I remember there was an issue with a huge performance hit for crystal binaries
<wontruefree> but crystal HEAD seems to be fixing things I run into anyways
<wontruefree> what behavior are you seeing ?
<wontruefree> I have some apps I have given to people in docker containers and have not hear anything about them
<wontruefree> but I dont know if they are really using them
<livcd> I remember reading about crystal apps being very slow in docker
<crystal-gh> [crystal] asterite opened pull request #6355: Encoding: compare with case insensitive UTF-8 to avoid using iconv when not necessary (master...feature/dont-use-iconv-for-case-insensitive-utf8) https://git.io/fNv2P
<wontruefree> I mean maybe it was the docker config
<wontruefree> I dont know
wontruefree has quit [Quit: bye]
<crystal-gh> [crystal] RX14 closed pull request #6343: Remove leftover debug messages in raise.cr (master...doc/remove-leftover-messages) https://git.io/fNe8P
wontruefree has joined #crystal-lang
wontruefree has quit [Quit: bye]
TCZ has joined #crystal-lang
<FromGitter> <Timbus> livcd: I have a half dozen or so crystal services running in kubernetes and none of them seem to have any performance issues regarding docker, to my knowledge.
wontruefree has joined #crystal-lang
wontruefree has quit [Client Quit]
<FromGitter> <Timbus> I also can't see how crystal would run slower compared to any other language in a container.. Only issue I had was crystal handles signals strangely as the PID1 process, so now I use dumb-init to start the crystal apps
<crystal-gh> [crystal] RX14 closed pull request #6346: Fix: incorrect debug info for closured self (master...bug/6195-incorrect-debug-info) https://git.io/fNeAv
wontruefree has joined #crystal-lang
TCZ has quit [Quit: Leaving]
<travis-ci> crystal-lang/crystal#e1b750f (master - Fix: incorrect debug info for closured self (#6346)): The build passed. https://travis-ci.org/crystal-lang/crystal/builds/401323174
<DeBot> https://github.com/crystal-lang/crystal/pull/6346 (Fix: incorrect debug info for closured self)
duane has quit [Ping timeout: 268 seconds]