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 imperative | |
import fp.{Book, Genre} | |
import scala.collection.mutable.ListBuffer | |
import scala.util.matching.Regex | |
trait BookValidation { |
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
trait Event | |
object KafkaEncoder { | |
type KafkaProtobufEvent[T <: Event] = GeneratedMessage with Message[T] with Updatable[T] with Event | |
type KafkaProtobufEncoder[E <: KafkaProtobufEvent[E]] = GeneratedMessageCompanion[E] | |
def apply[T <: KafkaProtobufEvent[T]](implicit enc: KafkaEncoder[T]) = enc | |
def serialize[T <: KafkaProtobufEvent[T]](data: T)(implicit companion: KafkaProtobufEncoder[T]): Array[Byte] = |
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
trait Operation | |
trait Revert | |
trait Transaction[R <: Revert, O <: Operation] |
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
lazy val root = (project in file(".")).enablePlugins(PlayScala). | |
settings( | |
slick <<= slickCodeGenTask // register manual sbt command | |
) | |
// code generation task | |
lazy val slick = TaskKey[Seq[File]]("gen-tables") | |
lazy val slickCodeGenTask = (sourceManaged, dependencyClasspath in Compile, runner in Compile, streams) map { (dir, cp, r, s) => | |
val outputDir = (dir / "slick").getPath // place generated files in sbt's managed sources folder | |
val url = "jdbc:oracle:thin:@mdebddd06.suranet.com:1537/DLLOLFHA" // connection info for a pre-populated throw-away, in-memory db for this demo, which is freshly initialized on every run |
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
protected val driver = com.typesafe.slick.driver.oracle.OracleDriver | |
import TperTiposPersonasRegistro._ | |
import driver.api._ | |
class TperTiposPersonas( _tableTag: Tag ) extends Table[TperTiposPersonasRegistro]( _tableTag, None, "TPER_TIPOS_PERSONAS" ) { | |
val cdtipoPersona: Rep[String] = column[String]( "CDTIPO_PERSONA", O.PrimaryKey, O.Length( 2, varying = true ) ) | |
val dstipoPersona: Rep[Option[String]] = column[Option[String]]( "DSTIPO_PERSONA", O.Length( 30, varying = true ) ) | |
val febaja: Rep[Option[Timestamp]] = column[Option[Timestamp]]( "FEBAJA" ) | |
val snnumerico: Rep[Option[Char]] = column[Option[Char]]( "SNNUMERICO" ) |
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 cats.data._ | |
import cats.syntax.traverse._ | |
import cats.std.list._ | |
import scala.util.Try | |
def tryInt(s: String): Try[Int] = Try(s.toInt) | |
def reader: Reader[Try[Int], String] = Reader[Try[Int], String] { t => | |
t.map(s => s"$s is a number").getOrElse("not") |
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 cats.data.{Kleisli, ListT} | |
import cats.std.list._ | |
type ListTA[A] = ListT[List, A] | |
val (f, g, h, x) = ( | |
(a: Int) => a match { | |
case 0 => ListT.fromList(List(List(0, 1))) | |
case 1 => ListT.fromList(List(List(0), List(1))) |
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 cats.data | |
import cats._ | |
import cats.functor.Contravariant | |
import ListT._ | |
/** | |
* ListT monad transformer. | |
*/ | |
sealed class ListT[M[_], A](val value: M[Step[A, ListT[M, A]]]) { |
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 user.controllers | |
import genesis.user.persistence.repository.{UserFilter, UserRepository} | |
import play.api.libs.json._ | |
import play.api.mvc.{Action, Controller} | |
import scala.concurrent.Future | |
/** | |
* Created by leandrob13 on 10/9/15. | |
*/ |
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 user.persistence.repository | |
import user.persistence.tables.UserRegister | |
import user.persistence.tables.UserTables.Users | |
import play.api.Play | |
import play.api.db.slick.DatabaseConfigProvider | |
import scala.concurrent.Future | |
case class UserFilter(name: Option[ String ] = None, lastname: Option[ String ] = None, | |
email: Option[ String ] = None, username: Option[ String ] = None, |