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
val query = ScalasticSearch.boolQuery( | |
cond ( | |
must( | |
'nickname -> "Superman", // is equivalent to... | |
term('nickname -> "Superman"), // this | |
term("nickname" -> "Superman") // or this | |
), | |
should( | |
'nickname -> "Superman", // is equivalent to... | |
term('nickname -> "Superman"), // this |
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
val pattern = java.util.regex.Pattern.compile ("""(?xs) ("(.*?)"|) ; ("(.*?)"|) (?: \r?\n | \z ) """) | |
val matcher = pattern.matcher (input) | |
while (matcher.find) { | |
val col1 = matcher.group (2) | |
val col2 = matcher.group (4) | |
// ... | |
} |
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.espertech.esper.client.{Configuration, EventBean, UpdateListener, EPServiceProviderManager} | |
import java.util.HashMap | |
import scala.collection.JavaConversions._ | |
object Sandbox | |
{ | |
def main(args: Array[String]) { | |
val config = new Configuration(); | |
val eventType = new HashMap[String, AnyRef]() | |
eventType.put("itemName", classOf[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
package demo1 | |
import com.espertech.esper.client.EventBean | |
import com.espertech.esper.client.EPAdministrator | |
import com.espertech.esper.client.UpdateListener | |
import com.espertech.esper.client.EPListenable | |
import com.espertech.esper.client.EPServiceProvider | |
object EsperUtil { |
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
package net.addictivesoftware.scala.akkaactors | |
import akka.actor.{Actor, PoisonPill} | |
import Actor._ | |
import akka.routing.{Routing, CyclicIterator} | |
import Routing._ | |
import collection.mutable.{HashMap, Map} | |
import java.util.concurrent.CountDownLatch |
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 scala.io.Source | |
def parseLines[T](file: String, transform: (Iterator[String]) => T): T = { | |
val log = Source.fromFile(file) | |
val logLines = log.getLines() | |
try { transform(logLines) } finally { log.close } | |
} | |
// Example usage. | |
// parseLines("verybigfile.txt", iterator.take(100).foreach(println)) |
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 scala.io.Source | |
def parseLines[T](file: String, transform: (Iterator[String]) => T): T = { | |
val log = Source.fromFile(file) | |
val logLines = log.getLines() | |
try { transform(logLines) } finally { log.close } | |
} | |
// Example usage. | |
// parseLines("verybigfile.txt", iterator.take(100).foreach(println)) |
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
package akka.unfiltered | |
import akka.actor._ | |
import akka.dispatch.Future | |
import akka.pattern.ask | |
import akka.util.duration._ | |
import akka.util.Timeout | |
import unfiltered.Async | |
import unfiltered.request._ |
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
scalaVersion := "2.9.1" | |
resolvers += "durgeshm repo" at "http://durgeshm.github.com/releases/" | |
libraryDependencies ++= Seq( | |
"com.twitter" %% "finagle-core" % "1.9.7", | |
"com.twitter" %% "finagle-http" % "1.9.7") |
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 akka.dispatch.Future | |
import akka.pattern.pipe | |
import akka.actor.Actor | |
case class Work(s: String) | |
case class Result(s: String) | |
object MyActor { | |
// put here to avoid closing over actor’s state | |
def doWork(work: String): String = { |