BrooklynJS - Jan 2014 Michael Donohoe - http://donohoe.io - @donohoe
  • Wouldn’t it be great if...
  • Anchor links! :)
  • No one uses them :(
  • (rarely clearly linked)
  • Manual process
  • 0 people will use them
  • Manually write unique names
  • Sequential numbers?
  • anchor1, anchor2, anchor3, ... anchorN
  • Let the CMS manage it...
  • Now you have 99 problems...
  • Move, add, edit, delete paragraphs...
  • Allow writers/editors to manually edit
  • What now?
  • Javascript to the rescue
  • Re-invent the wheel
  • This wheel will have fuzzy dice
  • How to generate a dynamic ID that
  • - Uniquely identify every paragraph
  • - Generates the same ID every time
  • - Accounts for paragraphs moving
  • - Tolerant to changes in Paragraph
  • Tolerance
  • - updates
  • - corrections
  • - sentences split off
  • - typos
  • You can’t get a 100% solution
  • But you can get very very very close...
  • Maybe 90% (hard to measure)
<p>Think about what this means for the privacy of the average person. A child born today will grow up with no conception of privacy at all. They'll never know what it means to have a private moment to themselves — an unrecorded, unanalyzed thought</p>
<p>Think about what this means for the privacy of the average person. A child born today will grow up with no conception of privacy at all. They'll never know what it means to have a private moment to themselves — an unrecorded, unanalyzed thought</p>
  • Each 6 char key refers to specific paragraph
  • Break paragraph into sentences
  • Take first and last sentences (sometimes the same)
  • First character from the first three words of each sentence
  • Read hash from URL...
  • http://friendster.com/snowflake/#/TawTnk
  • This will also match:
  •   TnkTaw
  •   TnkXYZ
  •   ABCTaw
  •   TawTnk
  •   TahTnk
  • Levenshtein: string metric for measuring the difference between two sequences. Informally, the Levenshtein distance between two words is the minimum number of single-character edits (insertions, deletions or substitutions) required to change one word into the other

  • Put it all together...
  • http://friendster.com/snowflake/#/TawTnk
  • Check URL for Hash
  • Only then, create Keys for document
  • Split ALL the Keys
  • Compare both using lev distance
  • Rank matches
  • Pick the winner - if any