fkchang has quit [Remote host closed the connection]
fkchang has joined #crystal-lang
NeverDie has joined #crystal-lang
fkchang has quit [Ping timeout: 252 seconds]
strcmp2 has joined #crystal-lang
strcmp1 has quit [Ping timeout: 260 seconds]
Veejay has quit [Ping timeout: 256 seconds]
Veejay has joined #crystal-lang
mgarciaisaia has joined #crystal-lang
dbackeus has joined #crystal-lang
dbackeus has quit [Ping timeout: 244 seconds]
havenwood has joined #crystal-lang
mgarciaisaia1 has joined #crystal-lang
mgarciaisaia has quit [Ping timeout: 246 seconds]
havenn has joined #crystal-lang
havenwood has quit [Ping timeout: 240 seconds]
havenn has quit [Ping timeout: 244 seconds]
mgarciaisaia has joined #crystal-lang
mgarciaisaia1 has quit [Ping timeout: 244 seconds]
nahtnam has quit [Quit: Connection closed for inactivity]
mgarciaisaia1 has joined #crystal-lang
mgarciaisaia has quit [Ping timeout: 244 seconds]
mgarciaisaia1 has quit [Ping timeout: 250 seconds]
mgarciaisaia has joined #crystal-lang
mgarciaisaia1 has joined #crystal-lang
nahtnam has joined #crystal-lang
mgarciaisaia has quit [Ping timeout: 256 seconds]
havenwood has joined #crystal-lang
mgarciaisaia has joined #crystal-lang
mgarciaisaia1 has quit [Ping timeout: 265 seconds]
mgarciaisaia has quit [Quit: Leaving.]
havenwood has quit [Ping timeout: 252 seconds]
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
havenwood has joined #crystal-lang
BlaXpirit has joined #crystal-lang
dbackeus has joined #crystal-lang
dbackeus has quit [Ping timeout: 255 seconds]
nahtnam has quit [Quit: Connection closed for inactivity]
blue_deref has quit [Quit: bbn]
Ven has joined #crystal-lang
havenwood has quit [Ping timeout: 240 seconds]
dbackeus has joined #crystal-lang
Ven has quit [Ping timeout: 255 seconds]
willl has quit [Quit: Connection closed for inactivity]
Ox0dea has joined #crystal-lang
leafybasil has quit [Remote host closed the connection]
leafybasil has joined #crystal-lang
leafybasil has quit [Ping timeout: 252 seconds]
Ven has joined #crystal-lang
unshadow has joined #crystal-lang
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
hosiawak has joined #crystal-lang
Kilo`byte has quit [Ping timeout: 256 seconds]
Kilo`byte has joined #crystal-lang
<dbackeus>
noticed that crystal doesn't seem to have any banged self mutating methods on String etc (upcase vs upcase! and so on), any comments on the reason for this?
leafybasil has joined #crystal-lang
<jhass>
dbackeus: String is intentionally immutable, the efficient non allocating APIs are on IO and similar instead
<trapped>
giving me this (after a series of undefined method/Nil errors): "Error: instance variable '@response' of CellViewer::Headers was not initialized in all of the 'initialize' methods, rend
<trapped>
on a side note, why shouldn't one be allowed to render views in middleware
<trapped>
just wondering about the design reasoning
<jhass>
I meant that you can call it while it can't handle it is a design bug
<jhass>
either it should handle it or not allow the call in the first place
dbackeus has joined #crystal-lang
<trapped>
jhass: while we wait for an official fix of sort, is there something i can do to "make it work"? like manually setting @response or something
<jhass>
trapped: well, look at the macro
<jhass>
just instantiate the view on your own and don't assign to @response.body
<jhass>
header = HeaderView.new(nil).render
<jhass>
and probably need to code the class on your own too to pass the variable, since the view macro doesn't seem to support that at all
<trapped>
yeah
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<trapped>
it's showing me <= partial_body %> on the page and outputting the actual partial_body to stdout along with request info
Ven has joined #crystal-lang
Ven has quit [Client Quit]
<jhass>
amethyst is.. a very moving target
<jhass>
I'll probably migrate carc.in away from it for now
<jhass>
it's good that these experiments happen to find an architecture that'll work well
<jhass>
it just makes it harder to use
<trapped>
how do i go rendering ECR files? the ECR module doesn't seem to let me give it variables to replace
<jhass>
the ECR is rendered inside the class you called ecr_file on, so you can access its instance variables and methods
<trapped>
alright
<trapped>
jhass: updated to this, complains that String does not have a '<<' method
<trapped>
actually i'll check in some source code
<jhass>
sure it's String and not String? (which is shortcut to String|Nil)
<jhass>
oh, actually String doesn't have #<<, right
<jhass>
since it's immutable
<trapped>
ah here it is
<trapped>
amethyst uses a StringIO
Ven has joined #crystal-lang
<jhass>
yeah, StringIO/String.build are the goto tools for sewing together strings
<jhass>
trapped: don't think you need the @controller = self line, and I guess you got getter's in your real code
<jhass>
also there should be a to_s on object which does exactly what your render does iirc, so could just call that
<jhass>
a nice pattern to clean up foo = xxx; something_with foo; foo is Object#tap: xxx.tap do |foo| something_with foo; end
<trapped>
if i remove the @controller = self line it sees that some variables i use in the ecr file are missing, tries to access them using @controller.@variable, which makes it fail to compile
<jhass>
oO
<trapped>
try for yourself
<trapped>
if i instead
<trapped>
add that line
<jhass>
okay I guess there's some method_missing idiosyncrasies going on
<trapped>
the error it gives on a missing variable is this: CellViewer::HeaderView doesn't have an instance var named '@page_title'
<jhass>
I'd just getter page_title, partial_body
<jhass>
or use @page_title and @partial_body in the view
<trapped>
which i guess i like more than "Nil doesn't have instance vars"
<trapped>
using @page_title it compiles even if the variable is missing
<jhass>
and well, I'm not sure if ob.@instance_var is going to survive
<trapped>
can i add whatever variables to a response? like response.title = "..."
<jhass>
I highly, highly doubt that
unshadow_ has joined #crystal-lang
unshadow has quit [Ping timeout: 240 seconds]
unshadow_ has quit [Ping timeout: 244 seconds]
unshadow has joined #crystal-lang
<asterite>
trapped: there are many reasons why strings are immutable. One is, for example, that if you use a string as a hash key (and that's something very common, think JSON), then you need separate memory for each of the strings, even though you won't be mutating those (but you have to be prepared if someone wants to do that anyway). I think Ruby optimizes this by having shared strings under the hoods, but that complicates things a lot. In most ca
<asterite>
ses immutable strings plus a string builder are easier and more performant.
<trapped>
asterite: why that explanation out of the blue
<asterite>
because I read the logs and I think you had that conversation when I was sleeping :)
unshadow_ has joined #crystal-lang
unshadow has quit [Ping timeout: 252 seconds]
<dbackeus>
that might have been me asking about the lack of mutable methods on String earlier, thanks for the explanation anyway :)
unshadow has joined #crystal-lang
waj has joined #crystal-lang
waj has quit [Client Quit]
dwahl has joined #crystal-lang
unshadow_ has quit [Ping timeout: 246 seconds]
dwahl has quit [Read error: Connection reset by peer]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Ven has joined #crystal-lang
<dbackeus>
is it possible to manipulate load paths in crystal?
<jhass>
yes, by setting the CRYSTAL_PATH environment variable
<jhass>
note that overwrites the defaults, so you have to include libs and the standard library too
<dbackeus>
thanks!
trapped_ has joined #crystal-lang
trapped has quit [Ping timeout: 244 seconds]
Ven has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
havenwood has joined #crystal-lang
_ has joined #crystal-lang
_ is now known as Guest5333
Ven has joined #crystal-lang
dwahl has joined #crystal-lang
Guest5333 has quit [Read error: Connection reset by peer]
trapped_ has quit [Ping timeout: 252 seconds]
Guest5333 has joined #crystal-lang
hosiawak` has joined #crystal-lang
trapped_ has joined #crystal-lang
hosiawak has quit [Ping timeout: 244 seconds]
Guest5333 has quit [Ping timeout: 246 seconds]
NeverDie has joined #crystal-lang
hosiawak` has quit [Ping timeout: 240 seconds]
luislavena has joined #crystal-lang
mgarciaisaia has joined #crystal-lang
<dbackeus>
why does typed tuples with inheritance break and what does the "+" mean after the class name in the error? http://play.crystal-lang.org/#/r/8jj
trapped_ has quit [Read error: Connection reset by peer]
_ is now known as Guest8658
<asterite>
Yes, it's exactly that issue
<dwahl>
dbackeus, and according to asterite's post, + means "foo or any of its subclasses" which is helpful because I've been wondering the same thing.
Guest8658 has quit [Read error: Connection reset by peer]
trapped_ has joined #crystal-lang
<trapped_>
i have an issue with JSON serialization
<BlaXpirit>
dwahl, you have to get used to the fact that crystal determines a ton of stuff at compile time
<dwahl>
nm, it's class in a macro is a NumberLiteral
<BlaXpirit>
determining the type of an object is executed at runtime only if it couldn't be determined at compile time and "hardcoded" into the executable
<dwahl>
so NumberLiteral returns true
kulelu88 has joined #crystal-lang
<dwahl>
BlaXpirit, yeah, I understand that, I just wasn't understanding that HashLiteral was a type defined within macros
<BlaXpirit>
perhaps u know more than i
<asterite>
Inside macros all you have access to are AST nodes, so you operate on syntax
<dwahl>
yeah
<dwahl>
i get it now, but thanks both of you.
Ven has quit [Disconnected by services]
<trapped_>
dwahl: gonna try what you proposed earlier
<trapped_>
went afk to get some oj
<trapped_>
does not work
Ven_ has joined #crystal-lang
mgarciaisaia1 has left #crystal-lang [#crystal-lang]
<trapped_>
still haven't managed to get it to work
luislavena has quit [Remote host closed the connection]
<trapped_>
cool
<jhass>
>> %(a handy quoteless string literal syntax is this)
<DeBot>
jhass: # => "a handy quoteless string literal syntax is this" - http://carc.in/#/r/8nj
* jhass
slaps DeBot
Ven_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<vifino>
Is there a way to download a file but abort if the received size is bigger than for example 5 megabyte?
<BlaXpirit>
maybe i could try to help, but i dont know how to download a file at all
<BlaXpirit>
vifino, probably not D:
<BlaXpirit>
not with HTTP::Client that is
<vifino>
D:
shama has joined #crystal-lang
Ven_ has joined #crystal-lang
<trapped_>
vifino: do you know if you can access the response headers before it finishes downloading
<vifino>
trapped_: If you mean the content length, yes. But that only prevents accidental stuff for the most part.
<trapped_>
if so, you could just spawn a thread for the Client, read the headers on the main thread, and, if it's too big, kill the thread
<trapped_>
thread/process/fiber
<trapped_>
depends on how crystal handles file descriptors and sockets i guess
<dwahl>
i've successfully read streams with the client
<dwahl>
it just opens a socket so you can read from the socket into a buffer
<dwahl>
i think
<dwahl>
you might want to subclass the client though
<BlaXpirit>
lol crul is a trivial command line interface for http::client
<BlaXpirit>
i hoped i would find something cool there
<asterite>
trapped_: on HEAD HTTP::Client supports body streaming, so you can do get with a block and then the response will have body_io set, and you can check the headers before reading the body
<fkchang>
jhass: so I was unable to get that websockethandler example you graciously provided to work yesterday. Any idea who might know how to do it? In it's stead is there a way to step debug, or the equivalent of monkey patching so I can try to debug the calls? Thanks
<jhass>
maybe asterite's still around
<jhass>
step debugging is still not really usable, we're mostly sticking to debug prints atm
<dwahl>
fkchang: inherit the class and copy and paste the source (or use previous_def (cant remember the exact syntax))
<jhass>
and yeah, crystal has an open class model, you can override anything any time
luislavena has joined #crystal-lang
<jhass>
you might also want to elaborate on what "doesn't work" means
dwahl has quit [Ping timeout: 246 seconds]
leafybasil has joined #crystal-lang
leafybasil has quit [Ping timeout: 252 seconds]
mgarciaisaia has joined #crystal-lang
NeverDie has quit [Quit: I'm off to sleep. ZZZzzz…]
dwahl has joined #crystal-lang
<fkchang>
jhass: I'll give monkey patching and printing a go
<fkchang>
jhass: by "doesn't work" it doesn't respond to the client connection, I can see code to handle the Upgrade request in the web socket handler code, so I know it's been coded for such, w/debug I can see the block gets called on the request, but I'm missing, what I'm guessing, is the right code in the block, so that the server doesnt' return 'Unhandled exception: end of file reached' on the server and "WebSocket connection to
<fkchang>
'ws://localhost:8081/' failed: Error during WebSocket handshake: 'Connection' header value is not 'Upgrade'" on the client. It's basically the same code as u originally supplied
<fkchang>
asterite: might know how it's supposed to work?
<jhass>
well, I never tried that code with an actual client, only guessed from reading sources
<adam12>
fkchang: I ran into this last night. The PR doesn't apply cleanly, but you can figure out where to add the changes, recompile, and all works.
<fkchang>
adam12: awesome, I'll give a shot.
Dreamer3 has quit [Read error: Connection reset by peer]
Dreamer3 has joined #crystal-lang
<adam12>
fkchang: Here's my echo server. I actually setup 'ws' as a getter as well. I'm not sure why it's not exposed. Without setting ws as a getter, you can use `ws_session.@ws.send` instead (instance var).
<adam12>
It's weird accessing an instance variable outside of the instance using the @ notation. I wonder if this is by design or bug?
<crystal-gh>
[crystal] porras opened pull request #1053: String#succ (master...String#succ) http://git.io/vY96E
<jhass>
adam12: it's by design but I hope it's one that won't last
<adam12>
jhass: agreed.
<jhass>
it's basically intended as a replacement for instance_variable_get and should be used similarly, if not even less often
<jhass>
in my example I just did it since there's no getter, though monkey patching one in would be better
<jhass>
or yet better monkey patch a proper API in
<adam12>
I can see the use cases. In this instance, WebSocketSession has a ws instance variable, which AFAIK is only way to write out the socket. Of course, with no getter, I had to use instance var, which led me down this rabbit hole.
<vifino>
How would I go ahead and make a temporary file?
<vifino>
I mean, I could use tmpnam, but I dunno if that's really a good idea..
dbackeus has quit [Remote host closed the connection]
<trapped_>
has anyone benchmarked crystal's network throughput?
dbackeus has joined #crystal-lang
dbackeus has quit [Ping timeout: 244 seconds]
<jhass>
vifino: there's Tempfile in stdlib
<vifino>
Awesome.
<jhass>
trapped_: not aware of anything, not published at least
<jhass>
some throw ab/wrk against a hello world HTTP::Server, but if anything that's burried in some issue comment :P
<jhass>
*threw
<vifino>
jhass: And how would I get the resulting directory back/where the file is?
<jhass>
File.dirname file.path
<vifino>
awesome.
leafybasil has joined #crystal-lang
NeverDie has joined #crystal-lang
havenn has joined #crystal-lang
havenwood has quit [Read error: Connection reset by peer]
havenn has quit [Read error: Connection reset by peer]
<fkchang>
adam12: have you gotten 'Unhandled exception: Invalid packet type' w/your echo server?
<adam12>
fkchang: I have not. I made a test webpage and worked good.
<fkchang>
adam12: I'm hitting w/this page, and I get a bad packet type: 8
<fkchang>
adam12: the jsbin works, I think it's because I close it, which is odd that OPOCODE_CLOSE is not handled
<adam12>
Very strange.
<fkchang>
that's it, commented out the websocket.close() in the js and no error. Now to figure out what to do with that. I'll submit a PR, once I know what the correct behavior should be
<adam12>
Good stuff.
Kilo`byte has quit [Ping timeout: 244 seconds]
<fkchang>
is there something to print out the call stack?
<fkchang>
oh, it's caller like in ruby
Kilo`byte has joined #crystal-lang
<dwahl>
most of the debuggy stuff is in the top level namespace part of the api