This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.
Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).
| import scala.annotation.tailrec | |
| import scala.collection.immutable.HashMap | |
| case class TrieNode(h: HashMap[Char, TrieNode], isWord: Boolean = false) | |
| object TrieNode { | |
| def empty = TrieNode(HashMap.empty) | |
| def buildTrieNode(s: List[Char], t: TrieNode = TrieNode.empty): TrieNode = { | |
| s match { | |
| case Nil => t.copy(isWord = true) |
| case class TrieNode[T](edgeList: Map[T, TrieNode[T]] = Map.empty[T, TrieNode[T]], isLeaf: Boolean = false, | |
| isEntry: Boolean = false) | |
| object TrieNode { | |
| def emptyTrieNode[T]: TrieNode[T] = { | |
| TrieNode[T]() | |
| } | |
| def newTrieNode[T](data: T): TrieNode[T] = { | |
| TrieNode[T](edgeList = Map[T, TrieNode[T]]((data, emptyTrieNode[T]))) |
| package akkahttptest | |
| import akka.http.Http | |
| import akka.stream.ActorFlowMaterializer | |
| import akka.actor.ActorSystem | |
| import akka.stream.scaladsl.{Sink, Source} | |
| import akka.http.model._ | |
| object TestClient extends App { |
This focuses on generating the certificates for loading local virtual hosts hosted on your computer, for development only.
Do not use self-signed certificates in production ! For online certificates, use Let's Encrypt instead (tutorial).
| import java.io.ByteArrayOutputStream | |
| import java.time.Duration | |
| import java.util.concurrent.Executors | |
| import java.util.{Properties, Timer, TimerTask, UUID} | |
| import Models.{Message, SystemMessage, UserMessage, msgAvroSchema} | |
| import com.sksamuel.avro4s.{AvroInputStream, AvroOutputStream, AvroSchema} | |
| import org.apache.kafka.clients.consumer._ | |
| import org.apache.kafka.clients.producer._ | |
| import org.apache.kafka.common.errors.WakeupException |
Example on how to run locally an AWS Lambda via API Gateway using localstack.
Based on...
| apiVersion: v1 | |
| kind: Service | |
| metadata: | |
| name: redis-service | |
| spec: | |
| type: LoadBalancer | |
| selector: | |
| app: redis | |
| ports: | |
| - name: redis |
Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.
A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.
val square : Int => Int = x => x * x| import scala.slick.lifted.CanBeQueryCondition | |
| // optionally filter on a column with a supplied predicate | |
| case class MaybeFilter[X, Y](val query: scala.slick.lifted.Query[X, Y]) { | |
| def filter[T,R:CanBeQueryCondition](data: Option[T])(f: T => X => R) = { | |
| data.map(v => MaybeFilter(query.filter(f(v)))).getOrElse(this) | |
| } | |
| } | |
| // example use case | |
| import java.sql.Date |