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
package object mail { | |
implicit def stringToSeq(single: String): Seq[String] = Seq(single) | |
implicit def liftToOption[T](t: T): Option[T] = Some(t) | |
sealed abstract class MailType | |
case object Plain extends MailType | |
case object Rich extends MailType | |
case object MultiPart extends MailType |
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
extern crate iron; | |
extern crate mysql; | |
use iron::prelude::*; | |
use iron::status; | |
use iron::{Handler}; | |
struct Router { | |
routes: HashMap<String, Box<Handler>> | |
} |
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
for (int i = 0; i < 10_000; i++) { | |
Thread t = new Thread(() -> System.out.println("doing something")); | |
t.start(); | |
t.join(); | |
} | |
// Eventually throws java.lang.OutOfMemoryError: unable to create new native thread |
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 sbt._ | |
import sbt.Keys._ | |
object MyPlugin extends AutoPlugin { | |
override lazy val projectSettings: Seq[Setting[_]] = Seq( | |
resourceDirectory in Compile := file("/tmp") | |
) | |
} | |
object MyBuild extends Build { |
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
package trees | |
object Main extends App { | |
trait Node | |
case class InnerTreeNode ( left:Node, right:Node, value:Int ) extends Node | |
case object StopNode extends Node | |
def leaf(x: Int): Node = InnerTreeNode(StopNode, StopNode, x) |
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 set = Command(SetCommand, setBrief, setDetailed)(setParser) { | |
case (s, (all, arg)) => | |
val extracted = Project extract s | |
import extracted._ | |
val dslVals = extracted.currentUnit.unit.definitions.dslDefinitions | |
// TODO - This is possibly inefficient (or stupid). We should try to only attach the | |
// classloader + imports NEEDED to compile the set command, rather than | |
// just ALL of them. | |
val ims = (imports(extracted) ++ dslVals.imports.map(i => (i, -1))) | |
val cl = dslVals.classloader(currentLoader) |
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
language: scala | |
scala: | |
- 2.10.3 | |
script: | |
- sbt compile test:compile | |
- sbt scalastyle | |
- sbt test | |
jdk: | |
- oraclejdk7 | |
- openjdk7 |
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
struct Node<T> { | |
value: T, | |
next: Option<~Node<T>> | |
} | |
struct LinkedList<T> { | |
head: ~Node<T>, | |
tail: ~Node<T> | |
} |
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 Util { | |
def dangerousString(str: String) : Future[String] = { | |
liveDangerously() | |
Future.successful(str) | |
} | |
// now becomes | |
def dangerousString(str: String) : Future[String] = { |
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 timing[A](x: => A): Int = { | |
import com.github.nscala_time.time.Imports._ | |
import org.joda.time.PeriodType | |
val then = LocalDateTime.now | |
x | |
new Period(then, LocalDateTime.now, PeriodType.millis).getValue(0) | |
} |