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 root = <numbers> | |
<number>1</number> | |
<number>2</number> | |
<number>3</number> | |
</numbers> | |
val root2= <numbers> | |
{for (x<- 1 to 3) yield <number>{x}</number>} | |
</numbers> |
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
//http://docs.scala-lang.org/overviews/core/string-interpolation.html | |
implicit class MyQuote(ctx:StringContext){ | |
def x(args:String*):String=ctx.parts.zip(args).map{case (p,a)=>s"$p$a"}.mkString("") | |
} | |
val string="STRINGY" | |
val string2="STRINGY2" | |
println(x"Part1 $string Part2 $string2 Part3 $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 com.felstar.macros.timestamp | |
import scala.reflect.macros.blackbox.Context | |
import scala.language.experimental.macros | |
object TimestampMacro { | |
def timestampString: String = macro timestampMacro | |
def timestampMacro(c: Context): c.Tree = { | |
import c.universe._ |
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
// Coproduct is extension of Either concept, to N multually exlusive choices | |
type ISB = Int :+: String :+: Boolean :+: CNil | |
val isb = Coproduct[ISB]("foo") //> isb : qaaz.ISB = foo | |
isb.select[Int] //> res0: Option[Int] = None | |
isb.select[String] //> res1: Option[String] = Some(foo) |
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
// Using vars, lots of local mutation | |
def getThemVar(th:Throwable)={ | |
var now=th | |
var li=List[Throwable](now) | |
var cause=now.getCause | |
while (cause!=null){ | |
li=cause::li | |
now=cause | |
cause=now.getCause | |
} |
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 playpen | |
object CaseMapApp extends App { | |
import caseMapper.CaseMapper._ | |
case class Address(firstLine:String, postcode:String, country:String) | |
case class Person(name: String, age: Int, address:Address) | |
val here=Address("26 Duncoding","KT17 4LX","UK") |
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 es | |
import com.sksamuel.elastic4s.ElasticClient | |
import com.sksamuel.elastic4s.ElasticDsl._ | |
import scala.concurrent._ | |
import ExecutionContext.Implicits.global | |
import scala.concurrent.duration._ | |
object e4s1 extends App { |
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.actor.ActorSystem | |
import scala.concurrent.duration._ | |
import akka.actor.ActorDSL._ | |
// Better than ThrottledProcessor as it fires immediately if idle, and doesn't send Process messages repeatedly | |
object ThrottledProcessor2 extends App { | |
implicit val system = ActorSystem("ThrottledProcessor") |
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 chroniclemap | |
import net.openhft.chronicle.map._ | |
import java.io.File | |
object C1 extends App { | |
val tmp = System.getProperty("java.io.tmpdir"); | |
val pathname = tmp + "/mychronicle.dat"; |
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 slick.lifted | |
import scala.slick.driver.MySQLDriver.simple._ | |
import slick._ | |
object CaseClassMapping extends App { | |
// the base query for the Users table | |
val users = TableQuery[Users] |