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
<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
<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.
<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>
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
<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…]
<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
<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