View BasicOperations.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
@JSExport | |
object ScalaJSExample{ | |
@JSExport | |
def main(args: Array[String]): Unit = { | |
val xs = Seq(1, 2, 3) | |
println(xs) | |
val ys = Seq(4, 5, 6) | |
println(ys) | |
val zs = for{ | |
x <- xs |
View gist:dc63796497638d56fc2e
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
--- a/spray-util/src/main/scala/spray/util/pimps/PimpedRegex.scala | |
+++ b/spray-util/src/main/scala/spray/util/pimps/PimpedRegex.scala | |
@@ -20,12 +20,9 @@ import java.util.regex.Pattern | |
import scala.util.matching.Regex | |
class PimpedRegex(regex: Regex) { | |
def groupCount = { | |
try { | |
- val field = classOf[Pattern].getDeclaredField("capturingGroupCount") | |
- field.setAccessible(true) |
View gist:18bc16c0d22c89ce49d6
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 thing = { | |
val sp = span.value | |
lazy val box: HTMLTextAreaElement = textarea( | |
onChange := () => span.innerHTML = box.value | |
).value | |
div(box, sp) | |
} |
View gist:5807849eb3e697a97198
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 utest._ | |
object Tests extends TestSuite | |
val tests = TestSuite do | |
'simple do | |
'class-assert((new scalite.simple.Class)() == "Hello World!12") | |
'assignments-assert((new scalite.simple.Assignments)() == 9) | |
'modassignments-assert((new scalite.simple.ModAssignments)() == 9) | |
'ifelsewhile-assert((new scalite.simple.IfElseWhile)() == 40) | |
'ifelsewhilelite-assert((new scalite.simple.IfElseWhileLite)() == 36) |
View MyService.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.example | |
import akka.actor.Actor | |
import spray.routing._ | |
import spray.http._ | |
import MediaTypes._ | |
// we don't implement our route structure directly in the service actor because | |
// we want to be able to test it independently, without having to spin up an actor |
View gist:89d4803da8d3f33c823a
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.example | |
import akka.actor.Actor | |
import spray.routing._ | |
import spray.http._ | |
import MediaTypes._ | |
// we don't implement our route structure directly in the service actor because | |
// we want to be able to test it independently, without having to spin up an actor |
View gist:899f0513c3267f6dbadb
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 words(s: String): Set[String] | |
def makeWordMap(sentences: List[String]) = { | |
val forwardMap = sentences.map(s => (s, words(s))).toMap | |
sentences.flatMap(words) | |
.distinct | |
.map(w => sentences.filter(forwardMap(s))) | |
} | |
def makeWordMap2(sentences: List[String]) = { |
View gist:0b513348e1b549561e78
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 ammonite.sh2 | |
import acyclic.file | |
import scala.collection.{immutable => imm} | |
object PConfig{ | |
implicit val pc = new PConfig() | |
} | |
case class PConfig(maxDepth: Int = 100, depth: Int = 0) | |
object PPrint extends LowPriPPrint{ |
View gist:c069926724b1739a1b69
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
[info] Running ammonite.repl.Repl | |
@ Range(0, 5).ma | |
max map maxBy | |
@ while(true) () | |
Interrupted! | |
@ val x = 1 | |
x: Int = 1 | |
@ val y = 2 | |
y: Int = 2 |
View Input.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
// Input Scala sources | |
def lightIsVisible(l: Vec, p: Vec) = { | |
val ray = Ray(p, l - p) | |
val length = (l - p).magnitude | |
var visible = true | |
for (i <- 0 until objects.length){ | |
val (o, s) = objects(i) | |
val t = o.intersectionTime(ray) | |
if (t > Epsilon && t < length - Epsilon){ | |
visible = false |
OlderNewer