<FromGitter>
<elorest> has anyone expirienced an issue where context.response.headers don’t all end up in the headers from curl or the browser. Sort of sporatically.
bcardiff has joined #crystal-lang
w-p has joined #crystal-lang
sz0 has quit [Quit: Connection closed for inactivity]
rohitpaulk has joined #crystal-lang
<bmcginty>
Anyone here have issues detecting closed sockets? I'm trying to check to see if a persistent connection is still alive, and I can't figure out when/what is supposed to be returned when the remote end of a socket closes.
<bmcginty>
elorest: I was seeing weird http stuff last week...weird enough that I'm trying to write/use my own to figure out what was going on. Though mine has just been in the client.
<FromGitter>
<elorest> k
renich has quit [Quit: Renich]
http_GK1wmSU has joined #crystal-lang
bcardiff has quit [Quit: bcardiff]
http_GK1wmSU has left #crystal-lang [#crystal-lang]
<oprypin>
elorest, hopefully you aren't putting broken strings with arbitrary bytes in there?
hightower has joined #crystal-lang
tosmi` has joined #crystal-lang
tosmi has quit [Ping timeout: 260 seconds]
hightower has quit [Ping timeout: 240 seconds]
<FromGitter>
<konovod> .
<FromGitter>
<elorest> <oprypin> Nope.
<FromGitter>
<sdogruyol> Good morning everyone
<FromGitter>
<elorest> Morning.
<FromGitter>
<elorest> <oprypin> For some reason if the body is even moderately large(~200 elements) it changes to chunked mode and overwrites the existing headers with ⏎ ⏎ ```< HTTP/1.1 200 OK ⏎ < Connection: keep-alive ⏎ < Transfer-Encoding: chunked``` [https://gitter.im/crystal-lang/crystal?at=598408fb210ac26920518ffa]
<FromGitter>
<elorest> If I reduce the size of the http body all of my headers get sent.
<FromGitter>
<elorest> And my cookies get set in my browser.
<shelvacu>
Is it a consistent size that changes it? Maybe 4k bytes or something?
<shelvacu>
deflate compression lib and stdlib buffered io both use a buffer size of 8192
<shelvacu>
1
<FromGitter>
<elorest> Yeah I’m finding stuff about that number everywhere. As far as html pages are concerned it’s not really that big.
<FromGitter>
<elorest> I believe that chunking after that size is appropriate. I just tested a couple rails sites. They also chuck after that number but they don’t delete my headers in the process.
snsei has joined #crystal-lang
rohitpaulk has quit [Ping timeout: 248 seconds]
snsei has quit [Remote host closed the connection]
rohitpaulk has joined #crystal-lang
mark_66 has joined #crystal-lang
snsei has joined #crystal-lang
<bmcginty>
oprypin: It's with sockets that I'm having the issue. Straight reading from them times out (while checking to see if .read returns 0).
snsei has quit [Remote host closed the connection]
rohitpaulk has quit [Ping timeout: 255 seconds]
snsei has joined #crystal-lang
http_GK1wmSU has joined #crystal-lang
snsei has quit [Remote host closed the connection]
http_GK1wmSU has left #crystal-lang [#crystal-lang]
<FromGitter>
<bararchy> bmcginty: Can you share a code exmaple ?
early has quit [Quit: Leaving]
early has joined #crystal-lang
<oprypin>
bmcginty, no difference
<oprypin>
sockets when explicitly closed will get you 0. but detecting remote socket going away is not reliable, hence timeout
<bmcginty>
oprypin: thanks.
hightower has joined #crystal-lang
trapped has joined #crystal-lang
trapped has quit [Read error: Connection reset by peer]
trapped has joined #crystal-lang
bmcginty has quit [Ping timeout: 248 seconds]
bmcginty has joined #crystal-lang
<FromGitter>
<code-andres> Hi, everyone... I'm stuck using concurrency for a simple logger... ⏎ ⏎ I have a Process, a spawn where the output is print and i want to use another spawn where each 3 seconds for example, kill the old Process and send the new one to the first spawn, I was trying with channels but the spawn must wait for a send. ⏎ ⏎ In littler words, is there a way to create just a "listener"between spawns
<FromGitter>
<akzhan> This is signal handler. They interrupts process execution for some events.
<FromGitter>
<akzhan> Many operating systems allow signals to be sent to running processes. Some signals have a defined effect on the process, while others may be trapped at the code level and acted upon. For example, your process may trap the USR1 signal and use it to toggle debugging, and may use TERM to initiate a controlled shutdown.
<FromGitter>
<akzhan> this is citation from Ruby doc :)
<FromGitter>
<akzhan> And usually should to set ignore on PIPE signal.
http_GK1wmSU has joined #crystal-lang
http_GK1wmSU has left #crystal-lang [#crystal-lang]
tosmi` has quit [Ping timeout: 260 seconds]
<FromGitter>
<crisward> @akzhan Thanks... I was using this around a `socket.send` as I was getting application crashes when the remote end disconnected mid message. However it seems to stop the sockets sending altogether. I can't remember what the exception was.
<FromGitter>
<crisward> I think someone on here suggested it, I added it a while ago, but just realised it's actually preventing the sockets being sent.
DTZUZO has quit [Ping timeout: 255 seconds]
<oprypin>
crisward, putting code inside signal.trap doesn't mean wrapping it, the code actually won't run. the code will run when the corresponding signal is received
<oprypin>
so the suggestion to use that probably meant something different
<FromGitter>
<crisward> oprypin - so it's like a rescue on begin, rescue ? Should I therefore just do this once globally ? Or once before every socket.send ? Perhaps I'll take a look at the ruby docs.
<oprypin>
> It is possible to make a custom RNG by including Random and implementing #next_u to return an unsigned number of a pre-determined type (usually UInt32). The numbers generated by your RNG must be uniformly distributed in the whole range of possible values for that type (e.g. 0u32..UInt32::MAX).
<oprypin>
it returns the type that is "native" to this particular RNG
<FromGitter>
<konovod> So how to get say random UInt64?
<FromGitter>
<konovod> oh, yes, then it's fine.
<oprypin>
`rand(UInt64::MIN..UInt64::MAX)`
<RX14>
oprypin, perhaps the kernel will write more than sizeof(struct sockaddr) when it can, for performance reasons around unaligned memory?
<oprypin>
that's too far down the rabbit hole
<RX14>
lol
<oprypin>
maybe the problem is size mismatch and the actual sckaddr it tries to write is bigger
<oprypin>
u said there can be different ones
<RX14>
perhaps
<RX14>
yes but looking again
<RX14>
they're all the same size?
<oprypin>
konovod, also just so you're aware, you wrote `u = 0_u64` but it can have absolutely no effect on consequent assignments to it
<oprypin>
assignment to a variable always makes the type of the variable the same as what was assigned to it, regardless of previous uses of that variable name
<oprypin>
i seem to notice this misconception often lately, maybe some docs need to clarify this
<RX14>
variables don't exist, we just have SSA but they're all named the same and every usage is a phi node
<FromGitter>
<konovod> @oprypin yeah, i was totally wrong. It would have effect in a field, but local var is just overwritten.
<oprypin>
it would have an effect of a compile error due to type mismatch but yeah
zaiste has joined #crystal-lang
A124 has joined #crystal-lang
<crystal-gh>
[crystal] konovod opened pull request #4789: Seed PRNGs from System source instead of time (master...rng_seed) https://git.io/v7Vju
<crystal-gh>
[crystal] RX14 opened pull request #4790: Fix WeakRef specs in release mode (master...bugfix/weakref-specs) https://git.io/v7Vjo
imnotjustarobot has joined #crystal-lang
<imnotjustarobot>
hello!
<RX14>
hi
<imnotjustarobot>
where can I get an interactive crystal? like IRB, the interactive ruby
<RX14>
crystal play
<RX14>
you can write code in there and get output in your browser
<imnotjustarobot>
but this is not the interactive crystal i expected
<imnotjustarobot>
is there not an interactive crystal like irb?
<RX14>
what do you need an interactive crystal for?
<imnotjustarobot>
like irb
<RX14>
if it's trying out snippets of code, you should use crystal play
<RX14>
if it's trying to use it as a debugger
<RX14>
well, you can't
<RX14>
it's impossible because crystal is compiled and statically typed
bcardiff has quit [Quit: bcardiff]
<imnotjustarobot>
but i can remember that there was somewhere in the universe an interactive crystal like irb..
<RX14>
there is but it doesn't work like irb in any way
<imnotjustarobot>
how can I half a number? is there an method for this?
<RX14>
divide it by two?
<imnotjustarobot>
oh
<crystal-gh>
[crystal] matiasgarciaisaia pushed 1 new commit to master: https://git.io/v7wv4
snsei has quit [Remote host closed the connection]
sauer2 has joined #crystal-lang
<sauer2>
Hi. Time.now.to_s("%s") returns the time from the UNIX date in seconds. I didn't find a format option to return it in milliseconds. Is there such an option?
<sauer2>
Or was it left out due to precision shenanigans?
<RX14>
sauer2, you want #epoch_ms
<RX14>
sauer2, because to_s is decimal you can concat %s%L and get the same result, but please just use #epoch_ms.to_s
<sauer2>
@RX14: That works, thank you!
<sauer2>
Oh, another question that came up: Does Crystal have anonymous classes?
<RX14>
no
<RX14>
what's the usecase?
<sauer2>
injecting function containers into an interpreter
<sauer2>
maybe for command patterns in general
<RX14>
well in crystal, classes and modules and that aren't *really* values
<RX14>
they are in ruby
<RX14>
but in crystal it's all just smoke and mirrors
<RX14>
so a lot of things would break with anonymous classes, they already do with private classes
<RX14>
would file-private classes help?
<sauer2>
No idea, but it is mostly a convenience issue at worst, since I have to write the function containers down and then pass an instance to the interpreter instead of passing an anonymous class.
<sauer2>
There might be even a better solution, since the code in question was ported from Java.
<RX14>
well i'd recommend just naming the classes
<sauer2>
@RX14: those can be passed directly?
<RX14>
no
<sauer2>
Hm. If it weren't a textbook text but a real world scenario, metaprogramming might have worked...
<sauer2>
Oh well, anyway, thanks for your time.
<RX14>
i don't think this is a valid usecase for metaprogramming of the top of my head
<RX14>
but i don't know the details so...
<sauer2>
@RX14 Why not? The functions might be considered part of the interpreter itself instead of injecting them at runtime. But that kind of stuff may only be possible with full compile time AST manipulation as shown in JAI; not sure if it's possible with replacement macros.
<RX14>
what do you mean injecting them at runtime
<sauer2>
I mean, if the interpreter is embedded in a host application you might want to provide application specific functions, for automation, macros, etc.
rohitpaulk has quit [Ping timeout: 240 seconds]
<sauer2>
So when you create the interpreter instance you first have to register application specific functions at it.
rohitpaulk has joined #crystal-lang
<sauer2>
@RX14 It's basically what people do with Lua.
sauer2 has quit [Quit: Page closed]
alibby has quit [Quit: Leaving.]
zaiste has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]