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
@Configuration | |
@Slf4j | |
public class DataSourceConfig { | |
@Bean | |
@Primary | |
@ConfigurationProperties(prefix = "spring.datasource.pws") | |
public DataSourceProperties pwdDataSourceProperties() { | |
return new DataSourceProperties(); | |
} |
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 socket | |
import sys | |
import time | |
if len(sys.argv) == 3: | |
# Get "IP address of Server" and also the "port number" from argument 1 and argument 2 | |
ip = sys.argv[1] | |
port = int(sys.argv[2]) | |
else: | |
print("Run like : python3 client.py <arg1 server ip 192.168.1.102> <arg2 server port 4444 >") |
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.example | |
import akka.actor.typed.{ActorRef, ActorSystem, Behavior, SupervisorStrategy, Terminated} | |
import akka.actor.typed.scaladsl.{Behaviors, PoolRouter, Routers} | |
import com.example.ParentActor._ | |
import com.example.Transformer.{ConvertPlease, GracefulShutdown} | |
object Transformer { | |
sealed trait Request |
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
{"name": "Michael", "age": 32, "gender": "male", "country": "TW"} | |
{"name": "David", "age": 12, "gender": "male", "country": "HK"} | |
{"name": "Amy", "age": 20, "gender": "female", "country": "HK"} | |
{"name": "Andy", "age": 40, "gender": "male", "country": "TW"} |
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
case class StringList(xs: List[String]) { | |
def prepend(element: String) = StringList(element :: xs) | |
} | |
val xs = List(1, 2, 3, "aa", "bb", "cc", 4, 5.5, 7, "dd", "ee", "ff", "gg", 8, 9.2, 10) | |
val r = xs.foldRight(List.empty[Any]) { | |
case (current: String, compactedList @ ((strList: StringList) :: xs)) => strList.prepend(current) :: xs | |
case (current: String, compactedList @ (_ :: xs)) => new StringList(current :: Nil) :: compactedList | |
case (current: Int, compactedList) => current :: compactedList |
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.parsing.combinator._ | |
case class Anyline(x: String) | |
case class Comment(comment: String) | |
case class Index(mode: String) | |
case class Field(iden: String, dataType: String, data: Any) | |
case class Block(name: String, data: Any) | |
object MyParsers extends RegexParsers { | |
override val whiteSpace = """[ \t]+""".r |
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
val useCase = new BaseUseCase[Int] { | |
def execute() = 100 | |
} | |
val result = executor.execute(useCase) { r => r } | |
result shouldBe Success(100) |
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
val useCase = new BaseUseCase[Int] { | |
def execute() = 100 | |
} | |
var isCalled = false | |
var useCaseResult: Try[Int] = Failure(new NoSuchElementException) | |
executor.execute(useCase) { result => | |
isCalled = true | |
useCaseResult = result |
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
object UseCaseExecutor { | |
type Presenter[T] = (Try[T] => Unit) | |
} | |
abstract class UseCaseExecutor { | |
import UseCaseExecutor.Presenter | |
def execute[T](useCase: UseCase[T])(presenter: Presenter[T]): Unit = { |
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
class UserToJSONPresenter extends CreateUserPresenter { | |
private var mData: User = _ | |
def onResult(user: User) { | |
mData = user | |
} | |
def toJSON = ??? | |
} | |
val executor = new NoLogUseCaseExecutor | |
val useCase = new CreateUser(....) | |
val newUser = executor.execute(useCase, presenter) |
NewerOlder