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
| class ReactiveMongoConnection extends Module { | |
| import ExecutionContext.Implicits.global | |
| private val config = ConfigFactory.load() | |
| implicit val context = inject[ActorSystem] | |
| val driver = new MongoDriver | |
| val pattern = "^mongodb:\\/\\/([\\w]*):([\\w]*)@([\\w\\.-]+):([\\d]+)\\/([\\w]+)".r | |
| val envUri = Properties.envOrElse("MONGOLAB_URI", "").toString |
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
| import reactivemongo.bson.{BSONHandler, BSONDateTime, Macros} | |
| import org.joda.time.format.ISODateTimeFormat | |
| import org.joda.time.{DateTime, DateTimeZone} | |
| package object myApp { | |
| DateTimeZone.setDefault(DateTimeZone.UTC) | |
| implicit object BSONDateTimeHandler extends BSONHandler[BSONDateTime, DateTime] { | |
| val fmt = ISODateTimeFormat.dateTime() | |
| def read(time: BSONDateTime) = new DateTime(time.value) |
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 BlPathMatchers { | |
| val BSONObjectID: PathMatcher1[BSONObjectID] = | |
| PathMatcher("""[\da-fA-F]""".r) flatMap { string ⇒ | |
| try Some(new BSONObjectID(string)) | |
| catch { case _: IllegalArgumentException ⇒ None } | |
| } | |
| } |
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 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); |
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
| 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 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
| BallHttpClient<Ball> httpClient = new GenericHttpClient<Ball>(SCHEME, HOST, PORT); |
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
| 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 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.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 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 | |
| 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 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
| 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 |
NewerOlder