Skip to content

Instantly share code, notes, and snippets.

@nasser
Created January 4, 2015 00:59
Show Gist options
  • Save nasser/7a0dfa6263b1ae8d2fd3 to your computer and use it in GitHub Desktop.
Save nasser/7a0dfa6263b1ae8d2fd3 to your computer and use it in GitHub Desktop.
Minimal git-style hash database
#!/usr/bin/ruby
puts open("db/#{ARGV.first}").read
#!/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