havenwood changed the topic of #ruby to: Rules: https://ruby-community.com | Ruby 2.7.2, 2.6.6, 3.0.0-preview1: https://www.ruby-lang.org | Paste 4+ lines of text to https://dpaste.org | Books: https://goo.gl/wpGhoQ | Logs: https://irclog.whitequark.org/ruby | BLM <3 | Can't talk? Register/identify with NickServ
<al2o3-cr> neshpion: pry's default pager is less with a few options. check Pry::Pager::SystemPager.default_pager
ruurd has quit [Remote host closed the connection]
<al2o3-cr> specifically -R option.
ur5us has quit [Ping timeout: 246 seconds]
dionysus69 has quit [Ping timeout: 265 seconds]
ruurd has joined #ruby
silverdust has quit [Ping timeout: 240 seconds]
akem has joined #ruby
ur5us has joined #ruby
silverdust has joined #ruby
ruurd has quit [Read error: Connection reset by peer]
ruurd has joined #ruby
ruurd has quit [Quit: bye folks]
cthulchu_ has joined #ruby
adu has quit [Quit: adu]
ruurd has joined #ruby
BSaboia has quit [Quit: This computer has gone to sleep]
RickHull has joined #ruby
bromps has quit [Quit: WeeChat 2.3]
<neshpion> al2o3-cr: nice. i almost confused myself by checking that variable with PAGER still set... but unsetting PAGER showed me that it then defaults to `less -R -F -X`, options which i've now stolen for my own default :D
coniptor has quit [Ping timeout: 265 seconds]
alexherbo2 has quit [Ping timeout: 268 seconds]
<mjacob> the general recommendation for organizing files in a project (e.g. a gem) seems that there should be one file per class and one folder per module ("namespace"), with the names converted to snake_case.
SeepingN has joined #ruby
<mjacob> but what's the recommended way to require the files within a gem and make the classes available to users of the gem?
<mjacob> i've seen examples where lib/gem.rb defines only the module Gem. i've seen examples where every file lib/gem/*.rb was required from lib/gem.rb (sometimes inside the "module Gem" scope, sometimes outside).
<RickHull> mjacob: I don't strictly map the filesystem to the class/module hierarchy. it's good to make it sensible/predictable
<RickHull> I am a big fan of "require structure" where each .rb file requires what it needs to function -- i.e. so the file can be required "naked" in irb, and its tests pass
<RickHull> each.rb file requires what it needs -- and no more
coniptor has joined #ruby
<RickHull> there is another view that says lib/foo_project.rb should require "all the things" at the top, even if foo_project.rb itself doesn't need everything
<RickHull> in my mind, that creates unnecessary require churn, where things are required that might not be needed in the current execution context
<mjacob> what do you think about using zeitwerk?
<RickHull> never used/heard of it. but I've been away for a while
<mjacob> i can see how both ways have pros and cons. within my code i could pick any. but what would a user of my gem expect?
adu has joined #ruby
<RickHull> one thing that is tricky -- when you're developing your gem, make sure to use e.g. `ruby -Ilib path/to/script.rb`
<RickHull> that is: include the current lib dir (e.g. /home/user/project/lib/foo-project.rb) so that your `require 'foo-project.rb'` can be resolved, without having the foo-project gem installed
<RickHull> or e.g. `ruby -Ilib test/foo-project.rb`
<RickHull> or e.g. `irb -Ilib` `>> require 'foo-project'`
<RickHull> lots of people get tripped up trying to use require-relative unnecessarily
silverdust has quit [Ping timeout: 240 seconds]
<RickHull> mjacob: I unequivocally recommend structuring your requires properly. That is, any symbol or name used in a given .rb file should require whatever file defines that symbol or name
<RickHull> method / class / module / whatever
silverdust has joined #ruby
<mjacob> with python, i can install packages in "editable" mode, such that the list of installed packages has a link to my source directory. is there something like this in ruby?
<RickHull> mjacob: not that I'm aware of. use `-I path/to/lib` so that you can resolve your libs
<RickHull> also, keep in mind that my view is kind of an old school one. there may be newer tools that hide this stuff. but I still suspect my way is better, particularly for gem development
silverdust has quit [Ping timeout: 264 seconds]
<RickHull> in particular, be aware that I try to avoid using Bundler. it's a great tool when it's needed, but it sometimes complicates things unnecessarily IMHO. again, I'm probably out of date
<mjacob> RickHull: thanks for introducing me into your way of doing things! ;)
<mjacob> i'm open to hearing an opposing view and forming my own opinion
adu has quit [Quit: adu]
<RickHull> I have lots of ruby repos that consist of what I consider clean code, and most of them are packaged as gems. I'm happy to answer any questions. but I'm using webchat for the moment until I get a more permanent IRC presence going
SeepingN has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
leah2 has quit [Ping timeout: 264 seconds]
<RickHull> Notice e.g. https://github.com/rickhull/compsci/blob/master/lib/compsci.rb if you just `require 'compsci'` then you're just going to get a helper function. I expect scripts and other users to e.g. `require 'compsci/node'` or w/e
<RickHull> oh man, bad example. it looks like I'm only using that helper function in test/ -- I was trying to find an example of a file in lib/ that actually did `require 'compsci'`
swaggboi has quit [Quit: C-x C-c]
adu has joined #ruby
silverdust has joined #ruby
silverdust has quit [Ping timeout: 264 seconds]
cthulchu_ has quit [Ping timeout: 240 seconds]
swaggboi has joined #ruby
Xeago has quit [Ping timeout: 264 seconds]
burgestrand has joined #ruby
Xeago has joined #ruby
burgestrand has quit [Ping timeout: 264 seconds]
Xeago has quit [Ping timeout: 260 seconds]
Xeago has joined #ruby
ivzhh has quit [Remote host closed the connection]
davispuh has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
ivzhh has joined #ruby
SeepingN has joined #ruby
RickHull has quit [Ping timeout: 245 seconds]
envex has joined #ruby
meinside has joined #ruby
ChmEarl has quit [Quit: Leaving]
cd has quit [Quit: cd]
ChmEarl has joined #ruby
zacts has joined #ruby
ivzhh has quit [Remote host closed the connection]
SeepingN has quit [Quit: The system is going down for reboot NOW!]
ivzhh has joined #ruby
ivzhh has quit [Remote host closed the connection]
ur5us has quit [Ping timeout: 272 seconds]
ivzhh has joined #ruby
ivzhh has quit [Remote host closed the connection]
ivzhh has joined #ruby
iamgr00t has quit [Quit: afk]
iamgr00t has joined #ruby
chouhoulis has quit [Remote host closed the connection]
desnudopenguino has joined #ruby
ivzhh has quit [Remote host closed the connection]
ivzhh has joined #ruby
pinkpandabot has quit [Quit: accidentally deleted api key...]
bocaneri is now known as Sauvin
<desnudopenguino> i'm starting a journey down writing a wrapper using FFI, and i'm not very familiar with C, in the structs in the C file i'm looking at, anyone in here have any experience going down this path, and have any suggestions for stuff to read or research?
<desnudopenguino> wow, my brain totally skipped over a huge chunk of that, in the structs i'm looking at, there are a bunch of types that aren't in the types documentation for ffi, so i'm kind of hung up on what to do with that.
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
ChmEarl has quit [Quit: Leaving]
neshpion has quit [Quit: WeeChat 2.9]
adu has quit [Quit: adu]
ua has quit [Ping timeout: 264 seconds]
Glumetu has joined #ruby
tsujp69 has joined #ruby
<tsujp69> so, gemset vs gemfile
<tsujp69> Why do some people still cling to gemsets with RVM isn't bundler's Gemfile quite literally a project-level gemset equivalent?
burgestrand has joined #ruby
Inoperable has quit [Excess Flood]
leah2 has joined #ruby
Inoperable has joined #ruby
ua has joined #ruby
elcontrastador has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
StarOnD has joined #ruby
zacts has quit [Quit: leaving]
Inoperable has quit [Excess Flood]
envex has quit []
Neozor has joined #ruby
Inoperable has joined #ruby
TomyWork has joined #ruby
BSaboia has joined #ruby
ua has quit [Quit: Leaving]
ua has joined #ruby
akem has quit [Quit: Leaving]
Neozor has left #ruby [#ruby]
silverdust has joined #ruby
zacts has joined #ruby
<jhass> yeah, I've been arguing for years that a bundle --path vendor/bundle is functionally equivalent to gemsets for 99% of usecases
<jhass> I guess it's changing habits :)
silverdust has quit [Ping timeout: 256 seconds]
imode has quit [Ping timeout: 246 seconds]
ap4y has quit [Ping timeout: 240 seconds]
dionysus69 has joined #ruby
alexherbo2 has joined #ruby
gray_-_wolf has quit [Read error: Connection reset by peer]
bamdad has quit [Ping timeout: 240 seconds]
bamdad has joined #ruby
BSaboia has quit [Quit: This computer has gone to sleep]
silverdust has joined #ruby
zacts has quit [Quit: leaving]
zacts has joined #ruby
AndreYuhai has joined #ruby
<AndreYuhai> Hey there, It's been a while!
<AndreYuhai> I've got a csv file which is around 18 MB. I load it using CSV.read but then how can I destroy this so that it doesn't take up as much memory anymore?
<AndreYuhai> Would making it nil be sufficient?
AndreYuhai has quit [Remote host closed the connection]
AndreYuhai has joined #ruby
StarOnD has quit [Ping timeout: 245 seconds]
bamdad has quit [Ping timeout: 240 seconds]
cd has joined #ruby
tosaraja has quit [Quit: http://quassel-irc.org - Chat comfortably. Anywhere.]
akem has joined #ruby
<jhass> AndreYuhai: do you really need to keep it in memory? Consider streaming via CSV.open / CSV.new
<AndreYuhai> jhass, What I want to is to read different ranges of this CSV so I can run multiple scripts with different ranges
<jhass> Ruby's GC is not giving memory it allocated back to the system aggressively. Obtaining memory from the system is quite the slow of an operation, so it's more performant this way. But it means that externally obersable memory usage might not equal actual live usage
<AndreYuhai> jhass, So using CSV.open is the way to go?
<jhass> not sure for your usecase exactly, it's the way to go for sequentially processing large amounts
<jhass> but if you need to seek around it gets hairy
<jhass> you might just have to live with the high memory usage. If it's a long running process I'd look into launching the task as a subprocess
<AndreYuhai> jhass, Oh alright, thank you! I will probably keep reading all of it as you said.
ruurd has quit [Quit: bye folks]
lucasb has joined #ruby
ruurd has joined #ruby
silverdust has quit [Ping timeout: 265 seconds]
silverdust has joined #ruby
braincrash has joined #ruby
silverdust has quit [Ping timeout: 256 seconds]
Rudd0 has quit [Ping timeout: 258 seconds]
burgestrand has quit [Quit: burgestrand]
TCZ has joined #ruby
braincrash has quit [Ping timeout: 272 seconds]
bamdad has joined #ruby
bamdad has quit [Remote host closed the connection]
bamdad has joined #ruby
BSaboia has joined #ruby
AndreYuhai has quit [Quit: Leaving]
bmurt has joined #ruby
weaksauce has quit [Ping timeout: 265 seconds]
Xiti` has joined #ruby
Xiti has quit [Ping timeout: 258 seconds]
burgestrand has joined #ruby
braincrash has joined #ruby
silverdust has joined #ruby
queip has quit [Remote host closed the connection]
queip has joined #ruby
TCZ has quit [Quit: Leaving]
orbyt_ has joined #ruby
orbyt_ has quit [Client Quit]
zacts has quit [Quit: leaving]
chouhoulis has joined #ruby
chouhoulis has quit [Ping timeout: 272 seconds]
chouhoulis has joined #ruby
jokester has quit [Quit: WeeChat 2.8]
zacts has joined #ruby
chouhoulis has quit [Quit: Leaving...]
chouhoulis has joined #ruby
akem has quit [Quit: Leaving]
ChmEarl has joined #ruby
silverdust has quit [Quit: Lost terminal]
stan has quit [Quit: Idle for 30+ days]
Rudd0 has joined #ruby
akem has joined #ruby
_aeris_ has quit [Remote host closed the connection]
_aeris_ has joined #ruby
cloud69 has joined #ruby
Glumetu has quit [Quit: Glumetu]
ellcs has joined #ruby
adu has joined #ruby
cthulchu_ has joined #ruby
budonyc has joined #ruby
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
elcontrastador has joined #ruby
zacts has quit [Quit: leaving]
ivzhh has quit [Remote host closed the connection]
ivzhh has joined #ruby
braincrash has quit [Ping timeout: 264 seconds]
crankharder has joined #ruby
zacts has joined #ruby
kindwindfall__ has quit [Ping timeout: 264 seconds]
<nakilon> there was some memory leak in CSV but I don't remember what was it about
<nakilon> basically there are two methods to load the file and one of them is leaking, but which one? it's not stated in docs
ivzhh has quit [Remote host closed the connection]
ivzhh has joined #ruby
bamdad has quit [Ping timeout: 240 seconds]
burgestrand has quit [Quit: burgestrand]
orbyt_ has joined #ruby
imode has joined #ruby
brainfunnel has joined #ruby
rippa has joined #ruby
<jhass> why would you document a memory leak rather than fix it? :D
<jhass> or are you talking about memory bloat actually?
eydaimon has joined #ruby
<eydaimon> I want to insert an image into the top corner of another image. What's a good toolkit to use for this?
<adam12> eydaimon: I like the image_processing gem. You probably want the `composite` method. https://github.com/janko/image_processing/blob/master/doc/minimagick.md#composite
<adam12> eydaimon: You could probably use minimagick directly if that's all you need. Up to you for which API you want.
<eydaimon> thanks :) looks like I can also do it with ffmpeg
<eydaimon> is minimagick based on imagemagick ?
<adam12> eydaimon: Yes. There are two libraries (iirc) and the other was rmagick. I think minimagick shells out (vs rmagick which did C interop).
<eydaimon> thanks a bundhle :)
<adam12> eydaimon: Cheers.
weaksauce has joined #ruby
stryek has joined #ruby
bmurt has joined #ruby
Rudd0 has quit [Ping timeout: 256 seconds]
BSaboia has quit [Quit: This computer has gone to sleep]
andremedeiros has quit [Quit: ZNC 1.8.2 - https://znc.in]
andremedeiros has joined #ruby
TCZ has joined #ruby
bamdad has joined #ruby
BSaboia has joined #ruby
zacts has quit [Quit: leaving]
ur5us has joined #ruby
TomyWork has quit [Remote host closed the connection]
<nakilon> jhass, don't ask me ..D
<nakilon> when I told about the leak in seattlerb's chat, they told me I'm idiot ..D
<nakilon> (just a place that I tried previously to discuss ruby)
<nakilon> IIRC the problem is that there are two ways to use the library and one is correct while another one kind of works but is leaking, and people have a problem with it
<nakilon> eydaimon, also take a look at ruby-vips
<nakilon> because it may consume much less resources than imagemagick
<jhass> well, a lot people are confusing leaks and bloat in ruby and they're not always easy to tell apart too. Mainly due to the aformentioned tendency of the GC to hold onto memory it got from the OS for a little while, but also, as you discovered, there's too many easy ways to load too big files all at once into memory or construct really big strings otherwise
nakilon has quit [Read error: Connection reset by peer]
nakilon has joined #ruby
<nakilon> eydaimon also if your images are PNG, looks like ChunkyPNG can compose images too: https://github.com/wvanbergen/chunky_png
<nakilon> "It is written in pure Ruby" so it does not need neither imagemagick, nor vips or ffmpeg
elcontrastador has quit [Ping timeout: 272 seconds]
bmurt has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
<nakilon> jhass, was disconnecting... that was a leak -- there are two methods that both work like importing the file but you are supposed to use only one of them while another one isn't supposed to be called directly or something like that
<nakilon> I don't wanna dive in it again, it's ungrateful
ap4y has joined #ruby
<jhass> sure :D
Scriptonaut has joined #ruby
Scriptonaut has quit [Changing host]
crankharder has quit [Ping timeout: 264 seconds]
V[excess] is now known as ^
rippa has quit [Quit: {#`%${%&`+'${`%&NO CARRIER]
crankharder has joined #ruby
nofxx has joined #ruby
nofxx_ has quit [Ping timeout: 268 seconds]
cthu| has joined #ruby
cthulchu_ has quit [Ping timeout: 258 seconds]
<havenwood> The ::read/::readlines vs ::foreach docs could be improved, but seem pretty clear as is.
<havenwood> ¯\_(ツ)_/¯
orbyt_ has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
Caerus has quit [Ping timeout: 272 seconds]
adu has quit [Quit: adu]
Caerus has joined #ruby
weaksauce has quit [Quit: Textual IRC Client: www.textualapp.com]
adu has joined #ruby
<havenwood> I don't get where a memory leak is involved, but one slurps the whole file into memory and the other doesn't.
<havenwood> Seems like memory bloat, as jhass suggested. Loading a whole file into memory isn't a "leak."
<nakilon> it wasn't about .each
<nakilon> there was some class variable memoisation that didn't clean
ruurd has quit [Read error: Connection reset by peer]
ruurd has joined #ruby
weaksauce has joined #ruby
zacts has joined #ruby
ellcs has quit [Ping timeout: 268 seconds]
zacts has quit [Client Quit]
stryek has quit [Quit: Connection closed for inactivity]
zacts has joined #ruby
elcontrastador has joined #ruby
Caerus has quit [Ping timeout: 256 seconds]
zacts has quit [Client Quit]
Caerus has joined #ruby
ellcs has joined #ruby
<havenwood> nakilon: ew, class variables
cloud69 has quit [Quit: Connection closed for inactivity]
Rudd0 has joined #ruby
akem has quit [Ping timeout: 260 seconds]
crankharder has quit [Ping timeout: 264 seconds]
dionysus69 has quit [Ping timeout: 264 seconds]
ruurd has quit [Quit: ZZZzzz…]
TCZ has quit [Quit: Leaving]
ruurd has joined #ruby
ChmEarl has quit [Read error: No route to host]
ivzhh has quit [Remote host closed the connection]
ivz_hh has joined #ruby
ChmEarl has joined #ruby
cer0 has joined #ruby
TCZ has joined #ruby
ruurd has quit [Quit: ZZZzzz…]
ellcs has quit [Ping timeout: 268 seconds]
ur5us has quit [Ping timeout: 260 seconds]
ur5us has joined #ruby
Cypher85478 has joined #ruby
Cypher85478 has quit [Client Quit]
alexherbo2 has quit [Quit: The Lounge - https://thelounge.chat]