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 tools.nsc.plugins.{Plugin, PluginComponent} | |
import tools.nsc.Global | |
import tools.nsc.transform.{TypingTransformers, InfoTransform, Transform} | |
import tools.nsc.symtab.Flags | |
class MyPlugin(val global: Global) extends Plugin { | |
val name = "annotations-inject-implicit" | |
val description = "generates code which adds an implicit parameter of type BindingModule when an AutoInjectable trait is mixed in" | |
val components = List[PluginComponent](AnnotationsInjectComponent) |
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 main.scala | |
trait Enum[T]{ self => | |
type E = this.type => T | |
implicit class k(e: E) extends Function0[T]{ | |
def apply() = e(self) | |
} | |
} |
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 outer(x): | |
def inner(): | |
print x | |
inner() | |
print x | |
outer(10) # 10 10 | |
def outer(x): |
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 x | |
println("reset{} " + | |
reset{ | |
shift{ cont: (Int => Int) => | |
println("cont(1): " + cont(1)) | |
println("cont(2): " + cont(2)) | |
5 | |
} |
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
case class Thing(s: String){ | |
def :=(t: Thing) = s + ": " + t.s | |
} | |
val float = Thing("float") | |
val left = Thing("left") | |
val backgroundImage = Thing("background-image") | |
def radialGradient(s: String) = Thing(s"radialGradient($s)") | |
val red = Thing("red") | |
val blue = Thing("red") |
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 metascala | |
import collection.mutable | |
import annotation.tailrec | |
import metascala.imm.Type | |
import metascala.rt.{Obj, FrameDump, Thread} | |
import metascala.natives.Bindings | |
import metascala.imm.Type.Prim | |
import org.objectweb.asm.ClassReader | |
import org.objectweb.asm.tree.ClassNode |
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 |
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) |
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 ScalaJSExample extends js.JSApp{ | |
def main() = { | |
val xs = Seq(1, 2, 3) | |
println(xs.toString) | |
val ys = Seq(4, 5, 6) | |
println(ys.toString) | |
val zs = for{ | |
x <- xs | |
y <- ys | |
} yield x * y |
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) | |
} |
OlderNewer