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
implicit def liftJsonUnmarshaller[A :Manifest] = new UnmarshallerBase[A] { | |
val canUnmarshalFrom = ContentTypeRange(`application/json`) :: Nil | |
def unmarshal(content: HttpContent) = protect { | |
val jsonSource = DefaultUnmarshallers.StringUnmarshaller.unmarshal(content).right.get | |
parse(jsonSource).extract[A] | |
} | |
} | |
implicit def liftJsonMarshaller[A <: AnyRef] = new MarshallerBase[A] { | |
val canMarshalTo = ContentType(`application/json`) :: Nil |
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 com.excilys.ebi.gatling.core.Predef._ | |
import com.excilys.ebi.gatling.http.Predef._ | |
import scala.util.Random | |
import com.excilys.ebi.gatling.core.feeder.Feeder | |
class ServiceSimulation extends Simulation { | |
def apply = { | |
val random = new Random | |
random.setSeed(System.currentTimeMillis) |
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 reactivemongo.bson.BSONDocument | |
import reactivemongo.api.collections.default.BSONCollection | |
import reactivemongo.api.{QueryOpts, DB} | |
import reactivemongo.core.commands.Count | |
import reactivemongo.api.collections.default._ | |
def getDocument(collection: BSONCollection): Future[Option[YourClass]] = { | |
val futureCount = db.command(Count(collection.name)) | |
futureCount.flatMap { count => | |
val skip = Random.nextInt(count) |
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
scala> "mongodb://dbuser:[email protected]:22222/heroku_app1111" | |
res7: String = mongodb://dbuser:[email protected]:22222/heroku_app1111 | |
scala> val pattern = "^mongodb:\\/\\/([\\w]+):([\\w]+)@([\\w\\.]+):([\\d]+)\\/([\\w]+)".r | |
pattern: scala.util.matching.Regex = ^mongodb:\/\/([\w]+):([\w]+)@([\w\.]+):([\d]+)\/([\w]+) | |
scala> val pattern(user, password, host, port, db) = res7 | |
user: String = dbuser | |
password: String = dbpassword | |
host: String = 1111.mongolab.com |
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 | |
import reactivemongo.bson.{Macros, BSONDocument, BSONDocumentReader} | |
import com.blrest.model.{FlickrData, ImageMeta} | |
/** | |
* Created by ccarrier for bl-rest. | |
* at 3:19 PM on 12/15/13 | |
*/ | |
package object blrest { |
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.blrest.dao | |
import scala.concurrent.Future | |
import akka.actor.ActorSystem | |
import reactivemongo.bson.BSONDocument | |
import reactivemongo.api.{QueryOpts, DB} | |
import reactivemongo.core.commands.Count | |
import reactivemongo.api.collections.default._ |
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 android.net.http.AndroidHttpClient; | |
import android.util.Base64; | |
import android.util.Log; | |
import com.google.gson.Gson; | |
import com.google.gson.reflect.TypeToken; | |
import org.apache.http.Header; | |
import org.apache.http.HttpResponse; | |
import org.apache.http.client.ClientProtocolException; |
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
BallHttpClient<Ball> httpClient = new GenericHttpClient<Ball>(SCHEME, HOST, PORT); |
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 java.io.IOException; | |
import java.io.UnsupportedEncodingException; | |
import java.net.URI; | |
import java.net.URISyntaxException; | |
import java.net.URLEncoder; | |
import java.util.ArrayList; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.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
private BallHttpClient<Ball> httpClient = new BallHttpClient<Ball>(SCHEME, HOST, PORT){ | |
@Override | |
public ResponseHandler<Ball> createResponseHandler() { | |
return new ResponseHandler<Ball>(){ | |
@Override | |
public Ball handleResponse(HttpResponse resp) | |
throws ClientProtocolException, IOException, NoResourceFoundException, ErrorAccessingResourceException { | |
handleErrors(resp); | |
return gson.fromJson(new InputStreamReader(resp.getEntity().getContent()), Ball.class); |
OlderNewer