havenwood changed the topic of #ruby to: Ruby 3.3.0, 3.2.3, 3.1.4 https://www.ruby-lang.org | Rules https://ruby-community.com | Logs https://libera.irclog.whitequark.org/ruby
ua_ has quit [Ping timeout: 256 seconds]
ua_ has joined #ruby
CrazyEddy has joined #ruby
CrazyEddy has left #ruby [#ruby]
CrazyEddy has joined #ruby
<bovis> havenwood: Thanks for those. The latter example is cleaner than the other (and than my attempts). I think it's close to what I want.
<bovis> Ultimately, I'm reaching for this process: File1.zip exists. In memory: (I make a copy, and add to it). I offer the edited copy to the user. The original File1.zip never changes, and I can add other contents to that same starting point later.
<bovis> What I'm finding is that, in my examples, I have opened File1.zip, pieced it out one by one, fed it to a stream, and created a copy from that. This isn't better than having all the pieces (outside a zip, in a directory somewhere) and putting them together on the fly.
<weaksauce> i wonder if you could serialize the intermediate object right before you add the extra thing and then load that from disk and add/finalize it and send it out
<weaksauce> bovis might be worth exploring if you have some odd requirement where the other thing you're trying isn't working for you
<bovis> adam12: Thank you. The addition of .string did make the zip open properly.
<bovis> weaksauce: adam12's addition of .string to my send_data does the trick. I guess it doesn't fix the issue of me reading the original piece-by-piece, but it's a start in the right direction.
<weaksauce> yeah that's a promising lead
<weaksauce> but doesn't seem like you are completely satisfied with it?
hightower2 has quit [Read error: Connection reset by peer]
fercell_ has joined #ruby
<bovis> weaksauce: Haha well I'm certianly happy this works. This is good on a small scale, a text file or an image. Trying to work through a directory and subs was a struggle before; I'd like to avoid the heavy lifting of packing everything together.
fercell has quit [Ping timeout: 252 seconds]
hightower2 has joined #ruby
<bovis> Serialize like Rails serialization used for databases? Or do you mean something different?
<weaksauce> i mean't it more generally from an object into a thing on disk that you can read from to instantiate a new object from
CrazyEddy has quit [Remote host closed the connection]
karolis has quit [Ping timeout: 268 seconds]
<Al2O3> that thing in the old days was an object unwound into a scheme/structure, and it was considered archived and could become live upon reading, or the system rebooting. Persistent objects was the idea.
<Al2O3> has that changed any?
<Al2O3> its been 30+ years since I worked on persistent object architecture or frameworks..
Linux_Kerio has joined #ruby
_ht has joined #ruby
Guest74 has joined #ruby
grenierm has joined #ruby
Guest74 has quit [Quit: Client closed]
MoskitoHero has joined #ruby
_ht has quit [Remote host closed the connection]
ken_barber has joined #ruby
hd1 has joined #ruby
hd1 has left #ruby [#ruby]
gr33n7007h has quit [Quit: WeeChat 4.2.2]
Linux_Kerio has quit [Ping timeout: 252 seconds]
gr33n7007h has joined #ruby
gaussianblue has joined #ruby
gaussianblue has quit [Quit: leaving]
CrazyEddy has joined #ruby
CrazyEddy has quit [Ping timeout: 240 seconds]
TomyWork has joined #ruby
gaussianblue has joined #ruby
xdminsy has joined #ruby
pascal_blaze has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pascal_blaze has joined #ruby
royo25 has joined #ruby
royo25 has quit [Client Quit]
royo25 has joined #ruby
Pixi__ has joined #ruby
Pixi` has quit [Ping timeout: 268 seconds]
CrazyEddy has joined #ruby
karolis has joined #ruby
CrazyEddy has quit [Remote host closed the connection]
user71 has joined #ruby
donofrio_ has joined #ruby
dviola has quit [Quit: WeeChat 4.2.2]
grenierm has quit [Ping timeout: 250 seconds]
donofrio has quit [Ping timeout: 256 seconds]
dviola has joined #ruby
donofrio__ has joined #ruby
donofrio_ has quit [Ping timeout: 268 seconds]
Linux_Kerio has joined #ruby
CrazyEddy has joined #ruby
CrazyEddy has quit [Client Quit]
konsolebox has joined #ruby
ken_barber has quit [Quit: Client closed]
CrazyEddy has joined #ruby
oneeyedalien has joined #ruby
user71 has quit [Quit: Leaving]
CrazyEddy has left #ruby [#ruby]
CrazyEddy has joined #ruby
<adam12> bovis: Since .string worked, what likely happened is `send_file` tried to send from an IO object (StringIO is the default for Zip), and the IO object's position was at the end of file, so it had nothing to send. `.string` returns the entire buffer, but I suspect `.rewind` before sending might have fixed it too. Glad it's worted.
<adam12> s/worted/sorted
<adam12> It might be worth trying `.rewind` instead, which may save you another large String allocation.
havenwood has quit [Quit: The Lounge - https://thelounge.chat]
havenwood has joined #ruby
sagax has joined #ruby
mjones has joined #ruby
<bovis> adam12: Interesting, .rewind doesn't work. I can confirm with IO.pos that rewind moves the cursor, but send_file doesn't seem to like anything but .string
<adam12> bovis: Weird.
<adam12> Well, maybe there won't be a string allocation since it's just returning the internal buffer and not a copy. I am not sure.
ken_barber has joined #ruby
oneeyedalien has quit [Quit: Leaving]
Linux_Kerio has quit [Ping timeout: 256 seconds]
pascal_blaze has quit [Quit: My MacBook has gone to sleep. ZZZzzz…]
pascal_blaze has joined #ruby
pascal_blaze has quit [Ping timeout: 246 seconds]
splud is now known as chatgpt
chatgpt is now known as splud
sagax has quit [Quit: Konversation terminated!]
pascal_blaze has joined #ruby
xdminsy has quit [Read error: Connection reset by peer]
pascal_blaze has quit [Ping timeout: 268 seconds]
CrazyEddy has left #ruby [#ruby]
CrazyEddy has joined #ruby
user71 has joined #ruby
xdminsy has joined #ruby
MoskitoHero has quit [Remote host closed the connection]
MoskitoHero has joined #ruby
pascal_blaze has joined #ruby
royo25 has quit [Quit: Bye]
pascal_blaze has quit [Ping timeout: 256 seconds]
szkl has quit [Quit: Connection closed for inactivity]
MoskitoHero has quit [Remote host closed the connection]
MoskitoHero has joined #ruby
MoskitoHero has quit [Remote host closed the connection]
MoskitoHero has joined #ruby
havenwood has quit [Quit: The Lounge - https://thelounge.chat]
havenwood has joined #ruby
pascal_blaze has joined #ruby
havenwood has quit [Client Quit]
pascal_blaze has quit [Ping timeout: 256 seconds]
havenwood has joined #ruby
danishman has joined #ruby
MoskitoHero has quit [Quit: MoskitoHero]
_ht has joined #ruby
gaussianblue has quit [Quit: leaving]
pascal_blaze has joined #ruby
pascal_blaze has quit [Ping timeout: 260 seconds]
<zayd> What's the best way of parsing a string like "16260400 kB" to turn it into MB, or if appropriate, GB? I'm guessing I use .to_i and then divide by the appropriate amount, is there anything else to it than that?
Linux_Kerio has joined #ruby
konsolebox_ has joined #ruby
konsolebox has quit [Ping timeout: 268 seconds]
konsolebox_ has quit [Quit: .]
osc4rpt has quit [Ping timeout: 264 seconds]
osc4rpt has joined #ruby
karolis has quit [Ping timeout: 256 seconds]
reset has joined #ruby
<zayd> weaksauce: i'm not using rails but thanks
<zayd> also, why do so many people use rails? is it mainly for web stuff?
<weaksauce> yeah it's a web framework
<zayd> ah
user71 has quit [Quit: Leaving]
konsolebox has joined #ruby
FetidToot1 has joined #ruby
FetidToot has quit [Ping timeout: 264 seconds]
FetidToot1 is now known as FetidToot
TomyWork has quit [Ping timeout: 268 seconds]
pascal_blaze has joined #ruby
pascal_blaze has quit [Ping timeout: 252 seconds]
<[0x1eef]> zayd: https://github.com/dominikh/filesize might be worth a look. Not actively maintained anymore. It always stood out to me though.
<[0x1eef]> Sounds like you want: Filesize.from("16260400 kB").pretty
<weaksauce> it's a simple library so i'm not sure why it would need to be that active
<zayd> [0x1eef]: i guess i can try this if i can't get it to work normally, i wanted to keep my code to as few libraries as possible so i'll see if i can do it in some way with what's already given
<zayd> thanks
danishman has quit [Remote host closed the connection]
<weaksauce> zayd it's under 200 loc you could just rip directly
ken_barber has quit [Quit: Client closed]
<[0x1eef]> Ruby continues to evolve and introduce breaking changes. :) IIRC that library is from 1.9 era. Forking it might be the best choice since you're gonna carry the maintainence burden either way.
<gr33n7007h> keep it simple and divide by 1e3 = MB, 1e6 = GB, 1e9 = TB and so on...
pascal_blaze has joined #ruby
<gr33n7007h> for Kib -> MiB you can right/left shift by multiples of 10
MoskitoHero has joined #ruby
pascal_blaze has quit [Ping timeout: 260 seconds]
pascal_blaze has joined #ruby
pascal_blaze has quit [Ping timeout: 260 seconds]
konsolebox_ has joined #ruby
konsolebox has quit [Ping timeout: 268 seconds]
rvalue has quit [Read error: Connection reset by peer]
rvalue has joined #ruby
MoskitoHero has quit [Ping timeout: 268 seconds]
pascal_blaze has joined #ruby
karolis has joined #ruby
pascal_blaze has quit [Ping timeout: 268 seconds]
havenwood has quit [Quit: The Lounge - https://thelounge.chat]
havenwood has joined #ruby
Vonter has quit [Ping timeout: 252 seconds]
Vonter has joined #ruby
karolis has quit [Ping timeout: 246 seconds]
___nick___ has joined #ruby
___nick___ has quit [Client Quit]
___nick___ has joined #ruby
karolis has joined #ruby
pascal_blaze has joined #ruby
pascal_blaze has quit [Ping timeout: 252 seconds]
___nick___ has quit [Ping timeout: 264 seconds]
karolis has quit [Ping timeout: 260 seconds]
_ht has quit [Remote host closed the connection]
pascal_blaze has joined #ruby
karolis has joined #ruby
pascal_blaze has quit [Ping timeout: 240 seconds]
xdminsy has quit [Read error: Connection reset by peer]
<adam12> zayd: https://github.com/adam12/friendly_numbers feel free to steal my implementation.
pascal_blaze has joined #ruby
konsolebox_ has quit [Quit: .]
jas-maelstrom has quit [Remote host closed the connection]
pascal_blaze has quit [Ping timeout: 255 seconds]
Linux_Kerio has quit [Ping timeout: 255 seconds]
<[0x1eef]> Nice. And friendly. :P
pascal_blaze has joined #ruby
crespire has joined #ruby
crespire1 has quit [Ping timeout: 256 seconds]
<adam12> :P
polishdub has quit [Ping timeout: 252 seconds]
polishdub has joined #ruby
<zayd> adam12: thanks, i'll try this out
jas-maelstrom has joined #ruby
ruby[bot] has quit [Remote host closed the connection]
ruby[bot] has joined #ruby
<zayd> adam12: am i doing something wrong with this or do i have to convert to bytes before running `FriendlyNumbers.number_to_human_size`?
<adam12> zayd: Yes. It expects `bytes` as an argument.
<zayd> whenever i try to use any variation it gives me an error saying "undefined method" when i try to use `File.read('/proc/meminfo').match(/(?=[0-9])(.*)/i).to_i` but a ton of sites say to use it
<zayd> adam12: alright
<adam12> Is `match` the right method? I thought that returned a MatchData object.
<adam12> Maybe you need `.match(...same.bits..)[0].to_i`
<zayd> adam12: yeah that did it
<zayd> sorry, still kind of new and haven't spent a ton of time looking into this stuff lol
<adam12> No problem.
<zayd> Does the /proc/meminfo file just hold the data weirdly? I have 32GB RAM but when I put in puts `"RAM: #{FriendlyNumbers.number_to_human_size File.read('/proc/meminfo').match(/(?=[0-9])(.*)/i)[0].to_i * 1024}"` it puts out "RAM: 30.502 GB" and when I do the same with `* 1000` it obviously also puts out a lower number.
<zayd> I guess it discounts cache or something?
donofrio_ has joined #ruby
donofrio__ has quit [Ping timeout: 252 seconds]