Skip to content

Instantly share code, notes, and snippets.

@scruffyfox
Created June 15, 2017 14:31
Show Gist options
  • Save scruffyfox/c0ff95a3f463d9c536884b0aa2b14c8d to your computer and use it in GitHub Desktop.
Save scruffyfox/c0ff95a3f463d9c536884b0aa2b14c8d to your computer and use it in GitHub Desktop.
Stack overflow-ify your code!
#!/usr/bin/ruby
#Usage: stackoverify <input file> <output file (optional)>
file = ARGV[0]
out = ARGV[1] || file + ".so"
replacements = [
"",
" ",
" ",
" ",
" ",
" "
]
outString = ""
begin
file = File.new(file, "r")
while (line = file.gets)
line.gsub!(/( )/, replacements.sample)
line.gsub!(/( )/, replacements.sample)
outString += "#{line}"
outString += rand(50) % 2 == 0 ? "\n" : ""
end
file.close
rescue => err
puts "Exception: #{err}"
err
end
File.open(out, 'w') { |file| file.write(outString) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment