Public feed
#725026
#!/usr/bin/env ruby=begin Author : Mr. Cheeks Description : A program to fight against nasty neighbors The program plays random noises at random times So if the landlord comes he'll hear nothing :p Note : Make sure you add sounds like cows, dogs in your directory! :p =endrequire 'rand'# the directory variable holding the mp3 directoryd = nil# the time in seconds to play another songtimerList = [4, 5, 6, 7]# The program to use to play soundsprogram = 'C:/Tools/mplayer/mplayer.exe'# The mp3 directorysoundDir = "C:/Projects/Python/mp3list/sounds"begin d = Dir.open(soundDir)rescue Errno::ENOENT #raise "Couldn't open #{dir} for reading: #{$!}"end files = Array.new# add all the songs to a listd.each do |file| filename = File.join(soundDir, file) if File.extname(filename) == "" next end # There is no -T equivalent in Ruby, but we can still test emptiness files.push(filename) end # loop all the timewhile true begin # sleep for some time sleep(timerList.pick) # play the song IO.popen( program + " " + files.pick, "r") # wait for the process to terminate Process.wait rescue Interrupt puts "Program terminated by the user" exit() end end