The use of SHA1 digests of data as unique identifiers is the answer to everything.
I know that appears to be ridiculous hyperbole, but I'll go into why I think that is the case in a longer post at some point. For now you'll have to take my word for it that using them as identifiers has simplified the inner workings of a big project tremendously. It's not just me either, the Software revision control system Git uses them as IDs for all its commits.
Anyway... one issue that can arise with them is that you notice that one specific digest string occurs more frequently than others in this uniformly distributed hash space... yikes... what's going on?
That digest would be da39a3ee5e6b4b0d3255bfef95601890afd80709 - make a note of it!
It represents the SHA1 digest of an Empty String
You might want to consider adding an explicit test for that string somewhere in your code.
Ideally you want a direct test for an empty string being used as an ID, but checking for this digest is a useful catch-all test.
Once I realized that this digest was being generated, and realized what it represented, then I could focus in on the root cause very quickly.
A collection of computer systems and programming tips that you may find useful.
Brought to you by Craic Computing LLC, a bioinformatics consulting company.
Tuesday, September 15, 2009
Subscribe to:
Posts (Atom)
Contributors
Archive of Tips
-
►
2011
(44)
-
►
November
(11)
- strsplit in R
- Running R scripts on the Command Line
- Deleting a File that starts with '-' on UNIX
- Plotting a simple bar plot in R
- Captain Beefheart Song Titles
- When jQuery $.ajax() keeps returning the same valu...
- Updating a DIV with jQuery and Sinatra
- Latest version of jQuery on Google APIs
- Sorting on multiple String keys in Ruby
- Manipulating Model/Table/Controller Names in Rails...
- Parsing 96 / 384 well Plate Maps
-
►
February
(14)
- Rails, UTF-8 and Heroku
- Tables named with reserved words in MySQL
- Setting up PostgreSQL on Mac OS X 10.6
- Problem with sqlite when installing the taps ruby ...
- Rails, Devise and custom User models
- Basic image rollover effect in jQuery
- Authentication in Mongo and Mongoid
- Always index columns that you want to sort on in M...
- Using Mongoid in Ruby applications outside of Rail...
- Using Twitter for System Notifications
- PATSY - a web service that makes patents easier to...
- JavaScript Bookmarklet that can create a New Windo...
- Running a Ruby 1.9 Sinatra app on Heroku
- Ruby 1.9 and incompatible character encodings
-
►
November
(11)