View XMLCR.scala
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 that= <that>x</that> | |
val thatcr= Seq(that,Text("\n")) | |
val xml= <root> | |
{ for (x<-1 to 4) yield that } | |
{ for (x<-1 to 4) yield |
View Debbie_Harry.xquery
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
xquery version "1.0-ml"; | |
let $out:=sem:sparql(' | |
SELECT * | |
WHERE { <http://dbpedia.org/resource/Debbie_Harry> ?p ?o } | |
') | |
for $i in $out | |
let $p:=map:get($i,"p") | |
let $o:=map:get($i,"o") |
View Rational.scala
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
object Rational extends App { | |
case class Rational(n: Int, d: Int=1) extends Ordered[Rational]{ | |
require(d != 0) | |
private def gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b) | |
private val g = gcd(n.abs, d.abs) | |
val numer = n / g | |
val denom = d / g | |
def + (that: Rational) = Rational( numer * that.denom + that.numer * denom, denom * that.denom) |
View ThrottledProcessor.scala
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 akka.actor.ActorSystem | |
import scala.concurrent.duration._ | |
import akka.actor.ActorDSL._ | |
object ThrottledProcessor extends App { | |
implicit val system = ActorSystem("ThrottledProcessor") | |
import system.dispatcher | |
case object Dump | |
case object Process |
View TimestampMacro.scala
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
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._ |
View ExceptionDig.scala
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
// 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 | |
} |
View CaseMapApp.scala
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
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") |
View e4s1.scala
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
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 { |
View ThrottledProcessor2.scala
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 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") |
View C1.scala
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
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"; |
OlderNewer