ChanServ changed the topic of #crystal-lang to: The Crystal programming language | | Fund Crystal's development: | GH: | Docs: | Gitter:
<SamantazFox_> Blacksmoke16: nice, thanks :)
<SamantazFox_> I'm not really familiar with includes, especially in modules ^^
<FromGitter> <Blacksmoke16> basically just using it so we can more easily get an array of the types we want
<SamantazFox_> mmh, I see
<FromGitter> <Blacksmoke16> other option would be to make the controllers a class/struct and use a parent type that you could do `all_subclasses` on
<SamantazFox_> as in `class BaseRoute; end; class MyRoute < BaseRoute; end`?
<FromGitter> <Blacksmoke16> essentially yea
<SamantazFox_> though, I was wondering what could be the performance impact of classes on a large codebase
<FromGitter> <Blacksmoke16> you'd never be instantiating them so prob not much diff than a module? :shrug:
<FromGitter> <Blacksmoke16> they're both equivalent so using the module approach is prob fine for now
<SamantazFox_> mmmh *nods*
<SamantazFox_> Also, what's that `{{debug}}` you used in your example?
<SamantazFox_> first time I'm seeing this!
<FromGitter> <Blacksmoke16> just so that it would print the generated code to stdout
<SamantazFox_> Damn, that's nice! Would have helped when I struggled with macros xD
<FromGitter> <Blacksmoke16> indeed :P super helpful
notzmv has quit [Read error: Connection reset by peer]
notzmv has joined #crystal-lang
greenbigfrog has quit [Ping timeout: 268 seconds]
greenbigfrog has joined #crystal-lang
notzmv has quit [Ping timeout: 252 seconds]
notzmv has joined #crystal-lang
walez has joined #crystal-lang
<FromGitter> <> hmm I'm having real difficulties coming purely from the fact that `STDOUT` is a constant although it doesn't have to be
<FromGitter> <Dan-Do> It seems I cannot subtract 2 arrays ⏎ ⏎ ```ary1 = [[2,3,4], [1,2,3]] ⏎ ary2 = [1,2,3] ⏎ pp! ary1 - ary2 # return ary1``` []
<FromGitter> <Dan-Do> Edit: I used it wrong. Should be `ary2 = [[1,2,3]]`
<FromGitter> <> yep, i straight up had to hack into the memory region that stores STDOUT ⏎
<yxhuvud> in Ruby there is both $stdout and STDOUT, where the difference is that one is the canonical stdout and one is possible to reassign. perhaps something similar would be a good idea?
<FromGitter> <paulocoghi> Has anyone successfully used on Linux?
<FromGitter> <paulocoghi> I can't run the simple examples, even after installing the required libs:
walez has quit [Quit: Leaving]
walez has joined #crystal-lang
notzmv has quit [Ping timeout: 252 seconds]
<FromGitter> <paulocoghi> Since the original library works normally on my machine (compilation and execution of the C, C++ and even Go versions), I will try to recreate the Crystal binding
<FromGitter> <> yxhuvud, it would certainly be a good idea, just that there are no globals
<yxhuvud> perhaps better to build an api for temporary replacement for the three std ios. It may be reasonable to have some minor specializations on those 3.
<FromGitter> <> yxhuvud, it would also hugely help to allow these to be any IO, not only FileDescriptor. almost all of the complexity is also due to that. ⏎ ⏎ >
<yxhuvud> well they can't be IO::Memory - they need to be backed by a file descriptor.
<FromGitter> <> yxhuvud, they can be IO anything which eventually calls to that FD-backed one
<FromGitter> <> not even necessarily, if you purely want to intercept it
<yxhuvud> well you'd need a pipe or whatever in between
<FromGitter> <> not for the stdout case
<FromGitter> <> it's all programmatic. any `write` call gets rewritten to a different `write` call and that's it
<FromGitter> <> and i know about pipes because i certainly needed them in this latest example
<yxhuvud> unless you want to keep it compatible wth c extensions or whatever, but yeah
<FromGitter> <> ah yea for stuff that directly accesses STDIN then you probably need `reopen` into a pipe
<FromGitter> <> but i think avoiding a pipe+fiber is a more worthy goal than catering to stuff that bypasses official interfaces
<yxhuvud> both would probably be nice to have. for example to redirect std output for a c extension to avoid spamming the terminal
notzmv has joined #crystal-lang
<SamantazFox_> Hello there! How can I force some method override to take over something else?
<FromGitter> <Blacksmoke16> define it after the one you want to override
<SamantazFox_> the problem is that I want to intercept an exception, but I'd like to not have a duplicate of the stdlib for a single line of code
<FromGitter> <Blacksmoke16> feels hacky to override stuff like this
<FromGitter> <Blacksmoke16> could you not use a `HTTP::Handler` for this?
<SamantazFox_> Idk, tbh
<SamantazFox_> I'm entirely open to suggestions!
<SamantazFox_> " You can use a handler to intercept any incoming request and can modify the response. These can be used for request throttling, ip-based filtering, adding custom headers e.g. <code>"
<SamantazFox_> Hmm, but when is it called?
<FromGitter> <Blacksmoke16> that would work, but also would globally silence both of those exceptions, even if they arent from that specific context in your PR
<FromGitter> <Blacksmoke16> whats the reason these exceptions are being thrown? would it be better to fix the root cause versus just hiding the issue?
<SamantazFox_> The root cause is simply the user aborting the page loading
<SamantazFox_> they reach `<domain>/some/path` and either click on a link or on the "Stop" button near the URL bar while the page is still loading.
<FromGitter> <Blacksmoke16> hmm
<SamantazFox_> Here's the issue about that problem ^
<SamantazFox_> That wouldn't be much of a problem if that didn't fill up the logs every time a user is impatient...
<FromGitter> <Blacksmoke16> could just silence the logs from stdlib http stuff
<FromGitter> <Blacksmoke16> based on, id be curious to see if you can reproduce on a simple endpoint or something
<SamantazFox_> it doesn't happen with a small payload (it's probably being buffered or something)
<SamantazFox_> (I've tried to delay the response as proposed here:, but the browser doesn't seem to time out for localhost)
<SamantazFox_> Yep, confirmed: Firefox and Vivaldi don't timeout on localhost.
avane has quit [Ping timeout: 268 seconds]
walez has quit [Read error: Connection reset by peer]
walez has joined #crystal-lang
ur5us has joined #crystal-lang
ur5us has quit [Ping timeout: 252 seconds]
avane has joined #crystal-lang
ur5us has joined #crystal-lang
<FromGitter> <Blacksmoke16> SamantazFox_: reproducible example would be super helpful id say
ur5us has quit [Ping timeout: 252 seconds]
walez has quit [Ping timeout: 256 seconds]