Skip to content

Instantly share code, notes, and snippets.

@ravenberg
Created August 2, 2016 06:45
Show Gist options
  • Select an option

  • Save ravenberg/a94ca4faee9f2b45c82eaa6b4b3ddcd9 to your computer and use it in GitHub Desktop.

Select an option

Save ravenberg/a94ca4faee9f2b45c82eaa6b4b3ddcd9 to your computer and use it in GitHub Desktop.

Revisions

  1. ravenberg created this gist Aug 2, 2016.
    10 changes: 10 additions & 0 deletions rubycode.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    def get_hash(name)
    readsize = 64 * 1024
    File.open(name, 'rb') do |f|
    size = File.size?(name)
    data = f.read(readsize)
    f.seek(-readsize, IO::SEEK_END)
    data += f.read(readsize)
    return Digest::MD5.hexdigest(data)
    end
    end