Skip to content

Instantly share code, notes, and snippets.

@ELLIOTTCABLE
Created October 19, 2014 19:56
Show Gist options
  • Select an option

  • Save ELLIOTTCABLE/25e9f8215179858cddc7 to your computer and use it in GitHub Desktop.

Select an option

Save ELLIOTTCABLE/25e9f8215179858cddc7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# Usage:
# # ./dat_fixer.rb <width in pixels>
#
# for example,
# $ ./dat_fixer.rb 150 >icons/usb.dat
width = Integer ARGV[0]
STDERR.puts "Splitting #{width}px wide image ..."
STDERR.puts "Paste the .dat content, seperated by spaces or newlines:" if STDIN.tty?
values = STDIN.read.split /\s+/
values.each_slice width do |arr|
puts arr.join ' '
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment