def delete_if(dir)
save = Dir.getwd
Dir.chdir(dir)
Dir.foreach(".") do |entry|
next if File.stat(entry).directory?
if yield entry
File.unlink(entry)
end
end
Dir.chdir(save)
end
delete_if("/tmp") { |f| File.size(f) > 3000 }