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
class Global { | |
lazy val analyzer = new { | |
val global: Global.this.type = Global.this | |
} with Analyzer | |
class Tree(v:String) | |
case class Symbol(v:String) | |
def test1 = { | |
val t1 = new Tree("test") | |
analyzer.test1(t1) | |
} |
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.reflect.macros.Context | |
object Macros { | |
def LINE:Int = macro line_impl | |
def line_impl(c: Context): c.Expr[Int] = { | |
import c.universe._ | |
c.Expr[Int](Literal(Constant(c.macroApplication.pos.line))) | |
} |
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
#!/bin/sh | |
exec scala "$0" "$@" | |
!# | |
object HelloWorld { | |
abstract class OCard { | |
val v:Int | |
val c:Int | |
def matchV(x:OCard):Boolean |
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
def getCheapest(iataFrom:String):Future[Iterable[model.FlightInfo]] = | |
model.Airports.get(iataFrom) match { | |
case Some(from) => | |
val f = avsfetcher.AvsCacheParser.fetchAviasalesCheapest(iataFrom) | |
val ret0 = f.map { | |
ret => ret.groupBy(_.iataTo).flatMap { | |
case (iataTo,rs) => | |
model.Airports.get(iataTo) match { | |
case Some(to) => | |
if ( rs.isEmpty ) |
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
object BaseFetcherActorSpec { | |
class BaseFetcherActorTester extends actors.BaseFetcherActor { | |
// import context.dispatcher | |
def receive = { | |
case 1 => sender ! 1 | |
execWithTimeout(Seq("perl","-e","""print 1\n;""")).map { | |
r => r | |
} | |
// ret => sender ! ret | |
//) |
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
abstract class BaseFetcherActor extends Actor { | |
import sys.process._ | |
val system = akka.actor.ActorSystem("system") | |
import context.dispatcher | |
import scala.concurrent.duration._ | |
var pid = 0 | |
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
def open(url:String):Future[Try[Page]] = { | |
val fetcher = Akka.system.actorOf(Props[PhantomExecutor],"phantom") | |
(fetcher ? Start()).flatMap { | |
case Started() => | |
println("YYYYYYYYYYYYYYy") | |
(fetcher ? OpenUrl(url))/*.mapTo[OpenUrlResult]*/.map { | |
/*case OpenUrlResult(Success(ret)) => | |
println("XXXXXXXXXXXXXXXX") | |
Success(new Page(fetcher)) | |
case OpenUrlResult(Failure(ex)) => Failure(ex) |
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
def factorial(n:Int):Int = if (n==0) 1 else n * factorial(n-1) | |
def permut(size:Int,_n:Int) = { | |
var v = (0 until size).toArray | |
var r = new Array[Int](v.length) | |
var pow = factorial(size) | |
var n = _n | |
for ( i <- 0 until size ) { | |
var j=0 | |
pow = pow/(size-i) |
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
var system = require('system'); | |
var page = require('webpage').create(); | |
var CONFIG = { | |
debug: true, | |
}; | |
page.onConsoleMessage = function(msg) { | |
if (msg == "$$INJECT") { | |
debug("injectClients"); | |
page.evaluate(function(_inj_query){ |
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
function processDestinations() { | |
var destinations = page.evaluate(function() { | |
var a = document.querySelectorAll("select.selectdestination"); | |
var avl,dep; | |
var avls = []; | |
var deps = []; | |
var name2iata={}; | |
for ( var i = 0; i < a.length ; i++) { | |
var id = a[i].id; | |
if (!dep && id.indexOf("Departure") != -1 ) { |
OlderNewer