Skip to content

Instantly share code, notes, and snippets.

View ruslanbogun's full-sized avatar

Ruslan Bogun ruslanbogun

View GitHub Profile
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 {
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] =
import scodec.Codec
import scodec.codecs._
trait G
type A = G
type B = G
case class One(a: Int) extends G
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] {
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
@ruslanbogun
ruslanbogun / gist:0cd5b91cc80bd8346273e0be966fa588
Last active August 8, 2019 13:55
No implicit Ordering defined for org.joda.time.DateTime
implicit def dateTimeOrdering: Ordering[DateTime] = Ordering.fromLessThan(_ isBefore _)
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)
}
implicit val jodaDateReads = Reads.jodaDateReads("yyyy-MM-dd HH:mm:ss Z")
implicit val jodaDateWrites = Writes.jodaDateWrites("yyyy-MM-dd HH:mm:ss Z")