Created
January 4, 2015 00:59
-
-
Save nasser/7a0dfa6263b1ae8d2fd3 to your computer and use it in GitHub Desktop.
Minimal git-style hash database
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
#!/usr/bin/ruby | |
puts open("db/#{ARGV.first}").read |
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
#!/usr/bin/ruby | |
require 'digest/sha1' | |
body = ARGF.read | |
hash = Digest::SHA1.hexdigest body | |
File.open("db/#{hash}", "w") { |f| f.write body } | |
puts hash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment