Last active
December 25, 2015 06:39
-
-
Save javierhonduco/6933499 to your computer and use it in GitHub Desktop.
Para los vagos.
TODO * THE THINGS.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'digest/sha1' | |
dir = '/Users/javierhonduco/Dropbox/uni/Estructura/lab/CodigoInicialP1' | |
exercise = 'E2-CompToInt' | |
args = 10000001 | |
interval = 0.5 | |
def dirhash dir | |
items = [] | |
hashs = [] | |
Dir.foreach(dir) do |item| | |
next if %w(. ..).include? item | |
next if !item.match /.(c|h)/ | |
next if item.match /.swp/ | |
items.push item | |
end | |
items.sort! | |
items.each do |item| | |
digest = Digest::SHA1.hexdigest File.read "#{dir}/#{item}" | |
hashs.push digest | |
end | |
Digest::SHA1.hexdigest hashs.join | |
end | |
previous = nil | |
while true | |
current = dirhash dir | |
if !previous.nil? and current != previous | |
puts 'A file has changed!' | |
puts `cd #{dir} && make && ./#{exercise} #{args}` | |
end | |
previous = current | |
sleep interval | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, timeout me maybe?