Created
June 15, 2017 14:31
-
-
Save scruffyfox/c0ff95a3f463d9c536884b0aa2b14c8d to your computer and use it in GitHub Desktop.
Stack overflow-ify your code!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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