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 examples | |
import scala.annotation.tailrec | |
object fact { | |
// see: http://stackoverflow.com/questions/1025181/hidden-features-of-scala/4027156#4027156 | |
def timed[T](thunk: => T) = { | |
val t1 = System.nanoTime | |
val ret = thunk |
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
/* | |
dpp: The way I do it in Lift is as follows: | |
http://scala-programming-language.1934581.n4.nabble.com/scala-Work-around-for-super-references-to-vals-td2000298.html | |
*/ | |
class Foo { lazy val x = _x ; protected def _x = 1 } | |
class Bar extends Foo { protected override def _x = super._x + 1 } | |
(new Bar).x // 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
<div data-lift="TestSnippet.methodName?eager_eval=true"> | |
<div data-lift="embed?what=/templates-hidden/my-template"></div> | |
</div> |
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
class Super { | |
val public_ = "public" | |
protected val protected_ = "protected" | |
private val private_ = "private" | |
protected[Super] val protected_super = "ps" | |
protected[this] val protected_this = "pt" |
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 the magic libraries | |
import scala.xml._ | |
import scala.xml.transform._ | |
// Source xml. In Scala, xml is literal. | |
val xml = | |
<user> | |
<email>joe@example.com</email> |
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 $tree = $('#tree1'); | |
$('#collapse').click(function() { | |
var tree = $tree.tree('getTree'); | |
tree.iterate(function(node) { | |
if (node.hasChildren()) { | |
$tree.tree('closeNode', node, true); | |
} | |
return 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
"Apache Directory Studio.exe" -vm "C:\Program Files (x86)\Java\jre7\bin\java.exe" |
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
// Please comment in case of typos or bugs | |
import scala.slick.driver.H2Driver._ | |
val db = Database.for...(...) | |
case class Record( ... ) | |
class Records(tag: Tag) extends Table[Record](tag,"RECORDS"){ | |
... | |
def * = ... <> (Record.tupled,Record.unapply) | |
// place additional methods here which return values of type Column |
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 | |
import scala.annotation.tailrec | |
class Tailrec { | |
def tail1(i: Int): Int = { | |
if (i >= 10) i | |
else tail1(i+1) | |
} |
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 Emp(id: Long, | |
firstName: Option[String], | |
lastName: Option[String]) | |
case class EmpProj(id: Column[Long], | |
firstName: Column[Option[String]], | |
lastName: Column[Option[String]]) | |
implicit object EmpShape extends CaseClassShape(EmpProj.tupled, Emp.tupled) |