ChanServ changed the topic of #crystal-lang to: The Crystal programming language | http://crystal-lang.org | Crystal 0.21.1 | Fund Crystal's development: http://is.gd/X7PRtI | Paste > 3 lines of text to https://gist.github.com | GH: https://github.com/crystal-lang/crystal | Docs: http://crystal-lang.org/docs/ | API: http://crystal-lang.org/api/ | Logs: http://irclog.whitequark.org/crystal-lang
<FromGitter> <fridgerator> lol
_whitelogger has joined #crystal-lang
rafadc has joined #crystal-lang
rafadc has left #crystal-lang [#crystal-lang]
mark_66 has joined #crystal-lang
miketheman has quit [Ping timeout: 260 seconds]
leex has quit [Ping timeout: 268 seconds]
pleiosau1 has quit [Ping timeout: 268 seconds]
leex has joined #crystal-lang
cyberarm has quit [Ping timeout: 240 seconds]
miketheman has joined #crystal-lang
Raimondii has joined #crystal-lang
pleiosaur has joined #crystal-lang
Raimondi has quit [Ping timeout: 268 seconds]
RX14 has quit [Ping timeout: 268 seconds]
cyberarm has joined #crystal-lang
wmoxam has quit [Ping timeout: 260 seconds]
Raimondii is now known as Raimondi
pabs has quit [Ping timeout: 268 seconds]
pabs has joined #crystal-lang
RX14 has joined #crystal-lang
bazaar has quit [Read error: Connection reset by peer]
bazaar_ has joined #crystal-lang
wmoxam has joined #crystal-lang
cyberarm has quit [Ping timeout: 252 seconds]
cyberarm has joined #crystal-lang
gloscombe has joined #crystal-lang
Qchmqs has joined #crystal-lang
Philpax has joined #crystal-lang
postmodern[m] has quit [Remote host closed the connection]
MatrixTraveler[m has quit [Read error: Connection reset by peer]
kodo[m] has quit [Write error: Connection reset by peer]
braidn[m] has quit [Write error: Connection reset by peer]
vegai has quit [Remote host closed the connection]
thelonelyghost has quit [Read error: Connection reset by peer]
sija[m] has quit [Remote host closed the connection]
krigare[m] has quit [Write error: Connection reset by peer]
MatrixTraveler[m has joined #crystal-lang
p0p0pr37_ has joined #crystal-lang
p0p0pr37_ has joined #crystal-lang
p0p0pr37 has quit [Ping timeout: 252 seconds]
p0p0pr37_ is now known as p0p0pr37
thelonelyghost has joined #crystal-lang
kodo[m] has joined #crystal-lang
braidn[m] has joined #crystal-lang
postmodern[m] has joined #crystal-lang
krigare[m] has joined #crystal-lang
sija[m] has joined #crystal-lang
vegai has joined #crystal-lang
bjz has joined #crystal-lang
zipR4ND has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
Qchmqs has quit [Ping timeout: 255 seconds]
bjz has joined #crystal-lang
Qchmqs has joined #crystal-lang
greengriminal has joined #crystal-lang
bjz_ has joined #crystal-lang
bjz has quit [Ping timeout: 260 seconds]
alxnlssn has joined #crystal-lang
<FromGitter> <sdogruyol> a quite day here :P
mv has joined #crystal-lang
mv has quit [Client Quit]
bjz_ has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
stereosteve has joined #crystal-lang
gewo has quit [Ping timeout: 264 seconds]
onionhammer has quit [Ping timeout: 246 seconds]
onionhammer has joined #crystal-lang
alxnlssn has quit [Quit: Connection closed for inactivity]
stereosteve has left #crystal-lang [#crystal-lang]
greengriminal has quit [Quit: This computer has gone to sleep]
mark_66 has quit [Remote host closed the connection]
<FromGitter> <bew> crystal is so intuitive no question needed :p
<FromGitter> <jwoertink> lol. I wish I could say that. I have a question about something every 5 seconds. I'm just trying not to get kicked out of the chat from a load of stupid questions hahah
<FromGitter> <bew> ahahah >< :D
McSoFake has joined #crystal-lang
<FromGitter> <bew> feel free to ask @jwoertink
<FromGitter> <sdogruyol> Yeah
<FromGitter> <jwoertink> I'll actually move over to the kemal chat for some of these
<wmoxam> ~~~]
<wmoxam> ~~~*
gloscombe has quit [Ping timeout: 245 seconds]
gloscombe has joined #crystal-lang
greengriminal has joined #crystal-lang
Qchmqs has quit [Ping timeout: 260 seconds]
Raimondii has joined #crystal-lang
Raimondi has quit [Ping timeout: 260 seconds]
Raimondii is now known as Raimondi
<FromGitter> <redcodefinal> Is there a way to do type restrictions for generics? I want to do something like ⏎ ⏎ ```code paste, see link``` ⏎ ⏎ I get the error that "T is not a class, T is a T" so I figured that if there was a way to restrict T to be of type A.class or typeof(A) that it would allow this. [https://gitter.im/crystal-lang/crystal?at=58ee61d8a0e4856242fa467e]
greengriminal has quit [Read error: Connection reset by peer]
greengriminal has joined #crystal-lang
<FromGitter> <redcodefinal> Well I guess I should start with can you inherit from a generic?
<FromGitter> <asterite> You can, but the compiler is very buggy in that respect, I would advise against that
<FromGitter> <redcodefinal> Darn I guess I'
<FromGitter> <redcodefinal> I'll have to figure out another way
McSoFake has quit [Quit: No reason]
gloscombe has quit [Remote host closed the connection]
<FromGitter> <redcodefinal> is there a way to find out if a class responds_to? an instance variably inside the class? `:@instance_variable` doesn't work since I guess `@` isnt allowed in symbols. ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58ee730ab52518ed4d0659ec]
<FromGitter> <Sija> @redcodefinal you can check existence of a method, not an ivar
<FromGitter> <redcodefinal> ok ty i guess I'll have to go about it a different way
<FromGitter> <Sija> why not `responds_to?(:test)`?
<FromGitter> <redcodefinal> Yeah that was my second option but it would have been a little cleaner to test an ivar instead but ultimately I guess I'll need to expose it. I'm playing around with some DSL stuff right now
greengriminal has quit [Quit: This computer has gone to sleep]
greengriminal has joined #crystal-lang
<FromGitter> <KCreate> Hey, I have a question about fibers in general and also have a concrete issue I'm trying to solve.
<FromGitter> <KCreate> Suppose I have a while-loop which does some expensive computations and a signal handler for `Signal::USR1`, the signal handler is never called because the main fiber doesn't give control back to the signal handler ⏎ ⏎ How could I make that work? ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58ee78e5bdf4acc11252e8af]
<FromGitter> <chuckremes> @KCreate You are going to need to call `Fiber.yield` somewhere in your `do_something_expensive` call. If it’s a single monolithic computation that can’t be interrupted then you are SOL. If you can divide it up into steps, call yield between the steps to give other fibers a chance to run. Remember that fibers are *cooperatively* scheduled so you need to be a good citizen.
greengriminal has quit [Quit: This computer has gone to sleep]
sz0 has joined #crystal-lang
greengriminal has joined #crystal-lang
<FromGitter> <KCreate> > Remember that fibers are cooperatively scheduled so you need to be a good citizen. ⏎ That made it super clear to me, I'll see what I can do
<FromGitter> <KCreate> damnit markdown formatting
greengriminal has quit [Client Quit]
greengriminal has joined #crystal-lang
<crystal-gh> [crystal] asterite pushed 3 new commits to master: https://git.io/vSDpO
<crystal-gh> crystal/master 7ca33b9 Sijawusz Pur Rahnama: Reformat File.write comment
<crystal-gh> crystal/master c7720ae Sijawusz Pur Rahnama: Use `Bytes` type idiom in HTTP::WebSocket#on_binary
<crystal-gh> crystal/master 2cd94c2 Sijawusz Pur Rahnama: Capitalize remaining lowercase stdlib exception messages
<FromGitter> <asterite> When parallelism lands that will work well, because the signal handler will probably run in another thread
<FromGitter> <fridgerator> :thumbsup:
zipR4ND1 has joined #crystal-lang
zipR4ND has quit [Ping timeout: 252 seconds]
<FromGitter> <KCreate> Super hyped for that!
<FromGitter> <chuckremes> @asterite Is the `thread-support` branch in good enough shape for early adopters to start testing code? I note that the last commit was a little over a month ago… maybe you guys have a bunch of local branches with changes that haven’t been pushed yet.
<FromGitter> <asterite> There's single-msqueue too, but it's not ready for testing yet
bjz has joined #crystal-lang
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <carsonbaker> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58ee99308bb56c2d11a09d05]
<RX14> @asterite what's the single-msqueue branch for?
<FromGitter> <carsonbaker> Hi.. can someone help me figure out how to implement .shutdown in the code I just posted? I'm a little confused.
<RX14> `@server.close`
<FromGitter> <carsonbaker> I don't know how to break out of the loop in the #start method. Because @server.accept blocks, it seems weird. I want to sort of.. cancel the @server.accept call.
<FromGitter> <carsonbaker> Oh, duh. So @server.close will make the #accept method return. Sorry, I don't know why I didn't see that.
<RX14> accept will raise when you call `@server.close`
<RX14> if you want it to return use accept?
<FromGitter> <carsonbaker> Gotcha. Thanks much. I feel silly.
<RX14> I find the best way to accept sockets is this:
<FromGitter> <RX14> ```while socket = server.accept? ⏎ spawn handle_client(socket) ⏎ end``` [https://gitter.im/crystal-lang/crystal?at=58ee99eae3700b1461c9213e]
<RX14> you do need the handle_client method
<RX14> well, a method
<FromGitter> <carsonbaker> <thumbs up> i'll do it like that.
<RX14> otherwise `socket` pointer could change
bjz has joined #crystal-lang
<FromGitter> <elorest> Is it possible to run kemal or HTTP::Server with sockets instead of ports yet?
<RX14> probably not
<RX14> is there a github issue?
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bjz has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter> <jwoertink> Has anyone dealt with `EVP_DecryptFinal_ex:wrong final block length` error from `OpenSSL::Cipher`?
bjz has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
<FromGitter> <elorest> <RX14> There’s this but it sort of seems to leave it hanging.
<RX14> commented @elorest
<FromGitter> <bew> @RX14 you see it as another constructor? Or as THE constructor (replacing the one with host/port)?
<RX14> how would it replace it?
<RX14> there's no way to specify a host/port
<FromGitter> <bew> Hmmrightmm, let's go to sleep now...
<FromGitter> <jwoertink> but you could at least buy me dinner first :p
<FromGitter> <elorest> @bew I believe that currently you just specify a port.
<FromGitter> <carsonbaker> is there a built-in programmatic way to tell if i'm running "crystal spec" vs an ordinary execution? i guess I could make something up where I set ENV["testing"] = true in my spec_helper.cr file...
<FromGitter> <bew> @carsonbaker why do you need that?
<FromGitter> <carsonbaker> i just wanted to change my log level when testing.
<FromGitter> <fridgerator> I usually set an env flag like you mentioned
<FromGitter> <carsonbaker> sounds good.
<FromGitter> <bew> Why we `can't reopen enum and add more constants to it` ?
elia has joined #crystal-lang
<FromGitter> <jwoertink> Is there a way to get a list of valid encodings for a string?
<FromGitter> <luislavena> @carsonbaker there is no differentiation. You can add something to `spec_helper.cr` (say override the default logging level)
<FromGitter> <carsonbaker> cool. thanks luis.
<FromGitter> <luislavena> @jwoertink can you provide a bit more of context on what you are trying to achieve?
<FromGitter> <jwoertink> There's this string in ruby that I'm trying to match up in crystal
<FromGitter> <jwoertink> if I call bytes on them, they are both the same
<FromGitter> <jwoertink> but in ruby, the encoding is ASCII-8BIT
<FromGitter> <jwoertink> I'm assuming in crystal it's UTF-8
<FromGitter> <jwoertink> this string gets passed to `OpenSSL::Cipher`
<FromGitter> <jwoertink> and I get different results between the two
<FromGitter> <jwoertink> ```icr(0.21.1) > String.new(secret).valid_encoding? ⏎ => false``` [https://gitter.im/crystal-lang/crystal?at=58eeb748408f90be66b5a1b8]
<FromGitter> <jwoertink> `String.new(secret).encode("ASCII-8BIT")` throws `Invalid encoding: ASCII-8BIT (ArgumentError)`
<FromGitter> <luislavena> @jwoertink Crystal default encoding is UTF-8, you can change encodings by using `.encode` or `.new(bytes, encoding)`
<FromGitter> <elorest> that isprime hosting looks pretty good.
<FromGitter> <elorest> is it much harder to use that digital ocean and aws?
<FromGitter> <luislavena> @jwoertink the encoding names are the ones supported by iconv, let me find you a reference
<crystal-gh> [crystal] MakeNowJust opened pull request #4280: Fixed #4278: String#underscore with digit (master...fix/string/underscore-with-digit) https://git.io/vSyaA
<FromGitter> <luislavena> `iconv --list` on the console (Linux) should provide you a list of supported encondings. AFAIK `ASCII-8BIT` is simply `ASCII`
<FromGitter> <bew> Encoding list is also available on https://www.gnu.org/software/libiconv/
<FromGitter> <jwoertink> ```2.3.3 :042 > secret.encoding ⏎ => #<Encoding:ASCII-8BIT> ``` [https://gitter.im/crystal-lang/crystal?at=58eeb82f8fcce56b20f82c60]
<FromGitter> <jwoertink> That's what I was trying to get. `String.new(secret, "ASCII")` throws a `Invalid multibyte sequence (ArgumentError)`
<FromGitter> <bew> Do you have an example string that you can share?
<FromGitter> <luislavena> @jwoertink was going to ask the same as @bew
<FromGitter> <luislavena> @jwoertink a direct link to sample array of bytes will be enough (honestly don't have the time to digest all the above links)
<FromGitter> <jwoertink> in this case `secret` comes from `secret = key_generator.generate_key("encrypted cookie")`
<FromGitter> <jwoertink> `[93, 56, 81, 213, 94, 160, 13, 60, 23, 193, 7, 184, 58, 203, 193, 168, 137, 123, 206, 232, 152, 193, 48, 128, 123, 22, 242, 193, 77, 51, 69, 158, 18, 195, 65, 215, 38, 20, 224, 77, 25, 224, 232, 166, 221, 140, 224, 139, 69, 171, 234, 79, 115, 128, 87, 30, 161, 56, 70, 232, 149, 132, 132, 73]`
<FromGitter> <jwoertink> those are the bytes
<FromGitter> <luislavena> @jwoertink please note that Ruby indicates ASCII-8BIT encoding sometimes to something that is a binary, it might not be a valid ASCII string
<FromGitter> <jwoertink> ```2.3.3 :043 > secret.valid_encoding? ⏎ => true``` [https://gitter.im/crystal-lang/crystal?at=58eeb934ad849bcf427b5045]
<FromGitter> <jwoertink> not sure if that makes a difference or not
<FromGitter> <luislavena> can we ignore for a second the encryption part?
<FromGitter> <jwoertink> yeah
<FromGitter> <luislavena> you're trying to build a string from the output of the encryption box, so the decrypted byte array should be the plain text you encrypted, that is correct?
<FromGitter> <luislavena> I took the bytes you gave and did this:
<FromGitter> <luislavena> `b = String.new(a, encoding: "ASCII", invalid: :skip)`
<FromGitter> <luislavena> that definitely resulted in random stuff
<FromGitter> <luislavena> `b # => "]8Q^\r<\u0017\u0007:{0{\u0016M3E\u0012A&\u0014M\u0019EOsW\u001e8FI"`
<FromGitter> <jwoertink> `"]8Q\xD5^\xA0\r<\x17\xC1\a\xB8:\xCB\xC1\xA8\x89{\xCE\xE8\x98\xC10\x80{\x16\xF2\xC1M3E\x9E\x12\xC3A\xD7&\x14\xE0M\x19\xE0\xE8\xA6\xDD\x8C\xE0\x8BE\xAB\xEAOs\x80W\x1E\xA18F\xE8\x95\x84\x84I"`
<FromGitter> <jwoertink> that's what I get from ruby. I would assume they would match, right?
<FromGitter> <luislavena> the thing is that Crystal strings are UTF
<FromGitter> <luislavena> just recently they will ignore invalid sequences, but still is not the best medium to store non-UTF content
<FromGitter> <luislavena> encrypted stuff sounds to me *not* a string but a byte sequence
<FromGitter> <luislavena> doing `b = String.new(a)` (where `a` is the `Byte[...]` sequence) got this:
<FromGitter> <luislavena> `b # => "]8Q\xD5^\xA0\r<\u0017\xC1\u0007\xB8:\xCB\xC1\xA8\x89{\xCE\xE8\x98\xC10\x80{\u0016\xF2\xC1M3E\x9E\u0012\xC3A\xD7&\u0014\xE0M\u0019\xE0\xE8\xA6݌\xE0\x8BE\xAB\xEAOs\x80W\u001e\xA18F蕄\x84I"`
<FromGitter> <jwoertink> Right. Same thing I got.
<FromGitter> <jwoertink> Ultimately, the goal here is that you log in to a rails app, rails created a session cookie, then you go to a kemal app, that cookie is deserialized
<FromGitter> <jwoertink> and then vice/versa
<FromGitter> <jwoertink> so I want to mimic what rails is doing when encoding the session, but I get different values
tilpner has quit [Quit: :wq]
<FromGitter> <luislavena> @jwoertink you might want to read how the Splice folks worked that out. the first thing (and that is the new Rails default) is that the cookie is in JSON format, so can be serialized-deserialized across languages
<FromGitter> <luislavena> (instead of Marshal)
<FromGitter> <luislavena> Now, the encrypt+sign part shouldn't be complicated, but usage of strings to handle that part might lead into errors.
<FromGitter> <jwoertink> right. I was reading that article by matt on that
badeball has quit [Ping timeout: 240 seconds]
tilpner has joined #crystal-lang
badeball has joined #crystal-lang
zipR4ND1 has quit [Ping timeout: 260 seconds]
splitty_ has quit [Quit: Leaving]
elia has quit [Quit: Computer has gone to sleep.]
<FromGitter> <carsonbaker> Here's a weird one: ⏎ ⏎ ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58eebdcb8bb56c2d11a12e0c]
<FromGitter> <carsonbaker> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=58eebdfea0e4856242fbd94f]
<FromGitter> <carsonbaker> I would think the print from server. cr should be "0x01 0x81" but instead I get "01 4a". What's up with that? I'm missing something important.
greengriminal has quit [Quit: Leaving]
<FromGitter> <carsonbaker> This, interestingly, does *not* happen if I don't layer in SSL.
<FromGitter> <carsonbaker> It's like every byte over 0x80 gets randomly changed to something else.
greenbigfrog has quit [Quit: The server of my BNC just shutdown or got killed!!!]
<FromGitter> <carsonbaker> If I send `01 02 03 79 7a 7b 7c 7f 80 81 82 83 84 85 86 87`, then I receive `01 02 03 79 7a 7b 7c 7f 01 c2 83 c4 85 c6 87`.