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
kmctown has joined #crystal-lang
kmctown has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<FromGitter> <girng> hello!
g- has joined #crystal-lang
<FromGitter> <sam0x17> how to get the IP address of an HTTP request being served by an instance of HTTP::Server
<FromGitter> <sam0x17> ?
<FromGitter> <sam0x17> I can't seem to find a way of getting the socket to the connected client -- if I had that I could get the ip address I think
<FromGitter> <bararchy> @sam0x17 -> https://github.com/crystal-lang/crystal/issues/453
virkony has joined #crystal-lang
<FromGitter> <bararchy> It seems that there is general bikeshedding, where everyone want's the "perfect" solution while this is not addressed for more then two years now
<FromGitter> <bararchy> and everyone just creates monky patching to handle this
<FromGitter> <bararchy> btw @sam0x17 you can abuse https://crystal-lang.org/api/master/HTTP/Server/Response.html#upgrade%28%26block%29-instance-method like most people do
<FromGitter> <bew> @luislavena hey, just saw https://youtu.be/r_9UB8-hG7I who poped in my YouTube recommendations :) veryy nice! are you still in Paris?
ashirase has quit [Ping timeout: 272 seconds]
ashirase has joined #crystal-lang
blassin has quit [Remote host closed the connection]
blassin has joined #crystal-lang
<FromGitter> <mavu> How do I check if I reached the end of an IO stream?
<FromGitter> <j8r> The end? You can check of the IO is closed
<FromGitter> <bew> Heart kind of io stream? (how would it know this is the end?)
<FromGitter> <bew> What*
<FromGitter> <j8r> Usually there is a terminator character
<FromGitter> <j8r> For lines
<FromGitter> <j8r> `\n` usually, that's it
<FromGitter> <mavu> I just treid Process.run do |p| and in the block read p.output.
<FromGitter> <mavu> it always runs into IO::EOFError
<FromGitter> <mavu> even with while !p.closed? around.
<FromGitter> <mavu> like this: ⏎ ⏎ `````` [https://gitter.im/crystal-lang/crystal?at=5c5ebc1c4003460b2d1f7d75]
<FromGitter> <mavu> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c5ebc3428c89123cb9ca6c2]
<FromGitter> <mavu> If I don't catch the EOFError It will always crash.
<FromGitter> <bew> Try add `output: Process::Redirect::Pipe` to the args of process run
<FromGitter> <bew> Hmm actually no it should be done by default with this overload
<FromGitter> <bew> Does it work with another program?
<FromGitter> <mavu> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c5ed019d1e3093ab5ef2aa4]
kmctown has joined #crystal-lang
<FromGitter> <mavu> (btw: have not updated yet, still on 0.27.0)
<FromGitter> <mavu> I think I know why that does not work. I suspect the pipe is only closed after the block exits. I just accideantally commented the puts p.output.read_line which left an empty block. ⏎ and the block never exited, with 100 cpu. I assume the while loop was circling the drain and .closed? never went true.
<FromGitter> <proyb6> What is the Crystal equivalent of C++ std::vector?
_whitelogger has joined #crystal-lang
aelyx has joined #crystal-lang
aelyx has quit [Read error: Connection reset by peer]
kmctown has quit [Quit: Textual IRC Client: www.textualapp.com]
<FromGitter> <bew> @proyb6 i'd say Array ?
<FromGitter> <proyb6> @bew I also came across ridiculous fast AOC in C++, probably a nice reference for benchmark in microseconds ⏎ https://github.com/Voltara/advent2018-fast ⏎ ⏎ Have been thinking whether a vector version in Crystal could be useful? [https://gitter.im/crystal-lang/crystal?at=5c5efa4080df6804a1776ee0]
Flipez has quit [Quit: The Lounge - https://thelounge.github.io]
Flipez has joined #crystal-lang
<FromGitter> <j8r> Yes it looks like C++ Array is StaticArray, and C++ Vector is Array
g- has quit [Remote host closed the connection]
<FromGitter> <Sija> For y’all linting loving creatures, now you can use Ameba on Codacy! 🎉 Cheers to @veelenga for his work on that (both Ameba and Codacy integration) ❤️
jemc has joined #crystal-lang
<FromGitter> <vladfaust> Thanks, @veelenga :)
<FromGitter> <vladfaust> What's the best way to find difference between two flat Hash of the same type `String => T`?
<FromGitter> <vladfaust> Having `@initial` and `@actual`, need to get changes in `@actual` compared to `@initial@
<FromGitter> <Blacksmoke16> to compute a change set?
<FromGitter> <vladfaust> Yup
<FromGitter> <Blacksmoke16> new hash, iterate over each key of one, if they dont match add that new new hash?
<FromGitter> <vladfaust> Yeah, but maybe a faster variant, IDK
<FromGitter> <Blacksmoke16> intersect would be neat
<FromGitter> <silmanduin66> hello
<FromGitter> <silmanduin66> i'm new to slang. Now i can do the following: ⏎ ⏎ ```p ⏎ == user.name``` ⏎ ⏎ but how can i turn this into somthing like : ... [https://gitter.im/crystal-lang/crystal?at=5c5f2035604f233ab6e03e60]
<FromGitter> <HarrisonB> @silmanduin66 I think it offers string interpolation? ⏎ ⏎ ```p ⏎ Your user name is #{user.name}``` [https://gitter.im/crystal-lang/crystal?at=5c5f20a63608b004a0998af9]
jemc has quit [Ping timeout: 246 seconds]
<FromGitter> <r00ster91> When I do `Bytes[500]` then that's a `Slice` of `UInt8`s but how does that work? 500 doesn't fit in a `UInt8`
<FromGitter> <diegogub> Hello all! Is it possible to iterate over a Union type , types?
<FromGitter> <Blacksmoke16> in a macro yes
<FromGitter> <Blacksmoke16> https://crystal-lang.org/api/0.27.0/Crystal/Macros/TypeNode.html#union_types%3ACrystal%3A%3AMacros%3A%3AArrayLiteral%28TypeNode%29-instance-method
<FromGitter> <diegogub> perfect, thank you @Blacksmoke16
<FromGitter> <bararchy> This is a bug right? ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ the `secure` and `http_only` flags are `false` even though it clearly has those flags [https://gitter.im/crystal-lang/crystal?at=5c5f23ccdf8a67280361c31f]
<FromGitter> <bararchy> Header was: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c5f241f9ed7e3764f4b3ca7]
<FromGitter> <silmanduin66> @HarrisonB thanks your solution works but I had to add `` ` | ` `` in front of the sentence :-)
jemc has joined #crystal-lang
<FromGitter> <Blacksmoke16> @bararchy https://play.crystal-lang.org/#/r/67na looks like the regex its using isnt picking up on it
<FromGitter> <Sija> @bararchy It’s because of incorrect date passed for_expires_ key
<FromGitter> <Sija> `12-Oct-1999` should be `12 Oct 1999`
<FromGitter> <Sija> perhaps regex parser could be changed to accept it, yet it’s clearly not a standard compliant format
<FromGitter> <Blacksmoke16> welp that would do it
<FromGitter> <Blacksmoke16> grr microsoft? :p
<FromGitter> <Sija> obviously IIS doesn’t give a f… about the standards
<FromGitter> <Blacksmoke16> doesnt surprise me, exchange server returns non web safe base64 strings as IDs for calendar/events and stuff
<FromGitter> <Sija> I guess it’s better to support it, since soon we could see those returned from GH servers… (sic!) ;)
<FromGitter> <bararchy> XD
<FromGitter> <bararchy> Trying to use your fix via monkeypatch, but it won't allow me to re-assagin the constants :\ ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5c5f3ad3df8a67280361c326]
<FromGitter> <Sija> yep, can’t do
<FromGitter> <Sija> you’d have to override `HTTP::Cookie::Parser.parse_set_cookie`
<FromGitter> <bararchy> 😢
<FromGitter> <bararchy> f***ing M$
<FromGitter> <Sija> that’s one of those rare cases where monkey-patching ain’t do it :/
<FromGitter> <bararchy> yeha, interesting though wha'ts the idea of not allow overiding constants
<FromGitter> <talbergs> Here is a small snippet. https://play.crystal-lang.org/#/r/67o1 Is it possible somehow to know a `callee` (at least class name) of a method? In lin 36 I have to pass `self` and in line 8 I have to accept it in signature. Could this value be determined runetime in def @line:8 ?
<FromGitter> <Sija> @talbergs try `caller`
<FromGitter> <talbergs> Thanks, will know about this keyword.
<FromGitter> <talbergs> Still, this does not help - it gives me this: https://play.crystal-lang.org/#/r/67o6 filenames and linenumbers
<FromGitter> <Sija> you have a method names there too, but no class names indeed :/
<FromGitter> <Sija> it used to include ‘em as well, but not anymoar
<FromGitter> <talbergs> yes not anymoar :(
<FromGitter> <talbergs> refactored a bit more https://play.crystal-lang.org/#/r/67oi now is there a `final` keyword? So ComponentA would not be able to declare method `get`
<FromGitter> <Blacksmoke16> neg, could maybe do something like this tho
<FromGitter> <talbergs> The first thing I guess is to create an expert level documentation for low level stuffs - ins and outs and various tricks - `caller` keyword for example is not in docs. Currently docs look like ment for housewifes, no offence
<FromGitter> <talbergs> Could be separate gitbook thou. But really in depth. (and keep in mind, the reader never heard of ruby) ... my 2 cents ;)
<FromGitter> <Blacksmoke16> @talbergs https://play.crystal-lang.org/#/r/67p3
<FromGitter> <talbergs> Smart idea - metaprogramming for win
<FromGitter> <talbergs> I have currently avoided metacoding in crystal - dunno syntax even
<FromGitter> <talbergs> Do you ppl do it really often in your projects?
<FromGitter> <talbergs> Does not it reduce readibility?
<FromGitter> <Blacksmoke16> not to people who know crystal
<FromGitter> <Blacksmoke16> macros are deff something that takes a bit getting used to for a new dev tho
gangstacat has quit [Quit: Ĝis!]
gangstacat has joined #crystal-lang
return0e_ has joined #crystal-lang
return0e has quit [Ping timeout: 272 seconds]
<FromGitter> <kingsleyh> Hahaha @talbergs - the docs look like they are meant for housewives - hahaha - awesome comment - so funny lol - not sure if it’s accuracy but very funny hehe
<FromGitter> <Sija> had a proper laugh about it too, image of a housewife reading Crystal docs just next to the washing machine was a nice one :D
<FromGitter> <Sija> @bararchy https://carc.in/#/r/67r9
<FromGitter> <bew> @talbergs btw `caller` is not a keyword, it's a regular method
return0e has joined #crystal-lang
<FromGitter> <sam0x17> aww that's too bad was hoping `Hash.each_with_index` would yield the key, the value, and the index ,but looks like just key and index
<FromGitter> <HarrisonB> > the docs look like they are meant for housewives ⏎ ⏎ I think this may hurt fostering an inclusive atmosphere in this channel
return0e_ has quit [Ping timeout: 244 seconds]
<FromGitter> <sam0x17> yeah guys lets keep things inclusive and unoffensive
<FromGitter> <Sija> @sam0x17 it does, https://carc.in/#/r/67rb
<FromGitter> <sam0x17> weird
<FromGitter> <sam0x17> my code, then
<FromGitter> <HarrisonB> @sam0x17 can you post a snippet?
<FromGitter> <sam0x17> ```code paste, see link``` ⏎ ⏎ where `@locked_keys` is a `Hash(UInt64, Tuple(Time, UInt64))` [https://gitter.im/crystal-lang/crystal?at=5c5f6568253c2b5ea3e62e84]
<FromGitter> <Sija> `key, v` => `(key, v)`
<FromGitter> <sam0x17> ah so the key and value are a tuple
<FromGitter> <sam0x17> kk
<FromGitter> <sam0x17> yes that works thanks
<FromGitter> <Sija> @HarrisonB @sam0x17 c’mon guys, why so serious? ;) btw, imo these days it’s too easy to get into the trap of “inclusiveness” and forget about sense of humor
<FromGitter> <Sija> soon we’ll need to put the rainbow flag over every project logo to get away from the accusations of not being exclusive, bit of distance won’t hurt...
<FromGitter> <HarrisonB> @Sija personally it didn't strike me as very funny--I understand that may have been the intent but I imagine if you're a developer that also does housework it would feel kind of crummy to hear ⏎ ⏎ > soon we’ll need to put the rainbow flag over every project logo to get away from the accusations of not being exclusive ⏎ ⏎ I think that's a bit of a slippery slope argument...
<FromGitter> <Sija> @HarrisonB well, if you’re getting offended by the “housewife” term maybe you should re-evaluate your self-esteem
<FromGitter> <Sija> walking on the tiptoes just because someone might get offended seems more slippery to me
<FromGitter> <j8r> here, more likely househusbands
<FromGitter> <HarrisonB> @Sija my self-esteem seems fine--I would just rather us not imply that houseworkers are dumb as part of a joke
<FromGitter> <j8r> please if there are housewives here, excuse us - you do a great job ♥️
<FromGitter> <Sija> :D