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: 'Afghanistan', code: 'AF'}, | |
{name: 'Åland Islands', code: 'AX'}, | |
{name: 'Albania', code: 'AL'}, | |
{name: 'Algeria', code: 'DZ'}, | |
{name: 'American Samoa', code: 'AS'}, | |
{name: 'AndorrA', code: 'AD'}, | |
{name: 'Angola', code: 'AO'}, | |
{name: 'Anguilla', code: 'AI'}, | |
{name: 'Antarctica', code: 'AQ'}, |
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
### Keybase proof | |
I hereby claim: | |
* I am pvillega on github. | |
* I am pvillega (https://keybase.io/pvillega) on keybase. | |
* I have a public key whose fingerprint is 4003 AFBF D975 6FE9 95ED 3813 4D71 E911 8574 2DBC | |
To claim this, I am signing this object: |
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
public void signRequest(Request request) { | |
if (apiKey != null) { | |
try { | |
request.queryParameter(API_KEY_NAME, bapiKey); | |
request.queryParameter(TIMESTAMP_NAME, String.valueOf(System.currentTimeMillis())); | |
request.queryParameter(SIGNATURE_NAME, sign(getSignablePart(request), apiKey.getPrivateKey())); | |
} catch (Exception ex) { | |
throw new RuntimeException(ex); | |
} | |
} |
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
Given the following request to a QA bapi instance, signed as specified in the document we sent: | |
http://bapi.qa8.gumtree.com/api/accounts/101981/packages?timestamp=1422961797794&signature=3d311860aa1bf1bd912ff0880102999f9c46a3670e8fb7ea9f71f112cb72e1a1&apiKey=c7deb878d73c3d3468a53a16f2c4232d | |
Your response will have the following headers: | |
Content-Type → application/json;charset=UTF-8 | |
Date → Tue, 03 Feb 2015 11:10:44 GMT | |
Server → GumBackend | |
Transfer-Encoding → chunked |
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
// simplified code to give the idea. Starting with 2 DSL, Trades and Http | |
object Trades { | |
sealed trait DSL[A] { def url: String } | |
final case class HeartBeat() extends DSL[TradeResult[StatusOk]] | |
type TradesPRG[A] = (DSL :|: FXNil)#Cop[A] | |
} | |
object Http { | |
sealed trait DSL[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
// Sample of code | |
// Trades Api | |
case object IsApiUp extends DSL[Xor[ErrorMessage, Ok]] | |
final case class Buy(venue: Sring, account: String, order: Order) extends DSL[Xor[ErrorMessage, NewOrderResponse]] | |
final case class VenueStocks(venue: String) extends DSL[Xor[ErrorMessage, List[Stock]]] | |
// Program | |
type API = LogApi.PRG :||: TradeApi.PRG |
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
// If I have a very simple program | |
def example2(venue: String, account: String) = for { | |
_ <- info("blah blah").freeko[API, O] // Returns Unit | |
b <- buy(venue, account, Order("BAD", -1, -1)).freeko[API, O] // Returns Result[OrderStatus] | |
} yield b | |
// with API definition and Onion | |
type Result[A] = Xor[String, A] | |
type API = LogApi.PRG :||: TradeApi.PRG | |
val API = Program[API] |
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 MainServer extends TwitterServer { | |
override def failfastOnFlagsNotParsed: Boolean = true | |
// some flags received via config | |
val port: Flag[Int] = flag("port", 8081, "TCP port for HTTP server") | |
// logging formatter | |
override def defaultFormatter = new Formatter( | |
timezone = Some("UTC"), | |
prefix = "<yyyy-MM-dd HH:mm:ss.SSS> [%.3s] %s: " |
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
// Credit to Kevin Horlick @beefyhalo fir the Meta implementation | |
// See https://gitter.im/tpolecat/doobie/archives/2015/12/22 | |
// It wasn't straightforward to find the answer, my Google-foo is weak, so I hope | |
// this helps people looking for this answer | |
// allows generation of doobie Meta objects from Refined types | |
implicit def refinedMeta[T: Meta, P, F[_, _]](implicit tt: TypeTag[F[T, P]], | |
ct: ClassTag[F[T, P]], | |
validate: Validate[T, P], | |
refType: RefType[F]): Meta[F[T, P]] = |
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
// List of Strings you may want to use for testing in input fields, as they can cause unexpected behaviour. Input fields | |
// should either return validation errors or sanitize them. | |
// Using mostly Strings due to the way JVM manages Chars with Unicode. | |
// Based on https://github.com/minimaxir/big-list-of-naughty-strings - version 29th May 2017 - update as required | |
import org.scalacheck.Gen | |
trait NaughtyStringsList { | |
val naughtyReservedStrings: Gen[String] = Gen.oneOf( |
OlderNewer