SITEI ZIKAN MADENI TOMENAITO FILE KESITYAU KUN

I can't wake up with usual alarm clock.
So I made a peculiar alarm clock named "SITEI ZIKAN MADENI TOMENAITO FILE KESITYAU KUN".


The clock is a simple ruby script.
We can use it like this

$./delete_timer.rb 10 0
set timer for 11:0


If you don't stop it with Ctrl+C before coming of the time you set, it will delete your file on directory specified with DELETE_DIRECTORY_PATH.
So you will wake up properly to save your file.


I assume that DELETE_DIRECTORY_PATH is set to a directory which contains precious pictures user shoted or something.
Naturally I'm using it like that.


Have you got the urge to use "SITEI ZIKAN MADENI TOMENAITO FILE KESITYAU KUN"?







delete_time.rb


#!/bin/ruby

DELETE_DIRECTORY_PATH = "F:/picture"
DEBUG = false
DELETE_FILES = 1

def delete_a_file
all_candidates = Dir.glob(DELETE_DIRECTORY_PATH + "/**/*")
all_files = []
all_candidates.each{ |candidate|
all_files << candidate if File::ftype(candidate) == "file"
}

DELETE_FILES.times{
to_delete = all_files[rand(all_files.length).to_i]
p to_delete if DEBUG
File.delete(to_delete)
all_files.delete(to_delete)
}
end

hour = ARGV[0]
minute = ARGV[1]

puts "set timer for " + hour.to_s + ":" + minute.to_s

loop {
current_time = Time.now

if current_time.hour == hour.to_i && current_time.min == minute.to_i
delete_a_file()
puts "game over :" + current_time.to_s
break
end

sleep 30
}