Skip to content

Instantly share code, notes, and snippets.

@KrzaQ
Created May 16, 2017 18:38
Show Gist options
  • Select an option

  • Save KrzaQ/ccb722105a478d2ef94a868c152509a7 to your computer and use it in GitHub Desktop.

Select an option

Save KrzaQ/ccb722105a478d2ef94a868c152509a7 to your computer and use it in GitHub Desktop.
def filter_line(line)
line.gsub!(/\x0f/, '')
line.gsub!(/\x03\d?\d?/, '')
line.gsub!(/\x02/, '')
line
end
def filter_file(name)
File.read(name).each_line.map{ |line| filter_line line }
end
def work_on_file(name)
File.write('out.log', filter_file(name).join("\n"))
end
def use_stdin
ARGF.each_line do |line|
print filter_line line
end
end
if(ARGV.size == 1)
work_on_file ARGV[0]
else
use_stdin
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment