Skip to content

Instantly share code, notes, and snippets.

@havenwood
Created April 27, 2025 21:12
Show Gist options
  • Save havenwood/4007b81e027a83829390a9e25b70cab5 to your computer and use it in GitHub Desktop.
Save havenwood/4007b81e027a83829390a9e25b70cab5 to your computer and use it in GitHub Desktop.
Just a fun example for Ruby IRC playing with IO.copy_stream
require 'stringio'
require 'zlib'
io = StringIO.new('Zip me...')
zipped_io = StringIO.new('', 'a+b')
writer = Zlib::GzipWriter.new(zipped_io)
IO.copy_stream(io, writer)
writer.finish
zipped_io.rewind
IO.copy_stream(zipped_io, $stdout)
writer.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment