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 awscala.Region | |
| import awscala.s3.Bucket | |
| import com.typesafe.config.ConfigValueType | |
| import pureconfig.error.{FailureReason, WrongType} | |
| import pureconfig.{ConfigCursor, ConfigReader} | |
| import scala.util.{Failure, Success, Try} | |
| object ConfUtils { |
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 monix.eval.Task | |
| import monix.reactive._ | |
| import scala.concurrent.Await | |
| import scala.concurrent.duration.Duration | |
| import scala.language.postfixOps | |
| import scala.util.Random | |
| import scala.concurrent.duration._ | |
| def retryOnFailure(times: Int, source: Task[Int]): Task[Int] = |
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 vertx = Vertx.vertx() | |
| vertx.createHttpServer().requestHandler(req => { | |
| }).listen(8080) |
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 vertx = Vertx.vertx() | |
| vertx.createHttpServer().requestHandler(req => { | |
| req.path() match { | |
| case p if p contains("/user") => | |
| val f = for { | |
| f1 <- Future { req.getParam("id").get.toInt } | |
| f2 <- if (f1 < 100) Future.unit else Future.failed(CustomException()) | |
| f3 <- Future { getUserFromDb(f1) } | |
| } yield f3 |
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 vertx = Vertx.vertx() | |
| vertx.createHttpServer.requestHandler(p => { | |
| p.path match { | |
| case a if a contains "/tes1" => | |
| val f = for { | |
| f1 <- Future (Thread.sleep(5000)) | |
| f2 <- Future (Thread.sleep(5000)) | |
| } yield f2 | |
| f.onComplete{ |
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 o = Class.forName("me.mbcu.dapackage.TwoStringConstructorClass").getConstructors()(0) | |
| val args = Array[AnyRef]("aaaa", "bbbb") | |
| val c = o.newInstance(args:_*).asInstanceOf[ParentAbstractClass] |
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 p = OkexParameters(Some(signed), apiKey, Some(symbol), None, None, None, None, Some(status), Some(currentPage), Some(pageLength)) | |
| import reflect.runtime.universe._ | |
| import reflect.runtime.currentMirror | |
| val m = currentMirror.reflect(p) | |
| m.symbol.typeSignature.members.toStream | |
| .collect{case s : TermSymbol if !s.isMethod => m.reflectField(s)} | |
| .filter(r => r.get != None) // filter out None | |
| .map(r => r.get 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
| object OkexStatus extends Enumeration { | |
| type OkexStatus = Value | |
| val filled = Value(1) | |
| val unfilled = Value(0) | |
| implicit val enumFormat = new Format[OkexStatus] { | |
| override def reads(json: JsValue): JsResult[OkexStatus] = json.validate[Int].map(OkexStatus(_)) | |
| override def writes(enum: OkexStatus) = JsNumber(enum.id) | |
| } | |
| } |