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
/* I'm trying to refactor $and and $or (which are essentially the same code returning a different outer query). | |
The problem is that currently only "String, Any" pairs work, and I need to be able to combine both those *AND* "Query Expression Objects". | |
Here's the $or spec right now | |
*/ | |
"Casbah's DSL $or Operator" should { | |
"Accept multiple values" in { | |
val or = $or("foo" -> "bar", "x" -> "y") |
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
import Data.List | |
import Data.Maybe | |
import Control.Monad | |
alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789" | |
base = length alphabet | |
encode :: Int -> String | |
encode 0 = "a" | |
encode id = map $ ((!!) alphabet) (reverse . tail) (map snd options) |
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 TestSpec extends org.specs2.mutable.Specification { | |
sequential // this causes the printing to break | |
"many tests" should { | |
(1 to 1000).foreach { i => | |
"example "+i >> { | |
("example "+i).pp | |
Thread.sleep((math.random*100).toLong) | |
ok | |
} |
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
import java.util.concurrent.atomic.*; | |
import java.util.concurrent.*; | |
public class Main { | |
private static ExecutorService executor = Executors.newFixedThreadPool(2); | |
private static int iterations = 10000000; | |
public static class Runner { | |
// writes to canceled happen before a CAS on suspended | |
// reads on canceled happen after a CAS on suspended |