This file contains 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 com.dius.pact.runner | |
import spray.routing.SimpleRoutingApp | |
import akka.actor.ActorSystem | |
import com.dius.pact.model.{Interaction, Pact} | |
object PactMockService extends App with SimpleRoutingApp { | |
implicit val system = ActorSystem("pack-mock-system") | |
val basePath = "src/test/resources" |
This file contains 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 myaccount.rest | |
import com.dius.pact.model.{Request, Pact} | |
import com.dius.pact.runner.PactFileSource | |
import org.specs2.mutable.Specification | |
import play.api.test.WithServer | |
import play.api.libs.ws.WS | |
import play.api.test.Helpers._ | |
import scala.concurrent.Await | |
import scala.concurrent.duration._ |
This file contains 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.util.{Failure, Success, Try} | |
import play.api.libs.json.{Json, JsValue} | |
import play.api.LoggerLike | |
trait BusinessProcess extends PropertiesContext { | |
def logger: LoggerLike | |
def processRequest[A, B](bodyExtractor: => A, doBusiness: A => BusinessResult[B]): BusinessResult[B] = { |
This file contains 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
/** | |
* Algebraic Data Type (ADT) for results that the business layers return to controllers. | |
* It has two cases: | |
* <ul> | |
* <li> OKResult wrapping a value | |
* <li> FailedResult containing a discriminator value and a list of error messages. | |
* <ul> | |
* Author: https://github.com/kenbot | |
*/ | |
sealed trait BusinessResult[+A] { |
This file contains 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
<?xml version="1.0"?> | |
<!-- | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software | |
distributed under the License is distributed on an "AS IS" BASIS, |
This file contains 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 myaccount | |
import scala.util.parsing.combinator.RegexParsers | |
object CatchingUrl extends App { | |
val path = "/Users/twer/Downloads/Enquiries - 107718461.csv" | |
val urlPat = """(.*)([ \t\r\n\f=]+(https?://)?([\d\w-]+\.)+[A-Za-z]+[\w- ./?%&=]*)(.*)""".r | |
val lines = CSV.parse(path) | |
lines.map { |
This file contains 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 rel | |
object PackageClassReaderDemo extends App{ | |
println(PackageClassReader.getClassNamesFromPackage("org.apache.spark.examples","/Users/xfwu/hadoop/workspace/app/app.jar").mkString("\n")) | |
} | |
object PackageClassReader { | |
def getClassNamesFromPackage(packageName: String,file:String): Seq[String] = { |
This file contains 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 rel | |
import scala.collection.mutable.ListBuffer | |
case class Graph(adj: Array[ListBuffer[Int]]) | |
object GraphBuild { | |
def apply(size: Int, data: (Int,Int) *) = { | |
val vertexs = new Array[ListBuffer[Int]](size) |
This file contains 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
/* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* | |
* Unless required by applicable law or agreed to in writing, software | |
* distributed under the License is distributed on an "AS IS" BASIS, | |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
NewerOlder