This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // cosine distance and pearson correlation | |
| // see http://ow.ly/vtm44 | |
| package com.allenday | |
| import com.twitter.scalding._ | |
| import com.twitter.scalding.mathematics._ | |
| import com.twitter.scalding.mathematics.Matrix._ | |
| class SimJob(args : Args) extends Job(args) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import com.twitter.util.{Duration, Time} | |
| /** | |
| * Sort of a lazy val, but that refreshes itselfs every so often; or a temporary cache for a value T, | |
| * will be refreshed at a minimun at the specified interval. | |
| * In practice, the refresh is done only when the value is accessed, so there are no guarantees | |
| * to when it will actually be refreshed. You can just be sure that it won't be refreshed if two calls | |
| * are made within `every`. | |
| */ | |
| class RefreshEvery[T](every: Duration)(refresh: => T) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| scala> trait Assoc[K] { type V ; val value: V } | |
| defined trait Assoc | |
| scala> def mkAssoc[V0](k: String, v: V0): Assoc[k.type] { type V = V0 } = | |
| | new Assoc[k.type] { type V = V0 ; val value = v } | |
| mkAssoc: [V0](k: String, v: V0)Assoc[k.type]{type V = V0} | |
| scala> implicit def nameAssoc = mkAssoc("Name", "Mary") | |
| nameAssoc: Assoc[String("Name")]{type V = String} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {{ states.binary_sensor | |
| | selectattr('attributes.device_class', 'in', ['door','window']) | |
| | selectattr('state', 'equalto', 'on') | |
| | list | count }} |
OlderNewer