Skip to content

Instantly share code, notes, and snippets.

@Voker57
Created May 2, 2010 16:56
Show Gist options
  • Save Voker57/387276 to your computer and use it in GitHub Desktop.
Save Voker57/387276 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
# usage: ./shitcounter.rb firefox log.txt
browser = ARGV[0]
logfile = File.open(ARGV[1], "w")
def ps_aux(grep = nil)
unf = `ps aux`.split("\n")[1..-1].map do |v| v.split(/\s+/) end
if grep
unf.select do |v|
v.join("").include? grep
end
else
unf
end
end
cnt = 0
File.readlines("links.txt").each do |lnk|
Thread.new do
`#{browser} #{lnk.chomp}`
end
puts "#{browser} #{lnk.chomp} &...\nPRESS ANY FUCKING KEY"
sum = 0
STDIN.getc
ps_aux(ENV["GREPBY"] || browser).each do |v|
sum += v[5].to_i
end
puts "#{cnt} #{sum}"
logfile.puts "#{cnt} #{sum}"
cnt += 1
end
logfile.close
puts "fuck off"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment