fix:storage of objet containing children

The storage of element with children was not done properly: I didn't
take into account the case where children were composed of several
elements. ie. a page has a child "userActions" which can contain more
than one event.

To go around, when a children is fetched, it is automatically stored in
an array (the array might be of size 1). And now, when storing the
object back, we iterate over every children and on each of them we
iterate over the different elements of the child. typical structur:
parent{child1{el1, el2},child2{el1, el2, el3}, child3{el1}}

--- src.coffee/storageExecutor.coffee
+++ src.coffee/storageExecutor.coffee
@@ -51,27 +51,31 @@
   store : (storeName, value, callback)->
     try
       if value._children?
-        count = value._children.length
+        count = 0
+        for child in value._children
+          count = count + value[child.name].length
         for child in value._children
           do(child) =>
-            @store child.objectStore value[child.name], () ->
-              delete value[child.name]
-              if count == 1
-                delete value._children
-                trans = @db.transaction [storeName], "readwrite"
-                store = trans.objectStore storeName
-                request = store.put value
-                request.onsuccess = (event) ->
-                  if callback?
-                    try
-                      callback event.target.result
-                    catch error
-                  return
-
-                request.onerror = @onerror
-              else
-                count--
-              return
+            for childElement in value[child.name]
+              @store child.objectStore, childElement, () =>
+                if count == 1
+                  for child in value._children
+                    delete value[child.name]
+                  delete value._children
+                  trans = @db.transaction [storeName], "readwrite"
+                  store = trans.objectStore storeName
+                  request = store.put value
+                  request.onsuccess = (event) ->
+                    if callback?
+                      try
+                        callback event.target.result
+                      catch error
+                    return
+
+                  request.onerror = @onerror
+                else
+                  count--
+                return
             return
       else
         trans = @db.transaction [storeName], "readwrite"
@@ -89,7 +93,8 @@
     catch error
       console.log error.message
       console.log "Error while storing #{JSON.stringify(value)} in store #{storeName}"
-      callback {}
+      if callback?
+        callback {}
     return

   get : (query, callback) ->
@@ -121,10 +126,7 @@
                 for child in query.children
                   do(child) =>
                     @get new mem0r1es.Query().from(child.objectStore).where("_#{store.keyPath}", "equals", result[store.keyPath]), (subResults) =>
-                      if subResults.length isnt 1
                         result[child.name] = subResults
-                      else
-                        result[child.name] = subResults[0]
                       if count is 1
                         callback results
                       else


Set color by the severity

Set color by the severity

--- plugins/slack/index.coffee
+++ plugins/slack/index.coffee
@@ -2,17 +2,24 @@

 class Slack extends NotificationPlugin
   @errorAttachment = (event) ->
-    fallback: "Something happened",
-    fields: [
-      {
-        title: "Error"
-        value: (event.error.exceptionClass + (if event.error.message then ": #{event.error.message}")).truncate(85)
-      },
-      {
-        title: "Location",
-        value: event.error.stacktrace && @firstStacktraceLine(event.error.stacktrace)
-      }
-    ]
+    attachment =
+      fallback: "Something happened",
+      fields: [
+        {
+          title: "Error"
+          value: (event.error.exceptionClass + (if event.error.message then ": #{event.error.message}")).truncate(85)
+        },
+        {
+          title: "Location",
+          value: event.error.stacktrace && @firstStacktraceLine(event.error.stacktrace)
+        }
+      ]
+    switch event.error.severity
+      when "error"
+        attachment.color = "#E45F58"
+      when "warning"
+        attachment.color = "#FD9149"
+    attachment

   @receiveEvent = (config, event, callback) ->
     # Build the notification title


Closes #20

Closes #20

Solução diferente: Toda vez que o seletor de data for alterado, o
attachment será enviado

--- src/script/portal-minicart.coffee
+++ src/script/portal-minicart.coffee
@@ -248,8 +248,7 @@
 				self.sendShippingDataAttachment()

 		availableDates.on 'change', ->
-			if self.cartData.timetableForSelectedDay.length == 1
-				self.sendShippingDataAttachment()
+			self.sendShippingDataAttachment()

 		availableTimetables.on 'change', ->
 			self.sendShippingDataAttachment()


Added khanify to meme_generator

Added khanify to meme_generator

--- src/scripts/meme_generator.coffee
+++ src/scripts/meme_generator.coffee
@@ -14,6 +14,8 @@
 # <text> TOO DAMN <high> - Generates THE RENT IS TOO DAMN HIGH guy
 #
 # Good news everyone! <news> - Generates Professor Farnsworth
+#
+# khanify <text> - TEEEEEEEEEEEEEEEEEXT!

 module.exports = (robot) ->
   robot.respond /Y U NO (.+)/i, (msg) ->
@@ -44,6 +46,10 @@

   robot.respond /(GOOD NEWS EVERYONE[,.!]?) (.*)/i, (msg) ->
     memeGenerator msg, 1591, 112464, msg.match[1], msg.match[2], (url) ->
+      msg.send url
+
+  robot.respond /khanify (.*)/i, (msg) ->
+    memeGenerator msg, 6443, 1123022, "", khanify(msg.match[1]), (url) ->
       msg.send url

 memeGenerator = (msg, generatorID, imageID, text0, text1, callback) ->
@@ -79,3 +85,11 @@
           callback "http://memegenerator.net#{img}"
       else
         msg.reply "Sorry, I couldn't generate that image."
+
+khanify = (msg) ->
+  msg = msg.toUpperCase()
+  vowels = [ 'A', 'E', 'I', 'O', 'U' ]
+  index = -1
+  for v in vowels when msg.lastIndexOf(v) > index
+    index = msg.lastIndexOf(v)
+  "#{msg.slice 0, index}#{Array(10).join msg.charAt(index)}#{msg.slice index}!!!!!"


calculate how many windows to place per floor in each building

--- views/gorillas.coffee
+++ views/gorillas.coffee
@@ -24,11 +24,11 @@

   build_windows:(x, y) ->
     rows = Math.round (@height)/31
-    window_positions = [ 10, 25, 40, 55, 70, 85 ]
+    windows_per_floor = Math.floor(@width/15)
     current_distance = 30
     total_height = 30
     for row in [0...rows]
-      @create_window x+position, 620+total_height-@height for position in window_positions
+      @create_window x+(position*15), 620+total_height-@height for position in [1...windows_per_floor]
       total_height += current_distance

   create_window:(x, y) ->


fixup: prim-data

fixup: prim-data

--- src/prim-data.coffee
+++ src/prim-data.coffee
@@ -74,10 +74,10 @@
 			return r.replace(/(\t|\n)/g, '')

 		samplePart = do ->
-			sample = json(sample(t), 4)
+			s = json(sample(t), 4)
 			"
\n" +
 			"sample: " +
-			(if /\n/.test sample then "
#{sample}
" else "#{sample}") +
+			(if /\n/.test s then "
#{s}
" else "#{s}") +
 			"
"

 		checkPart = if not check? then '' else


changed the message when shared password has been changed

--- views/js/login.coffee
+++ views/js/login.coffee
@@ -46,11 +46,11 @@
           message = "共通パスワードが違います．"
           try
             d = Date.parse(data.updated_at)
-            dt = (new Date() - d) / 86400000
-            if dt < 1
-              message += "パスワードは今日変更されました"
-            else if dt < 90
-              message += "パスワードは#{Math.floor(dt)}日前に変更されました"
+            dt = Math.floor(((new Date()).getTime() - d) / 3600000)
+            if dt < 24
+              message += "パスワードは#{dt}時間前に変更されました"
+            else if dt < 90*24
+              message += "パスワードは#{Math.floor(dt/24)}日前に変更されました"
           catch e
             console.log(e)
           _.cb_alert(message).always(->


Use getElementsByTagName

Use getElementsByTagName

--- src/quo.query.coffee
+++ src/quo.query.coffee
@@ -10,11 +10,12 @@
         selector = selector.trim()

         if CLASS_SELECTOR.test(selector)
-            dom_elements = domain.getElementsByClassName(selector)
-        else if TAG_SELECTOR.test(selector)
-            dom_elements = domain.getElementsByTagName(selector)
+            dom_elements = domain.getElementsByClassName selector.replace(".", "")
+        # else if TAG_SELECTOR.test(selector)
+        #     dom_elements = domain.getElementsByTagName(selector)
         else
-            dom_elements = domain.querySelectorAll(selector)
+            dom_elements = domain.querySelectorAll selector
+

         Array::slice.call(dom_elements)


hopefully fix a bug in some ancient code that nobody has used in years...

--- src/smc-hub/compute-client.coffee
+++ src/smc-hub/compute-client.coffee
@@ -1712,10 +1712,12 @@
         m += if opts.target? then ",target='#{opts.target}')" else ")"
         dbg = @dbg(m)
         dbg("")
+
         if (@compute_server.storage_servers.get()?.size ? 0) == 0
             dbg('no storage servers -- so all _storage_requests trivially done')
-            opts.cb?()
-            return
+            no_storage_servers = true
+        else
+            no_storage_servers = false
         if @is_storage_request_running()
             opts.cb?("already doing a storage request")
             return
@@ -1749,6 +1751,9 @@
                 else
                     cb()
             (cb) =>
+                if no_storage_servers
+                    cb()
+                    return
                 dbg("update database with *request* to '#{misc.to_json(opts.action)}' -- this causes storage server to doing something")
                 @compute_server.database.set_project_storage_request
                     project_id : @project_id
@@ -1756,6 +1761,9 @@
                     target     : opts.target
                     cb         : cb
             (cb) =>
+                if no_storage_servers
+                    cb()
+                    return
                 dbg("wait for action to finish")
                 @wait_storage_request_finish
                     cb : (err) =>


fix transcribe button position

fix transcribe button position

--- app/assets/javascripts/components/mark/tools/text-row-tool/done-button.cjsx
+++ app/assets/javascripts/components/mark/tools/text-row-tool/done-button.cjsx
@@ -32,15 +32,17 @@
     <Draggable onEnd={@props.onDrag}>
       <g
         className="mark-tool transcribe-button"
-        transform={"
-          translate(#{@props.position.x-BUTTON_WID}, #{@props.position.y-2*BUTTON_HEI*@props.tool.props.yScale})
-          rotate(#{@props.rotate})
-        "}
+        transform=
+          "
+            translate(#{@props.position.x},#{@props.position.y})
+            scale(#{1 / @props.tool.props.xScale}, #{1 / @props.tool.props.yScale})
+          "
       >
+
         <rect
           stroke="none"
-          transform="scale(#{1 / @props.tool.props.xScale}, #{1 / @props.tool.props.yScale})"
-          fill="rgba(0,0,0,0)"
+          transform="translate(0,#{-0.5*BUTTON_HEI})"
+          fill="rgba(255,255,255,0.0)"
           width="36"
           height="18"
           x="0"
@@ -50,8 +52,8 @@
         />
         <path
           stroke="none"
+          transform="translate(0,#{-0.5*BUTTON_HEI})"
           fill={FILL_COLOR}
-          transform="scale(#{1 / @props.tool.props.xScale}, #{1 / @props.tool.props.yScale})"
           d="m 12,15 -3,3 21,0 0,-3 z m 5,-5 -3,3 22,0 0,-3 z M 22,5 19,8 30,8 30,5 z M 14,0 11,3 15,7 18,4 z M 9.0249385,4.975061 0,14 l 0,4 4,0 9,-9 z"
         />


ManagedProvider:tests: move group creation to before step

--- workers/social/lib/social/models/computeproviders/computeprovider.test.coffee
+++ workers/social/lib/social/models/computeproviders/computeprovider.test.coffee
@@ -220,23 +220,24 @@

     testGroup = null

+    before (done) ->
+      withConvertedUser { createGroup: yes }, ({ group }) ->
+        testGroup = group
+        done()
+
     it 'should increase given group stack count', (done) ->

-      withConvertedUser { createGroup: yes }, ({ group }) ->
-
-        testGroup = group
-
-        ComputeProvider.updateGroupStackUsage testGroup, 'increment', (err) ->
-          expect(err).to.not.exist
-
-          JCounter.count
-            namespace : testGroup.slug
-            type      : ComputeProvider.COUNTER_TYPE.stacks
-          , (err, count) ->
-            expect(err).to.not.exist
-            expect(count).to.be.equal 1
-
-            done()
+      ComputeProvider.updateGroupStackUsage testGroup, 'increment', (err) ->
+        expect(err).to.not.exist
+
+        JCounter.count
+          namespace : testGroup.slug
+          type      : ComputeProvider.COUNTER_TYPE.stacks
+        , (err, count) ->
+          expect(err).to.not.exist
+          expect(count).to.be.equal 1
+
+          done()

     it 'should decrease given group stack count', (done) ->

@@ -281,24 +282,25 @@

     testGroup = null

+    before (done) ->
+      withConvertedUser { createGroup: yes }, ({ group }) ->
+        testGroup = group
+        done()
+
     it 'should increase given group instance count', (done) ->

-      withConvertedUser { createGroup: yes }, ({ group }) ->
-
-        testGroup = group
-
-        ComputeProvider.updateGroupInstanceUsage testGroup, 'increment', 2, (err) ->
-
-          expect(err).to.not.exist
-
-          JCounter.count
-            namespace : testGroup.slug
-            type      : ComputeProvider.COUNTER_TYPE.instances
-          , (err, count) ->
-            expect(err).to.not.exist
-            expect(count).to.be.equal 2
-
-            done()
+      ComputeProvider.updateGroupInstanceUsage testGroup, 'increment', 2, (err) ->
+
+        expect(err).to.not.exist
+
+        JCounter.count
+          namespace : testGroup.slug
+          type      : ComputeProvider.COUNTER_TYPE.instances
+        , (err, count) ->
+          expect(err).to.not.exist
+          expect(count).to.be.equal 2
+
+          done()

     it 'should decrease given group instance count', (done) ->


Use dollar sign in tests

Use dollar sign in tests

--- test/varity.coffee
+++ test/varity.coffee
@@ -1,171 +1,171 @@
 should = require('should')
 global.context = global.describe
-varity = require('../lib/varity')
+$ = require('../lib/varity')
 sinon = require('sinon')
 _ = require('underscore')
 jsdom = require('jsdom')

-describe 'varity', ->
+describe '$', ->
   beforeEach ->
     @callback = sinon.spy()

   afterEach ->
-    varity.reset()
+    $.reset()

   it 'should return a function', ->
-    varity.should.be.a.Function
+    $.should.be.a.Function

   it 'should wrap the passed function', ->
-    wrapped = varity @callback
+    wrapped = $ @callback
     wrapped.should.be.a.Function
     wrapped()
     @callback.called.should.be.true

   it 'should throw if passed no arguments', ->
     (->
-      varity()
+      $()
     ).should.throw('No function passed to varity')

   it 'should throw if the last argument is not a function', ->
     (->
-      varity({})
+      $({})
     ).should.throw('Last argument is not a function')

   context 'called with string types', ->
     it 'should accept string', ->
-      wrapped = varity 'string', @callback
+      wrapped = $ 'string', @callback
       wrapped 'something'
       @callback.calledWith('something').should.be.true

     it 'should accept String', ->
-      wrapped = varity 'String', @callback
+      wrapped = $ 'String', @callback
       wrapped 'something'
       @callback.calledWith('something').should.be.true

     it 'should accept function', ->
       fn = sinon.spy()
-      wrapped = varity 'function', @callback
+      wrapped = $ 'function', @callback
       wrapped(fn)
       @callback.calledWith(fn).should.be.true

     it 'should accept Function', ->
       fn = sinon.spy()
-      wrapped = varity 'Function', @callback
+      wrapped = $ 'Function', @callback
       wrapped(fn)
       @callback.calledWith(fn).should.be.true

     it 'should accept object', ->
       obj = fake: 'data'
-      wrapped = varity 'object', @callback
+      wrapped = $ 'object', @callback
       wrapped(obj)
       @callback.calledWith(obj).should.be.true

     it 'should accept Object', ->
       obj = fake: 'data'
-      wrapped = varity 'Object', @callback
+      wrapped = $ 'Object', @callback
       wrapped(obj)
       @callback.calledWith(obj).should.be.true

     it 'should accept array', ->
       arr = [ 'one', 'two' ]
-      wrapped = varity 'array', @callback
+      wrapped = $ 'array', @callback
       wrapped(arr)
       @callback.calledWith(arr).should.be.true

     it 'should accept Array', ->
       arr = [ 'one', 'two' ]
-      wrapped = varity 'Array', @callback
+      wrapped = $ 'Array', @callback
       wrapped(arr)
       @callback.calledWith(arr).should.be.true

     it 'should accept number', ->
-      wrapped = varity 'number', @callback
+      wrapped = $ 'number', @callback
       wrapped(2)
       @callback.calledWith(2).should.be.true

     it 'should accept Number', ->
-      wrapped = varity 'Number', @callback
+      wrapped = $ 'Number', @callback
       wrapped(2)
       @callback.calledWith(2).should.be.true

     it 'should accept boolean', ->
-      wrapped = varity 'boolean', @callback
+      wrapped = $ 'boolean', @callback
       wrapped(true)
       @callback.calledWith(true).should.be.true

     it 'should accept Boolean', ->
-      wrapped = varity 'Boolean', @callback
+      wrapped = $ 'Boolean', @callback
       wrapped(false)
       @callback.calledWith(false).should.be.true

     it 'should accept date', ->
       date = new Date()
-      wrapped = varity 'date', @callback
+      wrapped = $ 'date', @callback
       wrapped(date)
       @callback.calledWith(date).should.be.true

     it 'should accept Date', ->
       date = new Date()
-      wrapped = varity 'Date', @callback
+      wrapped = $ 'Date', @callback
       wrapped(date)
       @callback.calledWith(date).should.be.true

     it 'should accept regexp', ->
       reg = new RegExp('.*')
-      wrapped = varity 'regexp', @callback
+      wrapped = $ 'regexp', @callback
       wrapped(reg)
       @callback.calledWith(reg).should.be.true

     it 'should accept Regexp', ->
       reg = new RegExp('.*')
-      wrapped = varity 'Regexp', @callback
+      wrapped = $ 'Regexp', @callback
       wrapped(reg)
       @callback.calledWith(reg).should.be.true

     it 'should accept RegExp', ->
       reg = new RegExp('.*')
-      wrapped = varity 'RegExp', @callback
+      wrapped = $ 'RegExp', @callback
       wrapped(reg)
       @callback.calledWith(reg).should.be.true

     it 'should accept nan', ->
       nan = NaN
-      wrapped = varity 'nan', @callback
+      wrapped = $ 'nan', @callback
       wrapped(nan)
       # Checking truthy values of NaN is a pain
       @callback.args[0][0].should.be.NaN

     it 'should accept Nan', ->
       nan = NaN
-      wrapped = varity 'Nan', @callback
+      wrapped = $ 'Nan', @callback
       wrapped(nan)
       # Checking truthy values of NaN is a pain
       @callback.args[0][0].should.be.NaN

     it 'should accept NaN', ->
       nan = NaN
-      wrapped = varity 'NaN', @callback
+      wrapped = $ 'NaN', @callback
       wrapped(nan)
       # Checking truthy values of NaN is a pain
       @callback.args[0][0].should.be.NaN

     it 'should accept null', ->
-      wrapped = varity 'null', @callback
+      wrapped = $ 'null', @callback
       wrapped(null)
       @callback.calledWith(null).should.be.true

     it 'should accept Null', ->
-      wrapped = varity 'Null', @callback
+      wrapped = $ 'Null', @callback
       wrapped(null)
       @callback.calledWith(null).should.be.true

     it 'should accept undefined', ->
-      wrapped = varity 'undefined', @callback
+      wrapped = $ 'undefined', @callback
       wrapped(undefined)
       @callback.calledWith(undefined).should.be.true

     it 'should accept Undefined', ->
-      wrapped = varity 'Undefined', @callback
+      wrapped = $ 'Undefined', @callback
       wrapped(undefined)
       @callback.calledWith(undefined).should.be.true

@@ -173,7 +173,7 @@
       args = (->
         arguments
       ) 'one', 'two'
-      wrapped = varity 'arguments', @callback
+      wrapped = $ 'arguments', @callback
       wrapped(args)
       @callback.calledWith(args).should.be.true

@@ -181,35 +181,35 @@
       args = (->
         arguments
       ) 'one', 'two'
-      wrapped = varity 'Arguments', @callback
+      wrapped = $ 'Arguments', @callback
       wrapped(args)
       @callback.calledWith(args).should.be.true

     it 'should accept infinity', ->
-      wrapped = varity 'infinity', @callback
+      wrapped = $ 'infinity', @callback
       wrapped(Infinity)
       @callback.calledWith(Infinity).should.be.true

     it 'should accept Infinity', ->
-      wrapped = varity 'Infinity', @callback
+      wrapped = $ 'Infinity', @callback
       wrapped(Infinity)
       @callback.calledWith(Infinity).should.be.true

     it 'should accept error', ->
-      wrapped = varity 'error', @callback
+      wrapped = $ 'error', @callback
       e = new Error()
       wrapped e
       @callback.calledWith(e).should.be.true

     it 'should accept Error', ->
-      wrapped = varity 'Error', @callback
+      wrapped = $ 'Error', @callback
       e = new Error()
       wrapped e
       @callback.calledWith(e).should.be.true

     it 'should accept Element', (done) ->
       callback = @callback
-      wrapped = varity 'Element', @callback
+      wrapped = $ 'Element', @callback
       jsdom.env '

', (e, window) ->
         el = window.document.getElementById('id')
         wrapped el
@@ -218,7 +218,7 @@

     it 'should accept jQuery', (done) ->
       callback = @callback
-      wrapped = varity 'jQuery', @callback
+      wrapped = $ 'jQuery', @callback
       jsdom.env '

', ["http://code.jquery.com/jquery.js"], (e, window) ->
         elems = window.$('div')
         wrapped elems
@@ -229,71 +229,71 @@
       obj = {}
       arr = []
       fn = ->
-      wrapped = varity 'string', 'object', 'array', 'function', @callback
+      wrapped = $ 'string', 'object', 'array', 'function', @callback
       wrapped('something', obj, arr, fn)
       @callback.calledWith('something', obj, arr, fn).should.be.true

     it 'should accept multiple string parameters with duplicates', ->
       fn1 = ->
       fn2 = ->
-      wrapped = varity 'function', 'function', @callback
+      wrapped = $ 'function', 'function', @callback
       wrapped(fn1, fn2)
       @callback.calledWith(fn1, fn2).should.be.true

   context 'called with actual types', ->
     it 'should accept String', ->
-      wrapped = varity String, @callback
+      wrapped = $ String, @callback
       wrapped 'string'
       @callback.calledWith('string').should.be.true

     it 'should accept Function', ->
-      wrapped = varity Function, @callback
+      wrapped = $ Function, @callback
       fn = ->
       wrapped fn
       @callback.calledWith(fn).should.be.true

     it 'should accept Object', ->
-      wrapped = varity Object, @callback
+      wrapped = $ Object, @callback
       obj = {}
       wrapped obj
       @callback.calledWith(obj).should.be.true

     it 'should accept Array', ->
-      wrapped = varity Array, @callback
+      wrapped = $ Array, @callback
       arr = []
       wrapped arr
       @callback.calledWith(arr).should.be.true

     it 'should accept Number', ->
-      wrapped = varity Number, @callback
+      wrapped = $ Number, @callback
       wrapped 2
       @callback.calledWith(2).should.be.true

     it 'should accept Boolean', ->
-      wrapped = varity Boolean, @callback
+      wrapped = $ Boolean, @callback
       wrapped true
       @callback.calledWith(true).should.be.true

     it 'should accept Date', ->
-      wrapped = varity Date, @callback
+      wrapped = $ Date, @callback
       date = new Date()
       wrapped date
       @callback.calledWith(date).should.be.true

     it 'should accept RegExp', ->
-      wrapped = varity RegExp, @callback
+      wrapped = $ RegExp, @callback
       reg = /.*/
       wrapped reg
       @callback.calledWith(reg).should.be.true

     it 'should accept Error', ->
-      wrapped = varity Error, @callback
+      wrapped = $ Error, @callback
       e = new Error()
       wrapped e
       @callback.calledWith(e).should.be.true

     it 'should accept multiple type parameters', ->
-      wrapped = varity String, Function, Object, Array, RegExp, Date, @callback
+      wrapped = $ String, Function, Object, Array, RegExp, Date, @callback
       fn = ->
       obj = {}
       arr = []
@@ -303,7 +303,7 @@
       @callback.calledWith('string', fn, obj, arr, reg, date).should.be.true

     it 'should accept multiple type parameters with duplicates', ->
-      wrapped = varity Function, Array, Function, @callback
+      wrapped = $ Function, Array, Function, @callback
       fn1 = ->
       fn2 = ->
       arr = []
@@ -312,34 +312,34 @@

   context 'called with special types', ->
     it 'should accept null', ->
-      wrapped = varity null, @callback
+      wrapped = $ null, @callback
       wrapped null
       @callback.calledWith(null).should.be.true

     it 'should accept undefined', ->
-      wrapped = varity undefined, @callback
+      wrapped = $ undefined, @callback
       wrapped undefined
       @callback.calledWith(undefined).should.be.true

     it 'should accept multiple special parameters', ->
-      wrapped = varity null, undefined, @callback
+      wrapped = $ null, undefined, @callback
       wrapped null, undefined
       @callback.calledWith(null, undefined).should.be.true

     it 'should accept multiple special parameters with duplicate', ->
-      wrapped = varity null, null, undefined, null, @callback
+      wrapped = $ null, null, undefined, null, @callback
       wrapped null, null, undefined, null
       @callback.calledWith(null, null, undefined, null).should.be.true

   context 'called with mixed types', ->
     it 'should accept any combination of types (part 1)', ->
-      wrapped = varity 'string', Function, null, @callback
+      wrapped = $ 'string', Function, null, @callback
       fn = ->
       wrapped 'string', fn, null
       @callback.calledWith('string', fn, null).should.be.true

     it 'should accept any combination of types (part 2)', ->
-      wrapped = varity 'string', Function, Function, 'object', Object, null, undefined, Date, 'regexp', @callback
+      wrapped = $ 'string', Function, Function, 'object', Object, null, undefined, Date, 'regexp', @callback
       fn1 = ->
       fn2 = ->
       obj1 = {}
@@ -351,25 +351,25 @@

   context 'called with an array', ->
     it 'should accept an array of string parameters', ->
-      wrapped = varity ['string', 'object'], @callback
+      wrapped = $ ['string', 'object'], @callback
       obj = {}
       wrapped 'string', obj
       @callback.calledWith('string', obj).should.be.true

     it 'should accept an array of type parameters', ->
-      wrapped = varity [Date, RegExp], @callback
+      wrapped = $ [Date, RegExp], @callback
       date = new Date()
       reg = /.*/
       wrapped date, reg
       @callback.calledWith(date, reg).should.be.true

     it 'should accept an array of special parameters', ->
-      wrapped = varity [null, undefined, null], @callback
+      wrapped = $ [null, undefined, null], @callback
       wrapped null, undefined, null
       @callback.calledWith(null, undefined, null).should.be.true

     it 'should accept an array of mixed parameters', ->
-      wrapped = varity [null, 'string', Object, 'date', Function], @callback
+      wrapped = $ [null, 'string', Object, 'date', Function], @callback
       obj = {}
       date = new Date()
       fn = ->
@@ -377,7 +377,7 @@
       @callback.calledWith(null, 'string', obj, date, fn).should.be.true

     it 'should flatten an array of arrays with parameters', ->
-      wrapped = varity [['string', 'function'], ['object']], @callback
+      wrapped = $ [['string', 'function'], ['object']], @callback
       fn = ->
       obj = {}
       wrapped 'string', fn, obj
@@ -385,14 +385,14 @@

   context 'called with regular parameters and an array', ->
     it 'should accept parameters with a single array', ->
-      wrapped = varity 'string', [Object, Function], @callback
+      wrapped = $ 'string', [Object, Function], @callback
       fn = ->
       obj = {}
       wrapped 'string', obj, fn
       @callback.calledWith('string', obj, fn).should.be.true

     it 'should accept parameters with more than one array', ->
-      wrapped = varity [Array, Date], 'object', [undefined, 'infinity'], @callback
+      wrapped = $ [Array, Date], 'object', [undefined, 'infinity'], @callback
       arr = []
       date = new Date()
       obj = {}
@@ -402,67 +402,67 @@

   context 'called with string abbreviations', ->
     it 'should accept s', ->
-      wrapped = varity 's', @callback
+      wrapped = $ 's', @callback
       wrapped 'string'
       @callback.calledWith('string').should.be.true

     it 'should accept f', ->
-      wrapped = varity 'f', @callback
+      wrapped = $ 'f', @callback
       fn = ->
       wrapped fn
       @callback.calledWith(fn).should.be.true

     it 'should accept o', ->
-      wrapped = varity 'o', @callback
+      wrapped = $ 'o', @callback
       obj = {}
       wrapped obj
       @callback.calledWith(obj).should.be.true

     it 'should accept A', ->
-      wrapped = varity ' A', @callback
+      wrapped = $ ' A', @callback
       arr = []
       wrapped arr
       @callback.calledWith(arr).should.be.true

     it 'should accept 1', ->
-      wrapped = varity '1', @callback
+      wrapped = $ '1', @callback
       wrapped 2
       @callback.calledWith(2).should.be.true

     it 'should accept b', ->
-      wrapped = varity 'b', @callback
+      wrapped = $ 'b', @callback
       wrapped true
       @callback.calledWith(true).should.be.true

     it 'should accept d', ->
-      wrapped = varity 'd', @callback
+      wrapped = $ 'd', @callback
       date = new Date()
       wrapped date
       @callback.calledWith(date).should.be.true

     it 'should accept r', ->
-      wrapped = varity 'r', @callback
+      wrapped = $ 'r', @callback
       reg = /.*/
       wrapped reg
       @callback.calledWith(reg).should.be.true

     it 'should accept N', ->
-      wrapped = varity ' N', @callback
+      wrapped = $ ' N', @callback
       wrapped NaN
       @callback.args[0][0].should.be.NaN

     it 'should accept n', ->
-      wrapped = varity 'n', @callback
+      wrapped = $ 'n', @callback
       wrapped null
       @callback.calledWith(null).should.be.true

     it 'should accept u', ->
-      wrapped = varity 'u', @callback
+      wrapped = $ 'u', @callback
       wrapped undefined
       @callback.calledWith(undefined).should.be.true

     it 'should accept a', ->
-      wrapped = varity 'a', @callback
+      wrapped = $ 'a', @callback
       args = (->
         arguments
       ) 'one', 'two'
@@ -470,19 +470,19 @@
       @callback.calledWith(args).should.be.true

     it 'should accept i', ->
-      wrapped = varity 'i', @callback
+      wrapped = $ 'i', @callback
       wrapped Infinity
       @callback.calledWith(Infinity).should.be.true

     it 'should accept e', ->
-      wrapped = varity 'e', @callback
+      wrapped = $ 'e', @callback
       e = new Error()
       wrapped e
       @callback.calledWith(e).should.be.true

     it 'should accept E', (done) ->
       callback = @callback
-      wrapped = varity ' E', @callback
+      wrapped = $ ' E', @callback
       jsdom.env '

', (e, window) ->
         el = window.document.getElementById('id')
         wrapped el
@@ -491,7 +491,7 @@

     it 'should accept $', (done) ->
       callback = @callback
-      wrapped = varity '$', @callback
+      wrapped = $ '$', @callback
       jsdom.env '

', ["http://code.jquery.com/jquery.js"], (e, window) ->
         elems = window.$('div')
         wrapped elems
@@ -499,7 +499,7 @@
         done()

     it 'should accept a mix of letters', ->
-      wrapped = varity 'sfo1ne', @callback
+      wrapped = $ 'sfo1ne', @callback
       fn = ->
       obj = {}
       e = new Error()
@@ -507,7 +507,7 @@
       @callback.calledWith('string', fn, obj, 2, null, e).should.be.true

     it 'should accept a string with a space at the front', ->
-      wrapped = varity ' Ao', @callback
+      wrapped = $ ' Ao', @callback
       arr = []
       obj = {}
       wrapped arr, obj
@@ -516,13 +516,13 @@
     it 'should not accept other letters', ->
       callback = @callback
       (->
-        varity '9', callback
+        $ '9', callback
       ).should.throw('Unrecognized type: 9')

   context 'called with custom types', ->
     it 'should accept those types', ->
       class Foo
-      wrapped = varity 'Foo', @callback
+      wrapped = $ 'Foo', @callback
       f = new Foo()
       wrapped f
       @callback.calledWith(f).should.be.true
@@ -530,7 +530,7 @@
     it 'should accept multiple custom types', ->
       class Foo
       class Bar
-      wrapped = varity 'Foo', 'Bar', @callback
+      wrapped = $ 'Foo', 'Bar', @callback
       f = new Foo()
       b = new Bar()
       wrapped f, b
@@ -538,14 +538,14 @@

     it 'should accept camel case object names', ->
       class FooBaby
-      wrapped = varity 'FooBaby', @callback
+      wrapped = $ 'FooBaby', @callback
       fb = new FooBaby()
       wrapped fb
       @callback.calledWith(fb).should.be.true

     it 'should accept custom types with normal types', ->
       class Foo
-      wrapped = varity 'oAs', 'Foo', @callback
+      wrapped = $ 'oAs', 'Foo', @callback
       obj = {}
       arr = []
       f = new Foo
@@ -554,7 +554,7 @@

   context 'called with an object', ->
     it 'should accept a string type', ->
-      wrapped = varity
+      wrapped = $
         type: 'Array'
       , @callback
       arr = []
@@ -562,7 +562,7 @@
       @callback.calledWith(arr).should.be.true

     it 'should convert Object to AnonObject', ->
-      wrapped = varity
+      wrapped = $
         type: 'Object'
       , @callback
       obj = {}
@@ -570,7 +570,7 @@
       @callback.calledWith(obj).should.be.true

     it 'should convert Regexp to RegExp', ->
-      wrapped = varity
+      wrapped = $
         type: 'Regexp'
       , @callback
       reg = /.*/
@@ -578,14 +578,14 @@
       @callback.calledWith(reg).should.be.true

     it 'should convert Nan to NaN', ->
-      wrapped = varity
+      wrapped = $
         type: 'NaN'
       , @callback
       wrapped NaN
       @callback.args[0][0].should.be.NaN

     it 'should accept a real type', ->
-      wrapped = varity
+      wrapped = $
         type: Function
       , @callback
       fn = ->
@@ -593,7 +593,7 @@
       @callback.calledWith(fn).should.be.true

     it 'should accept optional', ->
-      wrapped = varity
+      wrapped = $
         type: 'Object'
         optional: true
       ,
@@ -604,7 +604,7 @@
       @callback.calledWith(undefined, {}).should.be.true

     it 'should accept populate', ->
-      wrapped = varity
+      wrapped = $
         type: 'Object',
         populate: true
       , @callback
@@ -612,7 +612,7 @@
       @callback.calledWith({}).should.be.true

     it 'should accept populate and optional', ->
-      wrapped = varity
+      wrapped = $
         type: 'Object'
         optional: 'true',
         populate: 'true'
@@ -627,7 +627,7 @@

     it 'should accept default on custom string types', ->
       class Foo
-      wrapped = varity
+      wrapped = $
         type: 'Foo'
         default: ->
           return new Foo()
@@ -637,7 +637,7 @@

     it 'should accept default on custom real types', ->
       class Foo
-      wrapped = varity
+      wrapped = $
         type: Foo
         default: ->
           return new Foo()
@@ -646,7 +646,7 @@
       @callback.args[0][0].should.be.an.instanceOf(Foo)

     it 'should accept default on built in types', ->
-      wrapped = varity
+      wrapped = $
         type: 'Object'
         default: ->
           return one: 1
@@ -655,7 +655,7 @@
       @callback.calledWith(one: 1).should.be.true

     it 'should accept non-function defaults', ->
-      wrapped = varity
+      wrapped = $
         type: 'Array'
         default: ['one', 'two']
       , @callback
@@ -663,7 +663,7 @@
       @callback.calledWith(['one', 'two']).should.be.true

     it 'should not override populate if passed together', ->
-      wrapped = varity
+      wrapped = $
         type: 'Array'
         populate: false
         default: ['one', 'two']
@@ -672,7 +672,7 @@
       @callback.calledWith(undefined).should.be.true

     it 'should accept a mix of objects', ->
-      wrapped = varity
+      wrapped = $
         type: 'Array'
       ,
         type: 'Object'
@@ -689,7 +689,7 @@
       @callback.calledWith(arr, undefined, obj, '').should.be.true

     it 'should accept objects with other parameters', ->
-      wrapped = varity 's-o', Object,
+      wrapped = $ 's-o', Object,
         type: 'Array',
         populate: true
         default: -> ['one', 'two']
@@ -700,7 +700,7 @@
       @callback.calledWith('string1', undefined, obj, ['one', 'two'], '', 'string2').should.be.true

     it 'should accept an options object after a string', ->
-      wrapped = varity 's+A',
+      wrapped = $ 's+A',
         defaults:
           'Array': ['one', 'two']
       , @callback
@@ -708,7 +708,7 @@
       @callback.calledWith('string', ['one', 'two']).should.be.true

     it 'should accept options after multiple strings', ->
-      wrapped = varity 'String', '_Array',
+      wrapped = $ 'String', '_Array',
         defaults:
           'Array': ['foobaby']
       , @callback
@@ -717,7 +717,7 @@

     it 'should accept a variety of options', ->
       class Foo
-      wrapped = varity 's~oA',
+      wrapped = $ 's~oA',
         populate: ['object', 'array']
         letters:
           '~': 'Foo'
@@ -731,73 +731,73 @@
   describe '~wrapper', ->
     context 'called with a missing param', ->
       it 'should pass undefined as the first param', ->
-        wrapped = varity 'sof', @callback
+        wrapped = $ 'sof', @callback
         obj = {}
         fn = ->
         wrapped obj, fn
         @callback.calledWith(undefined, obj, fn).should.be.true

       it 'should pass undefined as a middle param', ->
-        wrapped = varity 'sof', @callback
+        wrapped = $ 'sof', @callback
         fn = ->
         wrapped 'string', fn
         @callback.calledWith('string', undefined, fn).should.be.true

       it 'should pass undefined as the last param', ->
-        wrapped = varity 'sof', @callback
+        wrapped = $ 'sof', @callback
         obj = {}
         wrapped 'string', obj
         @callback.calledWith('string', obj, undefined).should.be.true

     context 'called with multiple missing params', ->
       it 'should accept two missing params next to each other', ->
-        wrapped = varity 'sof', @callback
+        wrapped = $ 'sof', @callback
         fn = ->
         wrapped fn
         @callback.calledWith(undefined, undefined, fn).should.be.true

       it 'should accept two missing params not next to each other', ->
-        wrapped = varity 'sof', @callback
+        wrapped = $ 'sof', @callback
         obj = {}
         wrapped obj
         @callback.calledWith(undefined, obj, undefined).should.be.true

       it 'should accept two missing params at the end', ->
-        wrapped = varity 'sof', @callback
+        wrapped = $ 'sof', @callback
         wrapped 'string'
         @callback.calledWith('string', undefined, undefined).should.be.true

     context 'called with multiple params of the same type in a row', ->
       it 'should pass the first instance of that type', ->
-        wrapped = varity 'off', @callback
+        wrapped = $ 'off', @callback
         obj = {}
         fn = ->
         wrapped obj, fn
         @callback.calledWith(obj, fn, undefined).should.be.true

       it 'should allow overriding the default behavior with - on types', ->
-        wrapped = varity 'Object', '-Function', 'Function', @callback
+        wrapped = $ 'Object', '-Function', 'Function', @callback
         obj = {}
         fn = ->
         wrapped obj, fn
         @callback.calledWith(obj, undefined, fn).should.be.true

       it 'should allow overriding the default behavior with - on abbreviations', ->
-        wrapped = varity 'o-ff', @callback
+        wrapped = $ 'o-ff', @callback
         obj = {}
         fn = ->
         wrapped obj, fn
         @callback.calledWith(obj, undefined, fn).should.be.true

       it 'should allow multiple -\'s not next to each other', ->
-        wrapped = varity ' -oo-ff', @callback
+        wrapped = $ ' -oo-ff', @callback
         obj = {}
         fn = ->
         wrapped obj, fn
         @callback.calledWith(undefined, obj, undefined, fn).should.be.true

       it 'should allow multiple -\'s next to each other', ->
-        wrapped = varity 'f-A-AA', @callback
+        wrapped = $ 'f-A-AA', @callback
         fn = ->
         arr = []
         wrapped fn, arr
@@ -807,8 +807,8 @@
       it 'should allow multiple functions to be wrapped', ->
         @callback1 = sinon.spy()
         @callback2 = sinon.spy()
-        wrapped1 = varity 'soA', @callback1
-        wrapped2 = varity 'fed', @callback2
+        wrapped1 = $ 'soA', @callback1
+        wrapped2 = $ 'fed', @callback2
         obj = {}
         arr = []
         fn = ->
@@ -820,7 +820,7 @@
         @callback2.calledWith(fn, e, date).should.be.true

       it 'should allow the same wrapper to be called more than once', ->
-        wrapped = varity 'so', @callback
+        wrapped = $ 'so', @callback
         wrapped 'string'
         obj = {}
         wrapped obj
@@ -830,10 +830,10 @@
         @callback.getCall(1).args[1].should.equal(obj)

       it 'should keep the same options when configure is used', ->
-        varity.configure populate: ['Object']
+        $.configure populate: ['Object']
         @callback2 = sinon.spy()
-        wrapped1 = varity 'o', @callback
-        wrapped2 = varity 'so', @callback2
+        wrapped1 = $ 'o', @callback
+        wrapped2 = $ 'so', @callback2
         wrapped1()
         wrapped2 'string'
         @callback.calledWith({}).should.be.true
@@ -841,80 +841,80 @@

     context 'called with object expansion', ->
       it 'should convert s to \'\'', ->
-        wrapped = varity 's+s', @callback
+        wrapped = $ 's+s', @callback
         wrapped 'string'
         @callback.calledWith('string', '').should.be.true

       it 'should convert String to \'\'', ->
-        wrapped = varity 'String', '+String', @callback
+        wrapped = $ 'String', '+String', @callback
         wrapped 'string'
         @callback.calledWith('string', '').should.be.true

       it 'should convert Function to ->', ->
-        wrapped = varity 'String', '+Function', @callback
+        wrapped = $ 'String', '+Function', @callback
         wrapped 'string'
         @callback.args[0][0].should.equal('string')
         @callback.args[0][1].toString().should.equal('function (){}')

       it 'should convert f to ->', ->
-        wrapped = varity 's+f', @callback
+        wrapped = $ 's+f', @callback
         wrapped 'string'
         @callback.args[0][0].should.equal('string')
         @callback.args[0][1].toString().should.equal('function (){}')

       it 'should convert o to {}', ->
-        wrapped = varity 's+of', @callback
+        wrapped = $ 's+of', @callback
         fn = ->
         wrapped 'string', fn
         @callback.calledWith('string', {}, fn).should.be.true

       it 'should convert Object to {}', ->
-        wrapped = varity 'String', '+Object', @callback
+        wrapped = $ 'String', '+Object', @callback
         wrapped 'string'
         @callback.calledWith('string', {}).should.be.true

       it 'should convert A to []', ->
-        wrapped = varity 's+A', @callback
+        wrapped = $ 's+A', @callback
         wrapped 'string'
         @callback.calledWith('string', []).should.be.true

       it 'should convert Array to []', ->
-        wrapped = varity 'String', '+Array', @callback
+        wrapped = $ 'String', '+Array', @callback
         wrapped 'string'
         @callback.calledWith('string', []).should.be.true

       it 'should convert Number to 0', ->
-        wrapped = varity 'String', '+Number', @callback
+        wrapped = $ 'String', '+Number', @callback
         wrapped 'string'
         @callback.calledWith('string', 0).should.be.true

       it 'should convert 1 to 0', ->
-        wrapped = varity 's+1', @callback
+        wrapped = $ 's+1', @callback
         wrapped 'string'
         @callback.calledWith('string', 0).should.be.true

       it 'should convert Boolean to false', ->
-        wrapped = varity 'String', '+Boolean', @callback
+        wrapped = $ 'String', '+Boolean', @callback
         wrapped 'string'
         @callback.calledWith('string', false).should.be.true

       it 'should convert b to false', ->
-        wrapped = varity 's+b', @callback
+        wrapped = $ 's+b', @callback
         wrapped 'string'
         @callback.calledWith('string', false).should.be.true

       it 'should convert RegExp to /.*/', ->
-        wrapped = varity 'String', '+RegExp', @callback
+        wrapped = $ 'String', '+RegExp', @callback
         wrapped 'string'
         @callback.calledWith('string', /.*/).should.be.true

       it 'should convert r to []', ->
-        wrapped = varity 's+r', @callback
+        wrapped = $ 's+r', @callback
         wrapped 'string'
         @callback.calledWith('string', /.*/).should.be.true

       it 'should convert Date to today\'s date', ->
-        wrapped = varity 'String', '+Date', @callback
+        wrapped = $ 'String', '+Date', @callback
         d = new Date()
         wrapped 'string'
         @callback.args[0][0].should.equal('string')
@@ -924,7 +924,7 @@
         arg.getFullYear().should.equal(d.getFullYear())

       it 'should convert d to today\'s date', ->
-        wrapped = varity 's+d', @callback
+        wrapped = $ 's+d', @callback
         d = new Date()
         wrapped 'string'
         @callback.args[0][0].should.equal('string')
@@ -934,39 +934,39 @@
         arg.getFullYear().should.equal(d.getFullYear())

       it 'should convert NaN to NaN', ->
-        wrapped = varity 'String', '+NaN', @callback
+        wrapped = $ 'String', '+NaN', @callback
         wrapped 'string'
         @callback.args[0][0].should.equal('string')
         @callback.args[0][1].should.be.NaN

       it 'should convert N to NaN', ->
-        wrapped = varity 's+N', @callback
+        wrapped = $ 's+N', @callback
         wrapped 'string'
         @callback.args[0][0].should.equal('string')
         @callback.args[0][1].should.be.NaN

       it 'should convert Null to null', ->
-        wrapped = varity 'String', '+Null', @callback
+        wrapped = $ 'String', '+Null', @callback
         wrapped 'string'
         @callback.calledWith('string', null).should.be.true

       it 'should convert n to null', ->
-        wrapped = varity 's+n', @callback
+        wrapped = $ 's+n', @callback
         wrapped 'string'
         @callback.calledWith('string', null).should.be.true

       it 'should convert Undefined to undefined', ->
-        wrapped = varity 'String', '+Undefined', @callback
+        wrapped = $ 'String', '+Undefined', @callback
         wrapped 'string'
         @callback.calledWith('string', undefined).should.be.true

       it 'should convert u to undefined', ->
-        wrapped = varity 's+u', @callback
+        wrapped = $ 's+u', @callback
         wrapped 'string'
         @callback.calledWith('string', undefined).should.be.true

       it 'should convert Arguments to arguments', ->
-        wrapped = varity 'String', '+Arguments', @callback
+        wrapped = $ 'String', '+Arguments', @callback
         wrapped 'string'
         @callback.args[0][0].should.equal('string')
         @callback.args[0][1].should.have.property('length')
@@ -974,7 +974,7 @@
         should.equal(@callback.args[0][1][0], undefined)

       it 'should convert a to arguments', ->
-        wrapped = varity 's+a', @callback
+        wrapped = $ 's+a', @callback
         wrapped 'string'
         @callback.args[0][0].should.equal('string')
         @callback.args[0][1].should.have.property('length')
@@ -982,24 +982,24 @@
         should.equal(@callback.args[0][1][0], undefined)

       it 'should convert Infinity to Infinity', ->
-        wrapped = varity 'String', '+Infinity', @callback
+        wrapped = $ 'String', '+Infinity', @callback
         wrapped 'string'
         @callback.calledWith('string', Infinity).should.be.true

       it 'should convert i to Infinity', ->
-        wrapped = varity 's+i', @callback
+        wrapped = $ 's+i', @callback
         wrapped 'string'
         @callback.calledWith('string', Infinity).should.be.true

       it 'should convert Error to a new error', ->
-        wrapped = varity 'String', '+Error', @callback
+        wrapped = $ 'String', '+Error', @callback
         wrapped 'string'
         @callback.args[0][0].should.equal('string')
         @callback.args[0][1].constructor.name.should.equal('Error')
         @callback.args[0][1].message.should.equal('')

       it 'should convert e to a new error', ->
-        wrapped = varity 's+e', @callback
+        wrapped = $ 's+e', @callback
         wrapped 'string'
         @callback.args[0][0].should.equal('string')
         @callback.args[0][1].constructor.name.should.equal('Error')
@@ -1007,29 +1007,29 @@

       # TODO: How to spy on window.document?
       it 'should convert E to document', ->
-        wrapped = varity 's+E', @callback
+        wrapped = $ 's+E', @callback
         wrapped 'string'
         @callback.calledWith('string', '

').should.be.true

       it 'should convert $ to $(document)', ->
-        wrapped = varity 's+$', @callback
+        wrapped = $ 's+$', @callback
         wrapped 'string'
         @callback.calledWith('string', []).should.be.true

       it 'should work with - on different abbreviations', ->
-        wrapped = varity 's-oo+A', @callback
+        wrapped = $ 's-oo+A', @callback
         obj = {}
         wrapped 'string', obj
         @callback.calledWith('string', undefined, obj, []).should.be.true

       it 'should work with - on different types', ->
-        wrapped = varity 'String', '-Object', 'Object', '+Array', @callback
+        wrapped = $ 'String', '-Object', 'Object', '+Array', @callback
         obj = {}
         wrapped 'string', obj
         @callback.calledWith('string', undefined, obj, []).should.be.true

       it 'should work with - on the same abbreviation', ->
-        wrapped = varity 's-+oo', @callback
+        wrapped = $ 's-+oo', @callback
         obj =
           one: 1
           two: 2
@@ -1037,7 +1037,7 @@
         @callback.calledWith('string', {}, obj).should.be.true

       it 'should work with - on the same type', ->
-        wrapped = varity 'String', '-+Object', 'Object', @callback
+        wrapped = $ 'String', '-+Object', 'Object', @callback
         obj =
           one: 1
           two: 2
@@ -1045,7 +1045,7 @@
         @callback.calledWith('string', {}, obj).should.be.true

       it 'should work with - the other way around', ->
-        wrapped = varity 'String', '+-Object', 'Object', @callback
+        wrapped = $ 'String', '+-Object', 'Object', @callback
         obj =
           one: 1
           two: 2
@@ -1054,39 +1054,39 @@

     context 'called with non-empty indicator', ->
       it 'should expand an empty object', ->
-        varity.configure
+        $.configure
           defaults:
             'Object':
               'not': 'empty'
-        wrapped = varity 's_o', @callback
+        wrapped = $ 's_o', @callback
         wrapped 'string', {}
         @callback.calledWith('string', not: 'empty').should.be.true

       it 'should expand undefined', ->
-        wrapped = varity 's_A', @callback
+        wrapped = $ 's_A', @callback
         wrapped 'string'
         @callback.calledWith('string', []).should.be.true

     context 'called with required indicator', ->
       it 'should throw an error if the required parameter is undefined', ->
-        wrapped = varity '*String', @callback
+        wrapped = $ '*String', @callback
         (->
           wrapped()
         ).should.throw('A required parameter was missing from the wrapped function')

       it 'should handle a required parameter followed by a non-required one', ->
-        wrapped = varity ' *ss', @callback
+        wrapped = $ ' *ss', @callback
         wrapped('string')
         @callback.calledWith('string', undefined).should.be.true

       it 'should handle a parameter followed by a required one (different types)', ->
-        wrapped = varity ' *so', @callback
+        wrapped = $ ' *so', @callback
         (->
           wrapped {}
         ).should.throw('A required parameter was missing from the wrapped function')

       it 'should handle a parameter followed by a required one (same type)', ->
-        wrapped = varity 's*s', @callback
+        wrapped = $ 's*s', @callback
         (->
           wrapped 'string'
         ).should.throw('A required parameter was missing from the wrapped function')
@@ -1094,14 +1094,14 @@
   describe '#reset', ->
     it 'should restore the defaults', ->
       callback2 = sinon.spy()
-      varity.configure
+      $.configure
         letters:
           'A': 'Apples'
-      wrapped = varity ' A', @callback
+      wrapped = $ ' A', @callback
       wrapped []
       @callback.calledWith(undefined).should.be.true
-      varity.reset()
-      wrapped2 = varity ' A', callback2
+      $.reset()
+      wrapped2 = $ ' A', callback2
       arr = []
       wrapped2 arr
       callback2.calledWith(arr).should.be.true
@@ -1109,21 +1109,21 @@
   describe '#configure', ->
     context 'called with letters', ->
       it 'should add new letters', ->
-        varity.configure
+        $.configure
           letters:
             'X': 'XtraLg'
-        wrapped = varity ' Xo', @callback
+        wrapped = $ ' Xo', @callback
         class XtraLg
         x = new XtraLg()
         obj = {}
         wrapped x, obj

       it 'should override changed letters', ->
-        varity.configure
+        $.configure
           letters:
             'a': 'Array',
             'A': 'Arguments'
-        wrapped = varity 'a', @callback
+        wrapped = $ 'a', @callback
         arr = []
         wrapped arr
         @callback.calledWith(arr).should.be.true
@@ -1131,34 +1131,34 @@
     context 'called with defaults', ->
       it 'should allow new items', ->
         class Foo
-        varity.configure
+        $.configure
           defaults:
            'Foo': ->
               return new Foo()
-        wrapped = varity '+Foo', @callback
+        wrapped = $ '+Foo', @callback
         wrapped()
         @callback.args[0][0].should.be.an.instanceOf(Foo)

       it 'should allow overrides', ->
-        varity.configure
+        $.configure
           defaults:
             'Array': ['one', 'two']
-        wrapped = varity '+Array', @callback
+        wrapped = $ '+Array', @callback
         wrapped()
         @callback.calledWith(['one', 'two']).should.be.true

     context 'called with populate', ->
       it 'should expand any missing params', ->
-        varity.configure
+        $.configure
           populate: true
-        wrapped = varity 'so', @callback
+        wrapped = $ 'so', @callback
         wrapped 'string'
         @callback.calledWith('string', {}).should.be.true

       it 'should expand passed in param types', ->
-        varity.configure
+        $.configure
           populate: ['Array', 'Object']
-        wrapped = varity 'oAs', @callback
+        wrapped = $ 'oAs', @callback
         wrapped()
         @callback.calledWith({}, [], undefined).should.be.true

@@ -1167,7 +1167,7 @@
         class FooBaby
           birth: ->
             return 'FOO BABY!'
-        varity.configure
+        $.configure
           populate: ['Object', 'Date']
           defaults:
             'Date': ->
@@ -1178,7 +1178,7 @@
               return new FooBaby().birth()
           letters:
             '~': 'FooBaby'
-        wrapped = varity 'Object', 'Date', 'Error', '-+Error', ' +~', @callback
+        wrapped = $ 'Object', 'Date', 'Error', '-+Error', ' +~', @callback
         wrapped()
         args = @callback.args[0]
         args[0].should.eql({})


Simplify walker test.

Simplify walker test.

--- test/walker.coffee
+++ test/walker.coffee
@@ -6,17 +6,12 @@
   it 'works', ->
     ast =
       type: 'Program'
-      body:
-        type: 'Identifier'
-        value: 'hi'
+      body: { type: 'Identifier', value: 'hi' }

     class MyWalker extends Walker
       visitors:
-        Program: (node) ->
-          @walk node.body
-
-        Identifier: (node) ->
-          node.value
+        Program: (node) -> @walk node.body
+        Identifier: (node) -> node.value

     output = new MyWalker(ast).run()
     expect(output).eql 'hi'


[grunt] added missing `node-gettext` functions as globals for Nunjucks

--- tasks/grunt-nunjucks-2-html.coffee
+++ tasks/grunt-nunjucks-2-html.coffee
@@ -127,8 +127,8 @@
           ###*
           * Load string from current locale
           * @note So far `sprintf` support only named placeholders
-          * @param  {string} string  String, which should be loaded
-          * @param  {object} ph = {} Values, which will be inserted instead of placeholders
+          * @param {string} string  String, which should be loaded
+          * @param {object} ph = {} Values, which will be inserted instead of placeholders
           * @return {string} Translated string into current locale
           ###
           env.addGlobal '_t', (string, ph = {}) ->
@@ -137,13 +137,88 @@
           ###*
            * Load string from specified locale
            * @note So far `sprintf` support only named placeholders
-           * @param  {string} locale = currentLocale Locale, from which string should be loaded
-           * @param  {string} string                 String, which should be loaded
-           * @param  {object} ph     = {}            Values, which will be inserted instead of placeholders
+           * @param {string} locale = currentLocale Locale, from which string should be loaded
+           * @param {string} string                 String, which should be loaded
+           * @param {object} ph     = {}            Values, which will be inserted instead of placeholders
            * @return {string} Translated string into specified locale
           ###
           env.addGlobal '_dt', (locale = currentLocale, string, ph = {}) ->
             sprintf(i18n.dgettext(locale, string), ph)
+
+          ###*
+          * Load plural string from current locale
+          * @note So far `sprintf` support only named placeholders
+          * @param {string} string       String, which should be loaded
+          * @param {string} stringPlural Plural form of string
+          * @param {number} count        Count for detecting correct plural form
+          * @param {object} ph = {}      Values, which will be inserted instead of placeholders
+          * @return {string} Pluralized and translated into current locale string
+          ###
+          env.addGlobal '_nt', (string, stringPlural, count, ph = {}) ->
+            sprintf(i18n.dngettext(currentLocale, string, stringPlural, count), ph)
+
+          ###*
+           * Load plural string from specified locale
+           * @note So far `sprintf` support only named placeholders
+           * @param {string} locale = currentLocale Locale, from which string should be loaded
+           * @param {string} string                 String, which should be loaded
+           * @param {string} stringPlural           Plural form of string
+           * @param {number} count                  Count for detecting correct plural form
+           * @param {object} ph     = {}            Values, which will be inserted instead of placeholders
+           * @return {string} Pluralized and translated into specified loca stringle
+          ###
+          env.addGlobal '_dnt', (locale = currentLocale, string, stringPlural, count, ph = {}) ->
+            sprintf(i18n.dngettext(locale, string, stringPlural, count), ph)
+
+          ###*
+          * Load string of specific context from current locale
+          * @note So far `sprintf` support only named placeholders
+          * @param {string} context Context of curret string
+          * @param {string} string  String, which should be loaded
+          * @param {object} ph = {} Values, which will be inserted instead of placeholders
+          * @return {string} Translated string into current locale
+          ###
+          env.addGlobal '_pt', (context, string, ph = {}) ->
+            sprintf(i18n.dpgettext(currentLocale, context, string), ph)
+
+          ###*
+           * Load string of specific context from specified locale
+           * @note So far `sprintf` support only named placeholders
+           * @param {string} locale = currentLocale Locale, from which string should be loaded
+           * @param {string} context                Context of curret string
+           * @param {string} string                 String, which should be loaded
+           * @param {object} ph     = {}            Values, which will be inserted instead of placeholders
+           * @return {string} Translated string into specified locale
+          ###
+          env.addGlobal '_dpt', (locale = currentLocale, context, string, ph = {}) ->
+            sprintf(i18n.dpgettext(locale, context, string), ph)
+
+          ###*
+          * Load plural string of specific context from current locale
+          * @note So far `sprintf` support only named placeholders
+          * @param {string} context      Context of curret string
+          * @param {string} string       String, which should be loaded
+          * @param {string} stringPlural Plural form of string
+          * @param {number} count        Count for detecting correct plural form
+          * @param {object} ph = {}      Values, which will be inserted instead of placeholders
+          * @return {string} Pluralized and translated into current locale string
+          ###
+          env.addGlobal '_npt', (context, string, stringPlural, count, ph = {}) ->
+            sprintf(i18n.dnpgettext(currentLocale, context, string, stringPlural, count), ph)
+
+          ###*
+           * Load plural string of specific context from specified locale
+           * @note So far `sprintf` support only named placeholders
+           * @param {string} locale = currentLocale Locale, from which string should be loaded
+           * @param {string} context                Context of curret string
+           * @param {string} string                 String, which should be loaded
+           * @param {string} stringPlural           Plural form of string
+           * @param {number} count                  Count for detecting correct plural form
+           * @param {object} ph     = {}            Values, which will be inserted instead of placeholders
+           * @return {string} Pluralized and translated into specified loca stringle
+          ###
+          env.addGlobal '_dnpt', (locale = currentLocale, context, string, stringPlural, count, ph = {}) ->
+            sprintf(i18n.dnpgettext(locale, context, string, stringPlural, count), ph)

           # =======
           # Filters
@@ -175,8 +250,8 @@
           ###*
            * Append string with locale name based on whether it's base locale or not
            * Most useful for urls construction
-           * @param  {string} string                 Target string
-           * @param  {string} locale = currentLocale Locale name, for which resolving should be made
+           * @param {string} string                 Target string
+           * @param {string} locale = currentLocale Locale name, for which resolving should be made
            * @return {string} String with resolved locale in front
           ###
           env.addFilter 'resolveUrl', (string, locale = currentLocale) ->
@@ -184,7 +259,7 @@

           ###*
            * Output or not locale name based on whether it's base locale or not.
-           * @param  {string} locale Name of locale, for which should be made resolving
+           * @param {string} locale Name of locale, for which should be made resolving
            * @return {string} Resolved value
           ###
           env.addFilter 'resolveLocaleDir', (locale) ->


rtmp: Do not use metadata to check if audio/video stream exists

--- rtmp.coffee
+++ rtmp.coffee
@@ -1316,12 +1316,6 @@
   receiveSetDataFrame: (requestData) ->
     if requestData.objects[1].value is 'onMetaData'
       console.log "[rtmp:receive] @setDataFrame onMetaData"
-      metadata = requestData.objects[2].value
-      # TODO: Are metadata keys always lowercase?
-      if metadata.audiocodecid?  # has audio stream
-        @emit 'audio_start'
-      if metadata.videocodecid?  # has video stream
-        @emit 'video_start'
     else
       throw new Error "Unknown @setDataFrame: #{requestData.objects[1].value}"

@@ -1377,6 +1371,8 @@
       streamName = publishingName

     @emit 'stream_reset'
+    @isFirstVideoReceived = false
+    @isFirstAudioReceived = false

     publishStart = createAMF0CommandMessage
       chunkStreamID: 4
@@ -1835,12 +1831,18 @@
             when 8  # Audio Message (incoming)
               audioData = parseAudioMessage rtmpMessage.body
               if audioData.adtsFrame?
+                if not @isFirstAudioReceived
+                  @emit 'audio_start'
+                  @isFirstAudioReceived = true
                 pts = dts = flv.convertMsToPTS rtmpMessage.timestamp
                 @emit 'audio_data', pts, dts, audioData.adtsFrame
               seq.done()
             when 9  # Video Message (incoming)
               videoData = parseVideoMessage rtmpMessage.body
               if videoData.nalUnitGlob?
+                if not @isFirstVideoReceived
+                  @emit 'video_start'
+                  @isFirstVideoReceived = true
                 dts = rtmpMessage.timestamp
                 pts = dts + videoData.info.videoDataTag.compositionTime
                 pts = flv.convertMsToPTS pts


test_crosstab.coffee: remove trailing whitespace

--- test/crosstab/test_crosstab.coffee
+++ test/crosstab/test_crosstab.coffee
@@ -5,7 +5,7 @@
     markers = ["D1M430", "D1M318"]
     mychart = crosstab()

-    data2pass =
+    data2pass =
             x: data.geno[markers[0]]
             y: data.geno[markers[1]]
             xcat: data.genocat[data.chrtype[markers[0]]]
@@ -22,7 +22,7 @@
     markers = ["DXM64", "DXM66"]
     mychart = crosstab()

-    data2pass =
+    data2pass =
             x: data.geno[markers[0]]
             y: data.geno[markers[1]]
             xcat: data.genocat[data.chrtype[markers[0]]]
@@ -39,7 +39,7 @@
     markers = ["D1M430", "DXM64"]
     mychart = crosstab()

-    data2pass =
+    data2pass =
             x: data.geno[markers[0]]
             y: data.geno[markers[1]]
             xcat: data.genocat[data.chrtype[markers[0]]]
@@ -50,5 +50,3 @@
     d3.select("div#chart3")
       .datum(data2pass)
       .call(mychart)
-
-


Provide $.fn.originalTrigger to bypass deprecation warning

--- src/space-pen.coffee
+++ src/space-pen.coffee
@@ -481,7 +481,7 @@
   JQueryEventAdd.call(this, elem, types, handler, data, selector)

-JQueryTrigger = $.fn.trigger
+$.fn.originalTrigger = $.fn.trigger
 $.fn.trigger = (eventName, data) ->
   if typeof eventName is 'string' and /\:/.test(eventName) and eventName not in ['cursor:moved', 'selection:changed', 'editor:display-updated']
     Grim?.deprecate """
@@ -491,8 +491,7 @@
       See the docs at https://atom.io/docs/api/latest/CommandRegistry#instance-dispatch
       for details.
     """
-  else
-    JQueryTrigger.call(this, eventName, data)
+  @originalTrigger(eventName, data)

 $.fn.setTooltip = ->
   throw new Error """


Use querySelectorAll when calling attach hooks

--- src/space-pen.coffee
+++ src/space-pen.coffee
@@ -197,7 +197,9 @@

   elementsWithHooks = []
   elementsWithHooks.push(element[0]) if element.attr?('callAttachHooks')
-  elementsWithHooks = elementsWithHooks.concat(element.find?('[callAttachHooks]').toArray() ? []) if onDom
+  if onDom
+    for child in element[0].querySelectorAll('[callAttachHooks]')
+      elementsWithHooks.push(child)

   $(element).view()?.afterAttach?(onDom) for element in elementsWithHooks


fix computation of size of file_use notification box

--- salvus/page/file_use.cjsx
+++ salvus/page/file_use.cjsx
@@ -540,7 +540,7 @@
     if not notification_list.is(":visible")
         return
     notification_list.removeAttr('style')  # gets rid of the custom height from before
-    max_height = $(window).height() - notification_list.offset().top - 50
+    max_height = $(window).height() - 50
     if notification_list.height() > max_height
         notification_list.height(max_height)
     # hack since on some browser scrollbar looks wrong otherwise.


file_use: enter to open file also broken by switch to immutable.js

--- salvus/page/file_use.cjsx
+++ salvus/page/file_use.cjsx
@@ -424,8 +424,9 @@
             <Icon name='check-square'/> Mark all Read
         </Button>

-    open_selected : (e) ->
-        open_file_use_entry(@_visible_list?[@state.cursor], @props.flux)
+    open_selected: ->
+        console.log("open_selected")
+        open_file_use_entry(@_visible_list?[@state.cursor].toJS(), @props.flux)
         hide_notification_list()

     render_list : ->


tune layout of create-task-type-form; #290

--- app/assets/javascripts/admin/views/tasktype/task_type_form_view.coffee
+++ app/assets/javascripts/admin/views/tasktype/task_type_form_view.coffee
@@ -10,100 +10,105 @@
 class TaskTypeFormView extends Backbone.Marionette.Layout

   template : _.template("""
-

+

Task types

         <form method="POST" class="form-horizontal">
-

-            Summary
-

-              <input type="text" id="summary" name="summary" value="" class="form-control"
-               required pattern=".{3,50}" title="Please use at least 3 characters.">
-

+

+

+              Summary
+

+                <input type="text" id="summary" name="summary" value="" class="form-control"
+                 required pattern=".{3,50}" title="Please use at least 3 characters.">
+

+

+
+

+              Team
+

+

+

+
+

+              Description
+

+                <textarea id="description" name="description" class="form-control"></textarea>
+

+

+

-
-

-            Team
-

-

-

-
-

-            Description
-

-              <textarea id="description" name="description" class="form-control"></textarea>
-

-

-
-

-            Allow Oxalis
-

-              <input type="checkbox" id="oxalisAllowed" name="allowedModes[]" value="oxalis" checked>
-
-

-

-
-

-            Allow Arbitrary
-

-              <input type="checkbox" id="arbitraryAllowed" name="allowedModes[]" value="arbitrary" checked>
-
-

-

-
-

-            Allow Branchpoints
-

-              <input type="checkbox" id="branchPointsAllowed" name="branchPointsAllowed" value="true" checked>
-
-

-

-
-

-            Allow Soma clicking
-

-              <input type="checkbox" id="somaClickingAllowed" name="somaClickingAllowed" value="true" checked>
-
-

-

-
-

-            Expected Time (min)
-

-

-                <input type="number" id="expectedTime_minTime" name="expectedTime.minTime"
-                  value="5" min="0" input-append="hours" class="form-control" required>
-                hours
-

-

-

-
-

-            Expected Time (max)
-

-

-                <input type="number" id="expectedTime_maxTime" name="expectedTime.maxTime"
-                  value="10" min="0" input-append="hours" class="form-control" required>
-                hours
-

-

-

-
-

-            Time limit
-

-

-                <input type="number" id="expectedTime_maxHard" name="expectedTime.maxHard"
-                  value="15" min="0" input-append="hours" class="form-control" required>
-                hours
-

-

-

-
-

-

-              <button type="submit" class="form-control btn btn-primary">Create</button>
-

-

+

+
+

+              Allow Arbitrary
+

+                <input type="checkbox" id="arbitraryAllowed" name="allowedModes[]" value="arbitrary" checked>
+
+

+

+
+

+              Allow Oxalis
+

+                <input type="checkbox" id="oxalisAllowed" name="allowedModes[]" value="oxalis" checked>
+
+

+

+
+

+              Allow Soma clicking
+

+                <input type="checkbox" id="somaClickingAllowed" name="somaClickingAllowed" value="true" checked>
+
+

+

+
+

+              Allow Branchpoints
+

+                <input type="checkbox" id="branchPointsAllowed" name="branchPointsAllowed" value="true" checked>
+
+

+

+
+

+              Expected Time (min)
+

+

+                  <input type="number" id="expectedTime_minTime" name="expectedTime.minTime"
+                    value="5" min="0" input-append="hours" class="form-control" required>
+                  hours
+

+

+

+
+

+              Expected Time (max)
+

+

+                  <input type="number" id="expectedTime_maxTime" name="expectedTime.maxTime"
+                    value="10" min="0" input-append="hours" class="form-control" required>
+                  hours
+

+

+

+
+

+              Time limit
+

+

+                  <input type="number" id="expectedTime_maxHard" name="expectedTime.maxHard"
+                    value="15" min="0" input-append="hours" class="form-control" required>
+                  hours
+

+

+

+
+

+

+                <button type="submit" class="form-control btn btn-primary">Create</button>
+

+

+

       </form>

   """)


Fixes #510

Fixes #510

--- src/upgradeDB.coffee
+++ src/upgradeDB.coffee
@@ -57,10 +57,11 @@
           clientDefer = Q.defer()
           promises.push clientDefer.promise

-          for cert in keystore.ca
-            if client.clientDomain is cert.commonName and not client.certFingerprint?
-              client.certFingerprint = cert.fingerprint
-              break
+          if keystore?.ca?
+            for cert in keystore.ca
+              if client.clientDomain is cert.commonName and not client.certFingerprint?
+                client.certFingerprint = cert.fingerprint
+                break

           do (clientDefer) ->
             client.save (err) ->


:art: use atom-text-editor for input

:art: use atom-text-editor for input

--- src/vdom/root.coffee
+++ src/vdom/root.coffee
@@ -8,14 +8,11 @@
   { bodyHeightBus } = buses

   return h 'div.atom-notational', [
-    h 'div', {
-        className: 'block search'
-      }, h 'input', {
-          className: 'native-key-bindings input'
-          type: 'text',
-          placeholder: 'Search, or press enter to create a new untitled file'
-          autocomplete: 'off'
-        }
+    h 'atom-text-editor', {
+        placeholder: 'Search, or press enter to create a new untitled file'
+        attributes:
+          mini: 'true'
+      }

     h 'div.header',
       h 'table',


Fix unit tests

Fix unit tests

--- services/web/test/UnitTests/coffee/Project/ProjectEntityHandlerTests.coffee
+++ services/web/test/UnitTests/coffee/Project/ProjectEntityHandlerTests.coffee
@@ -180,21 +180,13 @@

 		describe "a doc", ->
 			beforeEach (done) ->
-				@ProjectEntityHandler._cleanUpEntity @project, _id: @entity_id, 'doc', done
-
-			it "should not attempted to delete from FileStoreHandler", ->
-				@FileStoreHandler.deleteFile.called.should.equal false
-
-			it "should delete the doc from the document updater", ->
-				@documentUpdaterHandler.deleteDoc.calledWith(project_id, @entity_id).should.equal true
-
-		describe "when the entity is the root document", ->
-			beforeEach (done) ->
-				@project.rootDoc_id = new ObjectId(@entity_id)
-				@ProjectEntityHandler._cleanUpEntity @project, _id: @entity_id, 'doc', done
-
-			it "should unset the root doc id", ->
-				@ProjectEntityHandler.unsetRootDoc.calledWith(project_id).should.equal true
+				@ProjectEntityHandler._cleanUpDoc = sinon.stub().callsArg(3)
+				@ProjectEntityHandler._cleanUpEntity @project, @entity = {_id: @entity_id}, 'doc', done
+
+			it "should clean up the doc", ->
+				@ProjectEntityHandler._cleanUpDoc
+					.calledWith(@project, @entity)
+					.should.equal true

 		describe "a folder", ->
 			beforeEach (done) ->


Add backticks around URLs for style consistency

--- src/workspace.coffee
+++ src/workspace.coffee
@@ -511,9 +511,9 @@
   # in the current pane. The searchAllPanes flag expands the search from the
   # current pane to all panes. If you wish to open a view of a different type for
   # a file that is already open, consider changing the protocol of the URI. For
-  # example, perhaps you wish to preview a rendered version of the file /foo/bar/baz.quux
+  # example, perhaps you wish to preview a rendered version of the file `/foo/bar/baz.quux`
   # that is already open in a text editor view. You could signal this by calling
-  # {Workspace::open} on the URI quux-preview://foo/bar/baz.quux. Then your opener
+  # {Workspace::open} on the URI `quux-preview://foo/bar/baz.quux`. Then your opener
   # can check the protocol for quux-preview and only handle those URIs that match.
   addOpener: (opener) ->
     if includeDeprecatedAPIs


Allow changing font family

Allow changing font family

--- coffee/core/widgets.coffee
+++ coffee/core/widgets.coffee
@@ -100,6 +100,16 @@

 class LC.TextWidget extends LC.ToolWidget

+  getFamilies: -> [
+    {name: 'Sans-serif', value: '"Helvetica Neue",Helvetica,Arial,sans-serif'},
+    {name: 'Serif', value: (
+      'Garamond,Baskerville,"Baskerville Old Face",'
+      '"Hoefler Text","Times New Roman",serif')}
+    {name: 'Typewriter', value: (
+      '"Courier New",Courier,"Lucida Sans Typewriter",'
+      '"Lucida Typewriter",monospace')},
+  ]
+
   title: "Text"
   cssSuffix: "text"

@@ -108,7 +118,7 @@

   button: -> ""
   select: (lc) ->
-    @updateToolStyle()
+    @updateTool()
     lc.setTool(@tool)
     # not sure why we need to defer this, but I don't get paid enough to work
     # on this to find out why.
@@ -120,37 +130,49 @@
     new LC.TextTool()

   options: ->
+    familyOptions = []
+    i = 0
+    for family in @getFamilies()
+      familyOptions.push "<option value=#{i}>#{family.name}</option>"
+      i += 1
+
     @$el = $(
-      "<input type='text' id='text' placeholder='Enter text here'
+      "

+       <input type='text' id='text' placeholder='Enter text here'
         value='#{@tool.text}'>
        <input type='text' id='font-size' value='18'>
+       <select id='family'>#{familyOptions.join('')}</select>
        <input type='checkbox' id='italic'>italic
        <input type='checkbox' id='bold'>bold
-       Click and hold to place text.")
+       Click and hold to place text.
+
")

-    @$input = @$el.filter('input#text')
-    if @$input.size() == 0
-      @$input = @$el.find('input#text')
-
-    @$input.change (e) => @tool.text = @$input.val()
-    @$input.keyup (e) => @tool.text = @$input.val()
-
+    @$input = @$el.find('input#text')
     $fontSize = @$el.find('input#font-size')

-    @$el.find('input#italic').change (e) => @updateToolStyle()
-    @$el.find('input#bold').change (e) => @updateToolStyle()
-    $fontSize.change (e) => @updateToolStyle()
-    $fontSize.keyup (e) => @updateToolStyle()
+    @$input.change => @updateTool()
+    @$input.keyup => @updateTool()
+    $fontSize.change => @updateTool()
+    $fontSize.keyup => @updateTool()
+    @$el.find('input#italic').change => @updateTool()
+    @$el.find('input#bold').change => @updateTool()
+    @$el.find('#family').change =>
+      @updateTool()
+      @$input.focus()
+      @$input.select()

     @$el

-  updateToolStyle: ->
+  updateTool: ->
     items = []
     if @$el.find('input#italic').is(':checked')
       items.push('italic')
     if @$el.find('input#bold').is(':checked')
       items.push('bold')
-    $fontSize = @$el.find('input#font-size')
-    items.push("#{parseInt($fontSize.val(), 10)}px")
-    items.push('sans-serif')
+    items.push("#{parseInt(@$el.find('input#font-size').val(), 10)}px")
+
+    familyIndex = parseInt(@$el.find('select#family').val(), 10)
+    items.push(@getFamilies()[familyIndex].value)
+
     @tool.font = items.join(' ')
+    @tool.text = @$el.find('input#text').val()


Remove unused source maps

Remove unused source maps

--- webpack/cmdize.coffee
+++ webpack/cmdize.coffee
@@ -21,6 +21,7 @@
         x = path.parse dst = z.existsAt
         continue if '.js' != x.ext
         fs.unlink dst, ->
+        fs.unlink "#{dst}.map", ->
         x.base = x.name + '.bat'

         for q in dup [x.name, ':*'], debug


Simplify and log JSON properly

Simplify and log JSON properly

--- src/coffee/import/products.coffee
+++ src/coffee/import/products.coffee
@@ -79,7 +79,7 @@
               if not oldProduct
                 @logger.info "[Products] About to create product with id: '#{attr.value}', counter: '#{@productsCreated}'"
                 # product does not exist yet, create it
-                @_createProduct(p[0], attr.value)
+                @_createProduct(p[0])
               else
                 # product already exists - skip creation
                 @productsCreateSkipped = @productsCreateSkipped + 1
@@ -100,20 +100,16 @@
       processingTimeInSec: (endTime - @startTime) / 1000
     @logger.info summary, "[Products]"

-  _createProduct: (product, id) ->
+  _createProduct: (product) ->
     @client.products.save(product)
     .then =>
       @productsCreated = @productsCreated + 1
     .fail (error) =>
-      if error.statusCode is 400
-        if @_options.continueOnProblems
-          @productsCreateIgnored = @productsCreateIgnored + 1
-          msg = "[Products] Product with id: '#{id}' could not be created. Ignore and continue!; Reason:\n#{_u.prettify error}"
-          @logger.warn msg
-          Q.resolve msg
-        else
-          @_options.continueOnProblems
-          Q.reject error
+      if error.statusCode is 400 and @_options.continueOnProblems
+        @productsCreateIgnored = @productsCreateIgnored + 1
+        msg = "[Products] Product could not be created. Ignore and continue!; Reason:"
+        @logger.warn error, msg
+        Q.resolve msg
       else
         Q.reject error


Corrige fechamento de tag que afetava o IE

--- src/coffee/portal-minicart.coffee
+++ src/coffee/portal-minicart.coffee
@@ -22,32 +22,31 @@
       self.options.$template = $ """

-

-

-

-

-

-                                Produto
-                                Preço
-                                Quantidade
-                                Excluir
-

-

-

-

+

+

+

+

+

+                            Produto
+                            Preço
+                            Quantidade
+                            Excluir
+

+

+

+

+

+

+

+                    Total\
+
+                        R$ 0
+

-

-

-                        Total\
-
-                            R$ 0
-
-

-
-

+

-

+

       """


Update LandingPage.coffee

Update LandingPage.coffee

re-text

--- src/components/LandingPage.coffee
+++ src/components/LandingPage.coffee
@@ -116,7 +116,7 @@

               when V.DONATE
                 div null,
-                  h2 null, "hier kannst du doppelte Wirkung zeigen."
+                  h2 null, "Hier kannst du doppelte Wirkung zeigen."
                   p null,
                     """
                     Unsere Crowdfunding Kampagne auf www.betterplace.org


Another reset=>sync

Another reset=>sync

--- core/app/backbone/views/auto_complete/auto_complete_search_view.coffee
+++ core/app/backbone/views/auto_complete/auto_complete_search_view.coffee
@@ -18,7 +18,7 @@
   initSearchCollection: (collection) ->
     @search_collection = collection
     @listenTo @search_collection, 'request', @setLoading
-    @listenTo @search_collection, 'reset', @unsetLoading
+    @listenTo @search_collection, 'sync', @unsetLoading

   initTextInputView: (placeholder) ->
     @_text_input_view = new Backbone.Factlink.TextInputView


add a reconnect command for local_hub, which is *NOT* used yet; also fix some logging output

--- salvus/hub.coffee
+++ salvus/hub.coffee
@@ -2300,6 +2300,7 @@
                     winston.debug("local_hub --> hub: (connect) error -- #{err}, #{to_json(resp)}, trying to connect to '#{@path}' in #{@project_id}.")
                     if resp?.path? and resp?.path.indexOf("sage_server.port") != -1
                         err = "The Sage Worksheet server is not running.  The system may be very heavily loaded, you may have messed up a custom install of Sage, or caused problems by customizing your packages.  Make this work in the terminal:
 cd ~/.sagemathcloud\necho 'import sage_server, sage_salvus' | sage
 then restart the Sage Worksheet server.
Or contact wstein@uw.edu for help."
+                    #@local_hub.reconnect()
                     cb?(err)
                 else if resp.event == 'error'
                     cb?(resp.error)
@@ -2624,7 +2625,7 @@

 class LocalHub  # use the function "new_local_hub" above; do not construct this directly!
     constructor: (username, host, port, @project, cb) ->  # NOTE @project may be undefined.
-        winston.debug("Creating LocalHub(#{@username}, #{@host}, #{@port}, ...)")
+        winston.debug("Creating LocalHub(#{username}, #{host}, #{port}, ...)")
         if program.local
             @SAGEMATHCLOUD = ".sagemathcloud-local"
             # Do not timeout when doing development, since the enclosing project would already timeout... and
@@ -2633,6 +2634,10 @@
         else
             @SAGEMATHCLOUD = ".sagemathcloud"
         @connect(username, host, port, cb)
+
+    reconnect:  (cb) =>
+        winston.debug("local_hub reconnect #{@username}, #{@host}, #{@port}")
+        @connect(@username, @host, @port, (err) -> cb?(err))

     connect: (username, host, port, cb) =>
         if not username? or not host? or not port?


commenting code

commenting code

--- src/jiangConrathSimilarity.coffee
+++ src/jiangConrathSimilarity.coffee
@@ -2,12 +2,19 @@
 _  = require 'underscore'
 memoize = require './memoize'

+###
+synset counts tagged on the Brown corpus, used as relative frequencies in calculation of synset
+information
+###
 BROWN_JSON = fs.readFileSync(__dirname + '/../data/BROWN.json')
 BROWN = JSON.parse(BROWN_JSON);
 BROWN_COUNTS = _.countBy(BROWN, (freq) => return freq)

 {WORDNETIFY_SYNSETS_TREE} = require './Tree'

+###
+returns the estimated information for synset with id *nodeid*
+###
 getInformation = memoize (nodeId) ->
   freqSum = WORDNETIFY_SYNSETS_TREE[nodeId].tagCount
   N = 130811
@@ -15,18 +22,35 @@
   prob_hat = ((freqSum + 1) / N) * (N_r(freqSum + 1)/N_r(freqSum))
   return - Math.log(prob_hat)

+###
+depth of synset with id *node_id*, defined as the number of nodes up to the root node, i.e.
+the number of ancestors
+###
 depth = (node_id) ->
   return WORDNETIFY_SYNSETS_TREE[node_id].ancestorIds.length

+###
+returns the ids of all synsets which are hypernymsof both node1 and node2
+###
 getCommonHypernyms = (node1, node2) ->
   return _.intersection(node1.ancestorIds, node2.ancestorIds)

+
+###
+find lowest common subsumer for nodes *node1* and *node2*, used in calculation of the
+Jiang & Conrath similarity measure
+###
 lowestCommonHypernym = (node1, node2) ->
   synsets = getCommonHypernyms(node1, node2);
   depths = synsets.map( (s) => depth(s) )
   max_depth = depths.max()
   return synsets.filter((s) => depth(s) == max_depth)

+###
+calculates Jiang & Conrath Similarity measure of two synsets. Considers the information content of
+lowest common subsumer (lcs) and the two compared concepts to calculate the distance between the two concepts.
+Source: http://arxiv.org/pdf/cmp-lg/9709008.pdf
+###
 jiangConrathSimilarity = memoize (node1, node2) ->
   ic1 = getInformation(node1.synsetid)
   ic2 = getInformation(node2.synsetid)


Set default compileTimeout to 3 minutes for onsite users

--- services/web/config/settings.defaults.coffee
+++ services/web/config/settings.defaults.coffee
@@ -155,7 +155,7 @@
 		collaborators: -1
 		dropbox: true
 		versioning: true
-		compileTimeout: 60
+		compileTimeout: 180
 		compileGroup: "standard"
 		references: true
 		templates: true


oops, that's not a string

oops, that's not a string

--- scripts/pokebattle.coffee
+++ scripts/pokebattle.coffee
@@ -168,7 +168,7 @@
     msg.send "A wild #{poke} appears!"
     msg.send "http://serebii.net/Pkmn_Green/#{pad(pokemon.indexOf(poke) + 1, 3)}.gif"

-  robot.hear new RegExp(("(\b" + pokemon + "\b").join("|")+")", 'i'), (msg) ->
+  robot.hear new RegExp("("+pokemon.map(function(str) { return "\b#{str}\b" }).join("|")+")", 'i'), (msg) ->
     poke = msg.match[1]
     poke = poke[0].toUpperCase() + poke[1..-1].toLowerCase()
     msg.send "#{poke}, I choose you!"


added fetch to specific /package/xyz with all information included

Signed-off-by: Dominik Richter <b7323add517e187efe0283b76511b7ed762bfe13@gmail.com>

--- test/spec/controllers/main.coffee
+++ test/spec/controllers/main.coffee
@@ -65,7 +65,7 @@
     expect(@typeOf(n.packages)).toBe('array')
     expect(n.packages.length).toBe( 0 )

-  it 'should be able to access /node/xzy info (filled onde)', () ->
+  it 'should be able to access /node/xzy info (filled one)', () ->
     id = 'test'
     @httpBackend.whenGET('/v1/node/'+id).respond({
       'packages':[
@@ -111,3 +111,31 @@
     p = scope.package[id]
     expect(@typeOf(p)).toBe('object')
     expect(p.id).toBe(id)
+
+
+  it 'should be able to access /package/xyz info (filled one)', () ->
+    id = 'xyz'
+    r = {
+        "name": "accountsservice",
+        "uri": "http://us.archive.ubuntu.com/ubuntu/pool/main/a/accountsservice/accountsservice_0.6.15-2ubuntu9_amd64.deb",
+        "summary": "query and manipulate user account information",
+        "version": "0.6.15-2ubuntu9",
+        "architecture": "amd64",
+        "provider": "apt",
+        "archive": "precise"
+      }
+    @httpBackend.whenGET('/v1/package/'+id).respond(r)
+    @httpBackend.expectGET('/v1/package/'+id)
+    scope.fetch_package(id)
+    @httpBackend.flush()
+
+    p = scope.package[id]
+    expect(@typeOf(p)).toBe('object')
+    expect(p.id).toBe(id)
+    expect(p.name).toBe(r.name)
+    expect(p.uri).toBe(r.uri)
+    expect(p.summary).toBe(r.summary)
+    expect(p.version).toBe(r.version)
+    expect(p.architecture).toBe(r.architecture)
+    expect(p.provider).toBe(r.provider)
+    expect(p.archive).toBe(r.archive)


better pseudocode for rel filtering. Seems we have to go to server

--- views/coffeescript/filters.coffee
+++ views/coffeescript/filters.coffee
@@ -48,25 +48,22 @@
   activatedNodeId = appContext.getActivatedNodeId()
   activatedNode = node for node in nodeData.nodes when node.id == activatedNodeId

-  hideSubGraph(activatedNode, relsToHide, appContext)
+  relsHiddenByUser = getRelsHiddenByUser() #i.e. all relations corresponding to un-checked active filters
+  activeRels = allRels.diff(relsHiddenByUser)
+  for rel in activatedNode.rels
+    if relsHiddenByUser.contains(rel)
+      hideRel(rel)
+      otherNode = rel.other(node)
+      if (!areConnected(otherNode, node, activeRels))
+        # No connections to otherNode exists, so hide otherNode and its subgraph
+        hideSubGraph(node, activeRels)

-hideSubGraph = (node, relsToHide, appContext) ->
-  # TODO, pseudocode:
-  nodeData = appContext.getNodeData()
-  for rel in getRels(node, nodeData)
-    if relsToHide == "hide all" || shouldHide(rel, relsToHide)
-      hideRel(rel)
-      for relatedNode in getRelatedNode(node, rel, nodeData)
-        if (!areConnected(relatedNode, node, nodeData, rel /*ignore this one*/))
-          hideNode(relatedNode)
-          hideSubGraph(relatedNode, "hide all", appContext)
+areConnected = (nodeA, nodeB, rels) ->
+  # ask server about this..?

-connectionCount = (nodeA, nodeB, nodeData) ->
-  # Yikes...
-
-getRels = (node, nodeData) ->
-  (rel for rel in nodeData.rels when rel.data.end_node == node.id || rel.data.start_node == node.id)
+hideSubGraph = (startNode, rels) ->
+  # TODO

 buildCheckboxHtml = (relType, value, enabled) ->


+ ExpressionStack: tested .popWhenReady

+ ExpressionStack: tested .popWhenReady

--- test/unit/expression-stack.coffee
+++ test/unit/expression-stack.coffee
@@ -75,3 +75,17 @@
     it ".stackName is 'next'", ->
       testedStack.stackName.should.equal "next"

+    describe "after .popWhenReady()", ->
+      beforeEach ->
+        testedStack.popWhenReady()
+
+      it ".stackName is still 'next'", ->
+        testedStack.stackName.should.equal "next"
+
+      describe "after .addOperand(() => true)", ->
+        beforeEach ->
+          testedStack.addOperand () -> true
+
+        it ".stackName is 'bottom'", ->
+          testedStack.stackName.should.equal "bottom"
+


removed over

removed over

--- scripts/mo.coffee
+++ scripts/mo.coffee
@@ -1,5 +1,5 @@
 module.exports = (robot) ->
-  robot.hear /max|over|drive/i, (msg) ->
+  robot.hear /max|drive/i, (msg) ->
     imageMe msg

 imageMe = (msg) ->


Nah, I can use `SORT`

Nah, I can use `SORT`

--- scripts/rc.coffee
+++ scripts/rc.coffee
@@ -53,7 +53,6 @@
     @storage.multi([
       ["ZADD", @key("latest"), now, @who],
       ["ZADD", @key("#{@who}:scores"), score, now],
-      ["ZADD", @key("#{@who}:times"), score, now],
     ]).exec (err, replies) =>
       return cb(err, null, this) if err
       # Update the internal state if we succeed


bug fix

bug fix

--- app/assets/javascripts/ample_assets/classes/ample_assets.js.coffee
+++ app/assets/javascripts/ample_assets/classes/ample_assets.js.coffee
@@ -309,8 +309,9 @@
   events: ->
     @modal_events()
     @field_events()
-    $("a.asset-remove").live 'click', =>
-      @remove(this)
+    ref = this
+    $("a.asset-remove").live 'click', ->
+      ref.remove(this)
       false
     $("##{@options.id}-handle").live 'click', =>
       @toggle()


Fixed wrong use of splice().

Fixed wrong use of splice().

--- app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee
+++ app/assets/javascripts/app/controllers/agent_ticket_zoom.js.coffee
@@ -81,14 +81,14 @@
         article_lines = article['html'].split(/\n/)
         if article_lines.length > preview
           preview_mode = true
-          article_lines.splice( preview+1, 1, "----SEEMORE----" )
+          article_lines.splice( preview, 0, "----SEEMORE----" )
           article['html'] = article_lines.join("\n")
         article['html'] = window.linkify( article['html'] )
-        notify = "" + T('See more') + ""
+        notify = "" + T('See more') + ""

         # preview mode
         if preview_mode
-          article['html'] = article['html'].replace /^----SEEMORE----/m, (match) =>
+          article['html'] = article['html'].replace /^----SEEMORE----\n/m, (match) =>
             notify + '
'
           article['html'] = article['html'] + '
'


accommodate custom mark color override

accommodate custom mark color override

--- app/assets/javascripts/components/mark/tools/point-tool/index.cjsx
+++ app/assets/javascripts/components/mark/tools/point-tool/index.cjsx
@@ -77,13 +77,6 @@
         onMouseDown={@handleMouseDown}
       >

-        <g className="tool-shape #{classes.join ' '}">
-          <line x1="0" y1={-1 * crosshairSpace * selectedRadius} x2="0" y2={-1 * selectedRadius} strokeWidth={crosshairWidth} />
-          <line x1={-1 * crosshairSpace * selectedRadius} y1="0" x2={-1 * selectedRadius} y2="0" strokeWidth={crosshairWidth} />
-          <line x1="0" y1={crosshairSpace * selectedRadius} x2="0" y2={selectedRadius} strokeWidth={crosshairWidth} />
-          <line x1={crosshairSpace * selectedRadius} y1="0" x2={selectedRadius} y2="0" strokeWidth={crosshairWidth} />
-        </g>
-
         <Draggable onDrag={@handleDrag}>
           <g
             className="tool-shape #{classes.join ' '}"
@@ -97,6 +90,13 @@
                     <feMergeNode in=\"SourceGraphic\" />
                   </feMerge>
                 </filter>
+
+                <g #{if @props.mark.color? then "stroke=\"#{@props.mark.color}\""} >
+                  <line x1=\"0\" y1=\"#{-1 * crosshairSpace * selectedRadius}\" x2=\"0\" y2=\"#{-1 * selectedRadius}\" strokeWidth=\"#{crosshairWidth}\" />
+                  <line x1=\"#{-1 * crosshairSpace * selectedRadius}\" y1=\"0\" x2=\"#{-1 * selectedRadius}\" y2=\"0\" strokeWidth=\"#{crosshairWidth}\" />
+                  <line x1=\"0\" y1=\"#{crosshairSpace * selectedRadius}\" x2=\"0\" y2=\"#{selectedRadius}\" strokeWidth=\"#{crosshairWidth}\" />
+                  <line x1=\"#{crosshairSpace * selectedRadius}\" y1=\"0\" x2=\"#{selectedRadius}\" y2=\"0\" strokeWidth=\"#{crosshairWidth}\" />
+                </g>

                 <circle
                   #{if @props.mark.color? then "stroke=\"#{@props.mark.color}\""}


Main.vagrant.conf: fetch acvtivities 20 by 20

--- config/main.vagrant.coffee
+++ config/main.vagrant.coffee
@@ -135,7 +135,7 @@
     useStaticFileServer: no
     staticFilesBaseUrl: 'http://localhost:3020'
     runtimeOptions:
-      activityFetchCount : 50
+      activityFetchCount : 20
       precompiledApi: no
       authExchange: authExchange
       github         :