Skip to content

Instantly share code, notes, and snippets.

@havenwood
Last active April 3, 2020 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save havenwood/5a0de73eb4fb2581f38d33fc1644656f to your computer and use it in GitHub Desktop.
Save havenwood/5a0de73eb4fb2581f38d33fc1644656f to your computer and use it in GitHub Desktop.
Example refactor for akem on #ruby IRC
#!/usr/bin/env ruby
File.open IO::NULL, 'w' do |dev_null|
File.readlines('samples.txt', chomp: true).each do |sample|
sample_speed = rand(0.1..1.0)
cmd = "play -v 1 \"#{sample}\""
puts cmd
if rand(2).zero?
Process.detach spawn(cmd, err: :out, out: dev_null)
else
system(cmd)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment