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 scala.reflect._ | |
trait History | |
case class SlotHistory(t: Int) extends History | |
case class RouletteHistory(t: String) extends History | |
def test[T <: History : ClassTag](): T = { | |
classTag[T].runtimeClass match { |
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 scodec.bits.BitVector | |
import scodec.{Attempt, Codec} | |
import scodec.codecs.int32L | |
trait T | |
case class One(a: Int) extends T | |
object One { | |
implicit val codecOne: Codec[One] = |
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 scodec.Codec | |
import scodec.codecs._ | |
trait G | |
type A = G | |
type B = G | |
case class One(a: Int) extends G |
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
type Plus | |
type Minus | |
trait Expression[E] { | |
def value(a: Int, b: Int): Int | |
} | |
def expression[E](a: Int, b: Int)(implicit t: Expression[E]) = t.value(a, b) | |
implicit object plus extends Expression[Plus] { |
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
Amazon provides Amazon Linux AMIs that are configured to run as NAT instances. These AMIs include the string amzn-ami-vpc-nat in their names, so you can search for them in the Amazon EC2 console. | |
redirect from NAT to private net | |
sudo iptables -t nat -A PREROUTING -p tcp --dport 10234 -j DNAT --to-destination 10.0.1.234:22 | |
sudo iptables -A POSTROUTING -t nat -s 10.0.1.0/24 -j MASQUERADE | |
sudo /etc/init.d/iptables save | |
list | |
sudo iptables -t nat -L -n -v | |
sudo iptables -t nat -v -L PREROUTING -n --line-number |
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
implicit def dateTimeOrdering: Ordering[DateTime] = Ordering.fromLessThan(_ isBefore _) |
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
val f: Future[T] = ... | |
val result: Try[T] = Await.ready(f, Duration.Inf).value.get | |
val resultEither = result match { | |
case Success(t) => Right(t) | |
case Failure(e) => Left(e) | |
} |
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
implicit val jodaDateReads = Reads.jodaDateReads("yyyy-MM-dd HH:mm:ss Z") | |
implicit val jodaDateWrites = Writes.jodaDateWrites("yyyy-MM-dd HH:mm:ss Z") |