Guest65 has joined #ruby
rem has quit [Quit: rem]
lfalcao has joined #ruby
Guest65 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bastienleonard has quit [Ping timeout: 272 seconds]
tree has joined #ruby
Garb00 has joined #ruby
Garb0 has quit [Ping timeout: 272 seconds]
arestifo has joined #ruby
arestifo has quit [Client Quit]
Garb00 has quit [Quit: Garb00]
lunarkitty has quit [Quit: Connection closed for inactivity]
gfawcett has quit [Quit: The Lounge - https://thelounge.chat]
gfawcett has joined #ruby
Guest65 has joined #ruby
Guest5430 has joined #ruby
seabre has quit [Ping timeout: 245 seconds]
seabre has joined #ruby
zodeishi has quit [Ping timeout: 268 seconds]
gr33n7007h has quit [Quit: WeeChat 3.1]
gr33n7007h has joined #ruby
Guest5430 has quit [Ping timeout: 250 seconds]
lfalcao has quit [Ping timeout: 264 seconds]
arestifo has joined #ruby
Guest65 has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Bounga has joined #ruby
jinie has quit [Quit: ZNC 1.8.2 - https://znc.in]
gearnode has joined #ruby
jinie has joined #ruby
lunarkitty has joined #ruby
Garb0 has joined #ruby
arestifo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
bastienleonard has joined #ruby
bastienleonard has quit [Client Quit]
smurfke_ has joined #ruby
lunarkitty has quit [Quit: Connection closed for inactivity]
rapha has joined #ruby
<rapha> hi all
<rapha> does anyone of a pure-ruby (i.e. not RMagick) way of rendering some text with a specific font at a specific size into a newly-created PNG?
smurfke_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<jhass> chunky_png can give you pure ruby way to turn an RGBA buffer into PNG, but I doubt somebody went through the trouble of implementing a full font rendering stack
zodeishi has joined #ruby
royo25 has joined #ruby
Cata has joined #ruby
Garb0 has quit [Quit: Garb0]
<rapha> jhass: Yes, the author specifically precluded that possibility as it's out-of-scope.
<rapha> Well, okay then, back to RMagick and into the fray once more!
<jhass[m]> there's also the other one that shells out
Cata has quit [Quit: Leaving]
Garb0 has joined #ruby
arestifo has joined #ruby
Oblomov has joined #ruby
<Oblomov> hello all again. I'm having a weird situation with our daemonization code. we redirect $std{in,out,err} to /dev/null, override the .write(*args) method, but for some reason we're still getting interpreter warnings to stderr
Cata has joined #ruby
<Oblomov> instead of into the logfiles to which they should be directe from the overridden write() methods
Garb0 has quit [Ping timeout: 272 seconds]
Garb0 has joined #ruby
<adam12> Oblomov: Obvious question, but is there any chance the warnings are firing before the redirection happens?
<adam12> Oblomov: And what do you mean overwrite `.write(*args)`? of what object?
<wnd> I'm looking at a PR with "foo = some_var.map { |i| i[:field] }.uniq || [] # could be nil", where "|| []" is the changed/added part. AFAIK, "|| []" cannot possibly do anything meaningful. Unless I'm mistaken, the left side will either return an Array or raise an exception. The author insists a nil has been returned. Assuming some_var#map returns a standard Array, under what circumstances could this chain return nil?
<Oblomov> adam12: the warnings are firing after the redirection without any doubts (the command that triggers them is issued after the bot has joined on irc, which is done after the redirection)
<Oblomov> adam12: $stderr.write and $stdout.write
<jhass> you're self-deamonizing an IRC bot? but why
<Oblomov> adam12: but doing it on STDOUT and STDERR doesn't make any difference. we reopen them as /dev/null anyway
<Oblomov> jhass: “why not”
<wnd> I would get this if safe navigation was used. It isn't.
<jhass> because supervisors can do that job so much better than you ever could
<Oblomov> jhass: I'm allergic to supervisors ;-)
<jhass> wnd: I don't see any either
<adam12> wnd: It definitely only returns an Array. I can’t see `|| []` being of any use there at all.
<wnd> Thanks. It's not just me then.
<jhass> I mean there's always the possibility that some_var is not an array in the first place and thus map is not Array#map, or somebody overwrote Array#uniq, but nothing to expect
<adam12> Oblomov: What version of Ruby? Can you make a small reproducible example? Did you re-open $stderr after forking?
<Oblomov> adam12: I've tried both after and before, the issue is still present. I'll try building a small repro
<Oblomov> s/still present/present either way/
<adam12> forking with a $stderr of /dev/null definitely silences warnings for me… so I’m not sure.
<adam12> Oblomov: What was the interpreter warning by chance?
<Oblomov> adam12: bah just a bunch of warnings from reloading the plugins. stuff that we expect to be there anyway
<adam12> Oblomov: Like Constant already defined?
<Oblomov> well, “there” should be the log, not stderr, but you get the idea 8-)
<Oblomov> adam12: yes
<adam12> I wonder if you can silence those. They might be happening before evaluation. Hmm.
<Oblomov> adam12: but as I said, my issue isn't that the warnings are there, it's that the warnings aren't being redirected
<Oblomov> adam12: they definitely rehappen wheneve I do a rescan
<Oblomov> but as I said, I'm ok with the warnings being emitted
Garb0 has quit [Quit: Garb0]
<adam12> Yeah. It’s a mystery. This works as expected. ruby -w -e '$stderr = File.open("/dev/null"); Foo = true; Foo = false'
<Oblomov> adam12: yeah, I've also tried some longer stuff
<Oblomov> it works
<rapha> jhass: "shells out"? against whom?
<rapha> oooooooooooooh
<Oblomov> I'm trying to build a minimal
<rapha> as in, to call the shell. nm.
<jhass> sorry :D
<rapha> oh!
<rapha> "I was using RMagick and loving it, but it was eating up huge amounts of memory. Even a simple script would use over 100MB of RAM. On my local machine this wasn't a problem, but on my hosting server the ruby apps would crash because of their 100MB memory limit"
<rapha> already <3'ing it, thank you, jhass
<nakilon> I thought it was a known fact since at least 2000 that imagemagick is a leaking shit
<adam12> Oblomov: Maybe try overwriting `<<`
<rapha> nakilon: yes, but if there's no alternative then there's no alternative.
<nakilon> use vips
<adam12> Oblomov: ruby -w -rstringio -e '$stderr = StringIO.new; def $stderr.<<(*); raise; end; Foo = true; Foo = false; pp $stderr.string'
<nakilon> and ruby-vips
<adam12> Oblomov: Actually, that’s a bad example.
<jhass> vips has the worst C api ever, at least in terms of writing bindings for it
<adam12> Not enough coffee yet, apparently.
<jhass> uses gobject but then re-invents and sidesteps all of it
<Oblomov> adam12: yeah, I'm thinking the interpreter might not be using write()
<nakilon> jhass I'm pretty sure John would love to hear if you have ideas of what's wrong with ruby-vips
<rapha> jhass: hmm i think nakilon has a point though as what i want to do seems to be the simple one-liner of `text = Vips::Image.text 'Hello world!', font: 'sans 120', width: image.width - 100`
<jhass> not talking about ruby-vips but libvips itself
<nakilon> and does rapha need writing own bindings?
<Oblomov> adam12: but still, the reopening as /dev/null should at least silence them
<rapha> nope :)
<Oblomov> adam12: ruby -w -e 'HS=4; $stderr.reopen("/dev/null") ; exit if fork ; exit if fork; def $stderr.write(*args) ; return $1stdout.write(*args) ; end; HS=4'
<adam12> Oblomov: Before loading, can you see what $stderr is?
<jhass> just had to get rid of some frustration, sorry. I hope you can empathize nakilon :P
<Oblomov> adam12: I can check
<jhass> I just can't get beyond that stupid vaargs everywhere API
<nakilon> you probably can even execute that onliner as a single vips binary call without even using ruby-vips
<Oblomov> adam12: but see the above oneliner: I would expect it to print the warning on stdout, but it doesn't
<Oblomov> adam12: before the shenanigangs $stderr and $stdio are the expected #<IO:<STDERR>> and STDOUT
<nakilon> if you want to put text with transparency onto an image you'll need a bit more code, some dancing around layers
<nakilon> but snippets are pretty easily findable in github issues
<nakilon> (example result of using ruby-vips to put texts onto image: https://i.imgur.com/er62CS2.png)
<rapha> nakilon: nono, just 100% opaque white background and the ability to place at x and y offset and with specific font and size is enough. that seems to mostly be covered by the LOC above.
<nakilon> also you might want to google some env vars and ruby-vips options to reduce memory consumption even more -- those are some GC tweaks
<rapha> and i love your example image :)
<rapha> the dev machine has 48GB of RAM so for the time being i'm good
<adam12> Oblomov: Yeah. Interesting stuff.
<rapha> (whatever the fuck a "pseudodog" is ... sounds like something out of a tchernobyl video game)
<nakilon> yes it is
chonkbit has joined #ruby
<nakilon> used ruby to process the game files and generate different kinds of all locations of the game
<nakilon> *kinds of maps of
<adam12> Oblomov: I wonder if Ruby 2.5 has the same issue.
<Oblomov> I'm on 2.7 fwiw
Garb0 has joined #ruby
<Oblomov> oh damnit
<Oblomov> no wait
<Oblomov> that's for ruby 3
<adam12> It’s part of the 2.6 preview I thought. I didn’t look too close.
<adam12> But writing directly to the fd makes .. some sense?
<Oblomov> ah sorry, I may be reading github wrong
<Oblomov> adam12: also, with a reopen of $stderr to /dev/null in the oneline it ... sort of works
<Oblomov> and it should escape that path, because it's not the original one anymore ...
<Oblomov> is there something like godbolt for ruby? 8-D
<Oblomov> like a webpage where you can run oneliners for specific, different versions of ruby
<adam12> carc.in ?
<havenwood> Oblomov: You can look at the intermediary instructions with RubyVM::InstructionSequence.
<adam12> You can get them through `ruby` too.
<havenwood> >> RubyVM::InstructionSequence.compile('42 + 1').to_a.last
<ruby[bot]> havenwood: # => [1, :RUBY_EVENT_LINE, [:putobject, 42], [:putobject_INT2FIX_1_], [:opt_plus, {:mid=>:+, :flag=>16, : ...check link for more (https://carc.in/#/r/b9yl)
<nakilon> docker run --rm -ti ruby:3.0-alpine
<havenwood> >> require 'ripper'; Ripper.sexp '42 + 1'
<ruby[bot]> havenwood: # => [:program, [[:binary, [:@int, "42", [1, 0]], :+, [:@int, "1", [1, 5]]]]] (https://carc.in/#/r/b9yn)
<adam12> Not sure about C stuff tho.
<Oblomov> ruby -w -e 'HS=4; $stderr.reopen("/dev/null") ; exit if fork ; exit if fork; def $stderr.write(*args) ; return $stdout.write(*args) ; end; HS=4'
<Oblomov> wrong window sorry
<Oblomov> oh but wait ruby[bot] can handle these things?
<Oblomov> >> HS=4; $stderr.reopen("/dev/null") ; exit if fork ; exit if fork; def $stderr.write(*args) ; return $stdout.write(*args) ; end; HS=4
<ruby[bot]> Oblomov: # => (https://carc.in/#/r/b9yo)
<jhass[m]> just use it for demo though please, not for trial :)
<havenwood> >> File::NULL
<ruby[bot]> havenwood: # => "/dev/null" (https://carc.in/#/r/b9yp)
<Oblomov> jhass[m]: sorry 8-)
<Oblomov> jhass[m]: but can I ask for a different ruby version?
<jhass[m]> 27>> "sure"
<ruby[bot]> jhass[m]: # => "sure" (https://carc.in/#/r/b9yq)
<nakilon> jhass[m] remind me how is carc.in sandboxing?
<jhass[m]> feel free to use carc.in behind for experimentation, it's just about not spamming the channel
<nakilon> maybe I'll make a ruby repl in my bot too
<Oblomov> ah
<Oblomov> 25>> HS=4; $stderr.reopen("/dev/null") ; exit if fork ; exit if fork; def $stderr.write(*args) ; return $stdout.write(*args) ; end; HS=4
<jhass[m]> nakilon: outdated way: https://github.com/thestinger/playpen
<ruby[bot]> Oblomov: # => playpen: timeout triggered! (https://carc.in/#/r/b9yr)
<Oblomov> wut
<jhass[m]> I need to rebuild it but every alternative is so complicated
<jhass[m]> Oblomov: less frequently used stuff might take too long the first time, just retry
<jhass[m]> it's not exactly an oversized box :P
<Oblomov> possibly in query with the bot? 8-D
<jhass[m]> just use the website?
<nakilon> jhass[m] oh ( I need just something that would block the sockets -- the rest would be sandboxes/limited by cloud run options
<Oblomov> jhass[m]: oh right
<jhass[m]> nakilon: systemd should have an option for that somewhere
<Oblomov> no output in 2.5 either though
<jhass[m]> it can do some of the resource limiting better than playpen can, so I rely on it too
<Oblomov> adam12: so I guess that kind of busts the commit idea
<Oblomov> oh wait I know what's going on maybe
<Oblomov> and I'm an idiot
<nakilon> actually I could start docker inside the serverless runner, lol, sounds like overkill though but should be safe
<jhass[m]> nakilon: https://github.com/containers/bubblewrap would be the more low level and thus lightweight variant for that
<jhass[m]> the nice thing of playpen is that I can make a list of "what should work" examples and use it to train the syscall filter
<Oblomov> adam12: OK, just in case you want to know: the issue was that on daemonization we closed the console logger, which caused STDERR to be closed and then reopened by the interpreter for its own stuff
<jhass[m]> none of the other solutions support anything like it
<Oblomov> thanks again for the rubberducking, but I still think there's something weir with the way warnings behave
<Oblomov> even if it's fixed on my side of things 8-)
lfalcao has joined #ruby
<adam12> Oblomov: Interesting. Thanks for letting me know.
Bounga has quit [Read error: Connection reset by peer]
Bounga- has joined #ruby
Garb0 has quit [Ping timeout: 264 seconds]
Garb0 has joined #ruby
weaksauce has joined #ruby
lfalcao has quit [Ping timeout: 245 seconds]
Bounga- has quit [Ping timeout: 245 seconds]
Bounga has joined #ruby
reset has quit [Quit: reset]
weaksauce has quit [Ping timeout: 252 seconds]
gothprincess has joined #ruby
royo25 has quit [Quit: Bye]
jhass[m] has quit [Quit: node-irc says goodbye]
arestifo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
jhass[m] has joined #ruby
arestifo has joined #ruby
arestifo has quit [Client Quit]
Guest65 has joined #ruby
Guest65 has quit [Client Quit]
Guest65 has joined #ruby
lfalcao has joined #ruby
Guest65 has quit [Ping timeout: 272 seconds]
<gothprincess> Hi, can someone please clarify how do `do-blocks` work with closures and identifiers work, i.e, here: https://github.com/tootsuite/mastodon/blob/main/config/initializers/devise.rb#L82
<gothprincess> I'm confused about the left hand value: does do block bind a variable? Does it somehow dispatch something? My first day with ruby, so please be patient with me haha
Bounga has quit [Ping timeout: 245 seconds]
<leftylink> to cause `config` to be bound, it must be the case that tht eimplementation of `Devise.setup` at some point does `yield x`, in which case `config` will be `x`
<gothprincess> leftylink: aha, so I need to find Devise.setup? module Devise is defined just some lines above, but there's no `setup` there…
<gothprincess> Maybe modules in Ruby are namespaces into which any source file can append?..
<leftylink> failing that, the documentation of Devise.setup may advise its user on what value is yielded to the block
<gothprincess> leftylink: ah, it's a library function?
gr33n7007h has quit [Ping timeout: 272 seconds]
<adam12> gothprincess: Any method in Ruby will accept a block. They don’t have to do anything with the block tho.
<leftylink> the Gemfile and Gemfile.lock which would typically be located at the root of a repo will indicate what gems this repo depends on
Oblomov has left #ruby [Never try an explanation of what comes naturally (The wee Kirkcudbright centipede)]
jidar has joined #ruby
weaksauce has joined #ruby
Garb0 has quit [Ping timeout: 245 seconds]
arestifo has joined #ruby
Garb0 has joined #ruby
RougeR has joined #ruby
arestifo has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
RougeR has quit [Quit: Leaving]
smurfke_ has joined #ruby
weyhmueller has quit [Quit: ZNC 1.8.2 - https://znc.in]
havenwood has quit [Quit: The Lounge - https://thelounge.chat]
weyhmueller has joined #ruby
havenwood has joined #ruby
lfalcao has quit [Ping timeout: 264 seconds]
lfalcao has joined #ruby
<gothprincess> adam12: thanks! I'm guessing that this article then is the most relevant bit I need to understand to absorb the paradigm of parametric functions with yields and blocks: https://medium.com/rubycademy/the-yield-keyword-603a850b8921
<havenwood> gothprincess: It's rare to see "class variables" with the @@ these days since they're disfavored in modern Ruby.
<havenwood> gothprincess: It's common to see the ampersand, which designates a block argument here.
<weaksauce> dang devise has a lot of globals
<weaksauce> that is indeed surprising
<weaksauce> er s/globals/class variables
<gothprincess> weaksauce: yeah, I've caracterised them as global variables too )
<weaksauce> hehed
<weaksauce> class globals
<gothprincess> classy
smurfke_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
sweater2 has joined #ruby
smurfke_ has joined #ruby
<sweater2> Speaking of devise! Is there a dedicated channel for devise / warden?
<weaksauce> gonna go with a big doubt on that but maybe something on discord?
lfalcao has quit [Ping timeout: 245 seconds]
chonkbit has quit [Ping timeout: 264 seconds]
arestifo has joined #ruby
arestifo has quit [Client Quit]
Cata has quit [Quit: Leaving]
Garb0 has quit [Ping timeout: 264 seconds]
Garb0 has joined #ruby
Garb0 has quit [Quit: Garb0]
lunarkitty has joined #ruby
lfalcao has joined #ruby
gearnode has quit [Ping timeout: 244 seconds]
Garb0 has joined #ruby
Garb0 has quit [Client Quit]
reset has joined #ruby
pwnd_sfw has joined #ruby
gearnode has joined #ruby
Garb0 has joined #ruby
Garb0 has quit [Changing host]
Garb0 has joined #ruby
Garb0 has quit [Client Quit]
Garb0 has joined #ruby
lfalcao has quit [Ping timeout: 245 seconds]
reset has quit [Quit: reset]