Skip to content

Instantly share code, notes, and snippets.

@javierhonduco
Last active December 25, 2015 06:39
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 javierhonduco/6933499 to your computer and use it in GitHub Desktop.
Save javierhonduco/6933499 to your computer and use it in GitHub Desktop.
Para los vagos. TODO * THE THINGS.
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
@javierhonduco
Copy link
Author

Hey, timeout me maybe?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment