 String::dasherize = ->
   @replace /_/g, '-'
 
+Array::compact = (strings = true) ->
+  @forEach (element, index) =>
+    @splice(index, 1) if element is undefined or (strings and element is '')
+
+  @
+
 Array::toSentence = ->
   switch @length
     when 0 then ''


      elem.addClass 'negative' if parseInt(number, 10) < 0

  # Take a string like 'Asgard.Whiteboard.Entry' and retrieve the real class
  # with that name. Start at `window` and work down from there.
  @_stringToClass: (string) ->
    pieces = string.split('.')

      beforeSend: (xhr) ->
        $.rails.CSRFProtection xhr

  @getCurrentPageJson: ->
    pathname = window.location.pathname.replace(/\/+$/, '')

    $.get "#{pathname}.json#{window.location.search}"

  @humanDate: (date, time = false) ->
    if date.year() is moment().year()
      date.format("M/D#{if time then ' h:mm A' else ''}")
