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
scala> import net.ruippeixotog.scalascraper.browser.Browser | |
import net.ruippeixotog.scalascraper.browser.Browser | |
scala> import net.ruippeixotog.scalascraper.dsl.DSL._ | |
import net.ruippeixotog.scalascraper.dsl.DSL._ | |
scala> import net.ruippeixotog.scalascraper.dsl.DSL.Extract._ | |
import net.ruippeixotog.scalascraper.dsl.DSL.Extract._ | |
scala> val browser = new Browser |
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 shapeless._ | |
import shapeless.ops.nat.LTEq.<= | |
import Nat._ | |
sealed trait ToValue[T, V] { def value: V } | |
def toValue[T, V](implicit tv: ToValue[T, V]): V = tv.value | |
object Bool { | |
sealed trait Bool |
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 annotation.tailrec | |
import util.Random | |
object main extends App { | |
val target = "as armas e os baroes assinalados" | |
val genePool = Array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ') | |
def fitness(src: String): Double = src.zip(target).foldRight(0.0f) { (e, acc) => e match { | |
case (s, t) if s == t => acc + 1 | |
case _ => acc |
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
{ | |
"name": "botarena-bot-js", | |
"version": "1.0.0", | |
"description": "", | |
"main": "app.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "Rui Gonçalves", | |
"dependencies": { |
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 shapeless._ | |
trait TypeValue[A, R] { | |
def apply(): R | |
} | |
trait Size[A] extends TypeValue[A, Int] | |
implicit val shortSize = new Size[Short] { | |
def apply() = 2 |
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
var lastDist = null; | |
function initY(distance) { | |
actionFunc = setYDir; | |
return 'up'; | |
} | |
function setYDir(distance) { | |
var yDir = lastDist <= distance ? 'down' : 'up'; | |
actionFunc = moveY(yDir); |
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 annotation.tailrec | |
import util.Random | |
import scala.annotation.tailrec | |
import scala.collection.immutable.Stream.consWrapper | |
object Main2 extends App { | |
val target = "as armas e os baroes assinalados" | |
val genePool = Array[Char]('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' ') | |
def fitness(src: String, tgt: String): Double = src.zip(tgt).count { case (s, t) => s == t } |
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 scala.collection.immutable._ | |
import scala.util.Random | |
def benchmark[A](desc: String)(block: => A): Option[A] = { | |
val t = System.currentTimeMillis() | |
try { | |
val res = block | |
println(s"$desc: took ${System.currentTimeMillis() - t} ms") | |
Some(res) | |
} catch { |
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
def benchmark[A](desc: String)(block: => A): Option[A] = { | |
val t = System.currentTimeMillis() | |
try { | |
val res = block | |
println(s"$desc: took ${System.currentTimeMillis() - t} ms") | |
Some(res) | |
} catch { | |
case e: Throwable => | |
e.printStackTrace() | |
println(s"$desc: ${e.getClass.getSimpleName} thrown after ${System.currentTimeMillis() - t} ms") |
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 net.ruippeixotog.jmh | |
import java.util.concurrent.TimeUnit | |
import scala.collection.immutable.ListMap | |
import org.openjdk.jmh.annotations.{Benchmark, BenchmarkMode, Mode, OutputTimeUnit} | |
import org.openjdk.jmh.infra.Blackhole | |
class ListMapBenchmark { |
OlderNewer