Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 16:20
    HertzDevil unlabeled #13013
  • 14:24
    renovate[bot] edited #12735
  • 14:22
    straight-shoota milestoned #13048
  • 14:22
    straight-shoota milestoned #13048
  • 13:24
    HertzDevil labeled #13048
  • 13:24
    HertzDevil labeled #13048
  • 13:24
    HertzDevil labeled #13048
  • 13:24
    HertzDevil opened #13048
  • 12:32
    straight-shoota closed #12924
  • 12:32
    straight-shoota closed #12921
  • 12:31
    straight-shoota closed #12983
  • 12:24
    straight-shoota closed #13045
  • Feb 05 15:55
    Blacksmoke16 closed #13047
  • Feb 05 15:53
    serge-hulne closed #13047
  • Feb 05 15:45
    Blacksmoke16 edited #13047
  • Feb 05 15:42
    serge-hulne labeled #13047
  • Feb 05 15:42
    serge-hulne opened #13047
  • Feb 05 02:16
    renovate[bot] edited #12735
  • Feb 04 23:27
    straight-shoota milestoned #12966
  • Feb 04 23:27
    straight-shoota milestoned #12966
George Dietrich
@Blacksmoke16
From IRC (bridge bot)
@FromIRC
<straight-shoota> There is no way to access either body or body_io. They're mutually exclusive
<SamantazFox> That's something I'd expect, yeah, but why body is always the full body, as a String and body_io is that same body as IO, but Nil on Docker?
<straight-shoota> Sorry what has Docker to do with this?
<SamantazFox> I'm trying to figure that out, actually.
<SamantazFox> For context, I've made this code, to prevent an issue from happenning: https://github.com/iv-org/invidious/pull/2623/files
<SamantazFox> Said issue is: "body is sometimes decompressed, sometimes not"
From IRC (bridge bot)
@FromIRC
<SamantazFox> So, I've set "Content-Encoding" to "gzip, deflate" to disable HTTP::Client's auto-decompression, and added the required logic to decompress the body by myself
<SamantazFox> problem is that when deployed on bare-metal, it works fine, and on Docker, we're getting this: iv-org/invidious#2632
George Dietrich
@Blacksmoke16
i mean is it not possible you're doing like HTTP::Client.get "..." then trying to access body_io on it?
From IRC (bridge bot)
@FromIRC
<SamantazFox> response.body_io, yes.
George Dietrich
@Blacksmoke16
response = HTTP::Client.get("...")
response.body # okay
response.body_io # not okay

HTTP::Client.get("...") do |response|
  response.body # not okay
  response.body_io # okay
end
From IRC (bridge bot)
@FromIRC
<SamantazFox> Why is it "not okay"?
<SamantazFox> oops, wrong link
<SamantazFox> better
George Dietrich
@Blacksmoke16
because body_io is only set in the context of using the block overload, so body wouldnt be set
while if you used the non block overload body is set and body_io is not
by "not okay" meaning it'll raise saying it shouldn't be nil
if you try to use it in not the right context
From IRC (bridge bot)
@FromIRC
<SamantazFox> Oh, I misunderstood the code snippet you provided
<SamantazFox> Ok, I get it now.
<SamantazFox> Why isn't that mentionned in the API doc?!
George Dietrich
@Blacksmoke16
From IRC (bridge bot)
@FromIRC
<SamantazFox> Ok, thanks y'all
<SamantazFox> Now, I'm wondering why it works sometimes, and not others.
<SamantazFox> And of course impàlement that properly
From IRC (bridge bot)
@FromIRC
<SamantazFox> What's the most recommended? Foo::Bar.echo or Toto::Foo::Bar.echo
George Dietrich
@Blacksmoke16
probably doesnt really matter, could argue the former since its shorter, or the latter because its more clear what specific type it points to
j8r
@jrei:matrix.org
[m]
In rare cases you have no choice of the latter if the stdlib uses the same name
From IRC (bridge bot)
@FromIRC
<SamantazFox> mmmh, okay, thanks :⁠)
Paulo Coghi
@paulocoghi
@naqvis Wow!
Ali Naqvi
@naqvis
:+1:
From IRC (bridge bot)
@FromIRC
<spuun> I have a MetaVar (from @type.instance_vars) which i know is a Hash, but i want to get the key and value types. How? I want to go from the MetaVar to a HashLiteral, I think?
From IRC (bridge bot)
@FromIRC
<spuun> type.type_vars is enough
George Dietrich
@Blacksmoke16
:thumbsup:
Paulo Coghi
@paulocoghi
newbie question: Is it possible to dynamically call an instance method, passing the instance variable name by string?
George Dietrich
@Blacksmoke16
not built in, but it's technically possible to re-create
there is no#send like in Ruby, but id consider redesigning it so you dont need to do that?
Max Fierke
@maxfierke
https://github.com/wyhaines/Send.cr is one such approach to dynamic dispatch in Crystal
Paulo Coghi
@paulocoghi
I am implementing this concept in Crystal (from FeathersJS framework):
hook-flow-3-service.jpg
A library where you can "register" services (that is, class instances) with defined "expected" methods
The main library allow the "registration" of one or more instances
The classes are created by the developer, which must have one or more methods (from the expected ones)
And the library is responsible to (automatically) expose each service on the desired protocol, like a REST API, or Socket, etc
Max Fierke
@maxfierke
one option would be to use the macro finished hook on the base class to collect all the registered sub-classes and do what you need to there