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.annotation.implicitNotFound | |
| // Db effects | |
| sealed trait DbEffect | |
| trait ActualRead extends DbEffect | |
| trait StaleRead extends DbEffect | |
| trait Write extends DbEffect | |
| // Db effects applicability map |
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.annotation.implicitNotFound | |
| // Db effects | |
| sealed trait DbEffect | |
| trait ActualRead extends DbEffect | |
| trait StaleRead extends DbEffect | |
| trait Write extends DbEffect | |
| // Db effects applicability map |
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 confirmCode( | |
| userModel: UserModel, | |
| confirmationCodeType: ConfirmationCodeType, | |
| confirmationCode: String, | |
| newPhone: String | |
| ): DBIO[Either[Throwable, UpdateUserResult]] = { | |
| (for { | |
| code <- findActiveCode(confirmationCode, confirmationCodeType) eitherT | |
| _ <- confirmCodeByIdAndBindUserToIt(code.id, userId, now) eitherT | |
| _ <- updateUnconfirmedPhoneOrUserPhone(confirmationCodeType, userModel, newPhone) eitherT |
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
| class MyMap[K,V] private(val buckets:Array[Array[(K,V)]]) extends (K => V) { | |
| val size = buckets.length | |
| def apply(key:K):V = get(key).get | |
| def get(key:K):Option[V] = { | |
| val i = Math.abs(key.hashCode() % size) | |
| val bucket = buckets(i) | |
| if (bucket == null) None else { | |
| val filtered = bucket filter {_._1 == key} | |
| if (!filtered.isEmpty) Some(filtered.head._2) else None |
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.language.postfixOps | |
| val NL = "\r\n" | |
| implicit class StringOps(s:String) { | |
| def hcentered(l:Int):String = (s split "\r\n") map {s => s hcenteredSingle l} reduce {_ + "\r\n" + _} | |
| def hcenteredSingle(l:Int):String = { | |
| if (s.isEmpty) " " * l else { | |
| if (s.length >= l) s else { |
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
| abstract class Expr | |
| case class Var(name: String) extends Expr { | |
| override def toString:String = s"$name" | |
| } | |
| case class Number(num: Double) extends Expr { | |
| override def toString = num.toString | |
| } | |
| case class UnOp(operator: String, arg: Expr) extends Expr { |
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
| --- | |
| # SEE: http://schemas.xmlsoap.org/wsdl/ | |
| title: PimPay Platform Api Manifest | |
| version: 2.7 | |
| uversion: v2_7 | |
| directory: v2_7 # лежит в soap/v2_7 | |
| date: 02.09.2016 | |
| wsdl: | |
| schemaLocation: http://platform.api.%fqdn%/v2_7/soap/wsdl | |
| invokeLocation: http://platform.api.%fqdn%/v2_7/soap/invoke |
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 Test { | |
| def curry[A,B,C](f: (A, B) => C): A => (B => C) = a => f(a, _) | |
| def uncurry[A,B,C](f: A => B => C): (A, B) => C = f(_)(_) | |
| def compose[A,B,C](f: B => C, g: A => B): A => C = a => f(g(a)) | |
| def mul(a:Int, b:Int) = a * b | |
| val mulC = curry(mul) | |
| mulC(5)(10) |
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 Test { | |
| def curry[A,B,C](f: (A, B) => C): A => (B => C) = a => f(a, _) | |
| def uncurry[A,B,C](f: A => B => C): (A, B) => C = f(_)(_) | |
| def compose[A,B,C](f: B => C, g: A => B): A => C = a => f(g(a)) | |
| def mul(a:Int, b:Int) = a * b | |
| val mulC = curry(mul) | |
| mulC(5)(10) |
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 LUB[L <: HList, B] { | |
| def apply(value:L):Boolean | |
| } | |
| object LUB { | |
| def apply[L <: HList, B](implicit inst: LUB[L, B]): LUB[L, B] = inst | |
| implicit def hlistLub[L <: HList, B, S0 <: HList, F0 <: HList, N <: Nat](implicit | |
| subtype: SubtypeUnifier.Aux[L, B, S0], | |
| filter: FilterNot.Aux[S0, B, F0], | |
| len: Length.Aux[F0, N], |