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
| context "client correctly handles error status codes" $ do | |
| let test :: (WrappedApi, String) -> Spec | |
| test (WrappedApi api, desc) = | |
| it desc $ | |
| withWaiDaemon (return (serve api (left (500, "error message")))) $ | |
| \ host -> do | |
| let getResponse :: EitherT ServantError IO () | |
| getResponse = client api host | |
| Left FailureResponse{..} <- liftIO $ runEitherT getResponse | |
| runIO $ responseStatus `shouldBe` (Status 500 "error message") |
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
| {-# LANGUAGE CPP #-} | |
| {-# LANGUAGE DataKinds #-} | |
| {-# LANGUAGE DeriveGeneric #-} | |
| {-# LANGUAGE FlexibleContexts #-} | |
| {-# LANGUAGE GADTs #-} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| {-# LANGUAGE RecordWildCards #-} | |
| {-# LANGUAGE StandaloneDeriving #-} | |
| {-# LANGUAGE TypeOperators #-} | |
| {-# OPTIONS_GHC -fcontext-stack=25 #-} |
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
| [ | |
| { | |
| "array": [ | |
| { | |
| "id": "0" | |
| }, | |
| { | |
| "id": "1" | |
| } | |
| ] , |
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
| /** @jsx React.DOM */ | |
| var React = require('react'); | |
| module.exports = React.createClass({ | |
| getInitialState: function() { | |
| return { | |
| sameAsBilling: true | |
| } | |
| }, |
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
| r.db('lumi').table('users').coerceTo('array').filter(function(row){ | |
| return row('username').match('[^a-zA-Z0-9_]') | |
| }).update({ | |
| username: r.row('username').coerceTo('string').replace(/[^a-zA-Z0-9_]/gi, '') | |
| }) |
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
| trait Rql { | |
| // val DEFAULT_HOST = "localhost" | |
| // val DEFAULT_PORT_DRIVER = 28015 | |
| def connect: Connection | |
| def get(db:String, table: String): String = { | |
| // Table example | |
| val query = Json.array( | |
| jNumber(1), Json.array( | |
| jNumber(15), Json.array( |
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
| overriding value connection in trait Rql of type com.scalaRethinkdb.Connection; | |
| value connection has incompatible type | |
| val connection = connect _ |
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
| private def recvAll(accum: Int): Array[Byte] = { | |
| @tailrec def recvAllBuf(response: Array[Byte], acc: Int): Array[Byte] = { | |
| val character = in.read() | |
| val responseArray = response :+ character.toByte | |
| acc match { | |
| case 0 => responseArray | |
| case _ => recvAllBuf(responseArray, acc - 1) | |
| } | |
| } |
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
| package com.scalaRethinkdb | |
| object VersionDummy { | |
| sealed abstract class Version | |
| object V0_3 extends Version | |
| object V0_4 extends Version | |
| object Version { | |
| implicit object instances extends Wire[Version] { | |
| def toWire(a: Version): Int = a 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
| package com.scalaRethinkdb | |
| object VersionDummy { | |
| trait Version extends Wire[Version] { | |
| def fromWire(a: Int): Version = a match { | |
| case 0x5f75e83e => V0_3 | |
| case 0x400c2d20 => V0_4 | |
| case _ => throw new RethinkDbUnexpectedResponseError("Version not found.") | |
| } | |
| } |