This file contains 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
# Election results | |
It's election night! Exciting! We have a feed of election results from a data supplier. They will supply us a file which will be updated throughout the night as results come in. | |
## Results format | |
The fields in the file will be separated by commas but each row will vary in length as described below. | |
A result will consist of: |
This file contains 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
val myFuture = someFuture // from a previous async op | |
val result = myFuture map { f => | |
slowOp(f) // either takes ages or doesn't complete at all | |
} | |
// then some timeout on result | |
timeout(result, fallback) | |
// question is: if fallback is used, what happens to the execution of the slowOp (does it continue and hog resources?!) |
This file contains 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
class UniversalSet[A] extends Set[A] { | |
def contains(key: A) = true | |
def iterator = throw new UnsupportedOperationException() | |
def +(elem: A) = this | |
def -(elem: A) = throw new UnsupportedOperationException() | |
override def toString: String = "UniversalSet" | |
} |
This file contains 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
/** | |
* Convert a dataTable string representation into a List of Maps. For example: | |
* | |
* | x | y | | |
* | 1 | a is | | |
* | 2 | b does | | |
* | |
* Becomes: | |
* | |
* List(Map(x -> 1, y -> "a is"), Map(x -> 2, y -> "b does")) |
NewerOlder