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 Scratchpad { | |
static enum RouteNames { | |
USERS_FORM, | |
USERS_JSON, | |
USER_GET, | |
USER_POST | |
}; | |
public static void main(String[] args) { | |
new Routes( |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Title</title> | |
</head> | |
<body> | |
<script | |
src="https://code.jquery.com/jquery-2.2.4.min.js" |
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
$.ajax("http://localhost:8080/api/v1/loan-applications", { 'method': 'POST', 'contentType' : 'json', 'headers': { 'Content-Type': 'application/json', 'X-Custom-MerchantId': '123' } , 'data': '{ "productId": "123", "amount": "222", "language": "fr" }'}) |
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 * as React from 'react'; | |
import { Text, View, ScrollView, Button, StyleSheet } from 'react-native'; | |
//let contacts = [...Array(10).keys()].map(i => { | |
// return { id: i, name: "Eric " + i , phoneNumber: "000000000" + i } | |
//}) | |
let contacts = [{ id: 1, name: "Eric", phoneNumber: "00000" }] | |
const stylesheets = StyleSheet.create({ |
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
// Start writing your ScalaFiddle code here | |
case class Book(title: String, author: String) | |
trait ToJson[A] { | |
def toJson(a: A): String | |
} | |
trait ToXml[A] { | |
def toXml(a: A): 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
trait Functor[M[_]] { | |
def map[A, B](ma: M[A], f: A => B): M[B] | |
def lift[A, B](f: A => B): M[A] => M[B] | |
} | |
object Functor { | |
def apply[F[_] : Functor]: Functor[F] = implicitly[Functor[F]] | |
implicit val optionIsFunctor = new Functor[Option] { |
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
trait Show[A] { | |
def show(a: A): String | |
} | |
object Show { | |
// def apply[A](implicit sh: Show[A]): Show[A] = sh | |
def apply[A: Show]: Show[A] = implicitly[Show[A]] | |
object ops { |
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 cats.implicits._ | |
trait UseCase[In, Out, Err] extends Function1[In, Either[Err, Out]] | |
trait CreateLoanApplication extends UseCase[CreateLoanApplicationIn, CreateLoanApplicationOut, CreateLoanApplicationErr] { | |
override def apply(in: CreateLoanApplicationIn): Either[CreateLoanApplicationErr, CreateLoanApplicationOut] = { | |
Either.right(CreateLoanApplicationOut()) | |
} | |
} | |
case class CreateLoanApplicationIn() |
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
// Start writing your ScalaFiddle code here | |
import cats.implicits._ | |
trait UseCase[Parameters, Error, Result] { | |
def execute(p: Parameters): Either[Error, Result] | |
} | |
import CreateLoanApplication._ | |
trait CreateLoanApplication extends UseCase[CreateLoanApplicationRequest, CreateLoanApplicationError, CreateLoanApplicationResult] { |
NewerOlder