   now: ->     Date.now()
 
   uniqid: ->  Date.now() + Math.floor Math.random()*110000
-  
+
   randomBase62Hash:(length=8, ensureLength=yes)->
     # TODO: this function was ported from an answer on stackoverflow, and must
     #       perform wretchedly.  Also, it would seem likely that it is not


  calls the provided function with the first filename that is
  similar to filepath, but that does not exist in the filesystem.
  generate new filename candidates by appending an underscore "_", 
  and the next integer.
  ###     
  Path.makeSafe = (filepath, callback)->
    _checkPath filepath, callback
  ###


  nicename:(name) ->
    name.toLowerCase().replace /[^a-z0-9]+/g, '-'

  makeTeaser:(long, options={})->
    return unless long

    minLength = options.minLength or 450
    maxLength = options.maxLength or 600

    return long if long < minLength or long < maxLength

    long = long.substr 0, maxLength

    # prefer to end the teaser at the end of a sentence (a period).
    # failing that prefer to end the teaser at the end of a word (a space).
    candidate = @tryToShorten(long, '.') or @tryToShorten long, ' ', '...'

    if candidate?.length > minLength
      candidate
    else
      long

  tryToShorten:(long, optimalBreak, suffix)->
    unless ~ long.indexOf optimalBreak then no
    else
