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 core.dao | |
import scala.concurrent.Future | |
import play.api.Logger | |
import reactivemongo.core.commands.LastError | |
import reactivemongo.core.errors.DatabaseException | |
import core.db.MongoHelper |
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.util.concurrent.atomic._ | |
import collection.mutable.ArrayBuffer | |
/** | |
* Buffer type with purely functional API, using mutable | |
* `ArrayBuffer` and cheap copy-on-write scheme. | |
* Idea described by Bryan O'Sullivan in http://www.serpentine.com/blog/2014/05/31/attoparsec/ | |
*/ | |
class Buffer[A](id: AtomicLong, stamp: Long, values: ArrayBuffer[A], size: Int) { | |
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
from fabric.api import * | |
from fabric.colors import green as _green, yellow as _yellow | |
import boto | |
import boto.ec2 | |
from config import * | |
import time | |
def create_server(): | |
""" | |
Creates EC2 Instance |
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
Versioning is an anti-pattern | |
============================= | |
We often say "use the right tool for the job", but when managing change | |
in software systems, we always use versioning. Hypermedia APIs are | |
actually hindered by introducing versioning and manage change in a | |
different way. With that in mind, there are also a lot of options for | |
managing change in a Hypermedia API. We'd like to change our service and | |
break as few clients as possible. Versioning is only one way to manage | |
change, though... and my contention is that it's not appropriate for |
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
// An ADT+shapeless as a drop-in replacement for a standard Scala Enumeration. | |
// | |
// First the unsafe standard Scala Enumeration ... | |
// | |
object ScalaEnumDemo extends App { | |
// Example from scala.Enumeration scaladoc. Terse ... | |
object WeekDay extends Enumeration { | |
type WeekDay = Value | |
val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value | |
} |
This gist has been upgraded to a blog post here.
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 CassandraWrapper { | |
import scala.language.implicitConversions | |
import scala.language.postfixOps | |
/** | |
* Converts a `ResultSetFuture` into a Scala `Future[ResultSet]` | |
* @param f ResultSetFuture to convert | |
* @return Converted Future | |
*/ | |
implicit def resultSetFutureToScala(f: ResultSetFuture): Future[ResultSet] = { | |
val p = Promise[ResultSet]() |
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
case class ErrorMessage(message: String, cause: String) | |
object ErrorMessage { | |
import spray.json.DefaultJsonProtocol._ | |
implicit val errorFormat = jsonFormat2(ErrorMessage.apply) | |
} | |
import spray.httpx.SprayJsonSupport._ | |
implicit val jsonRejectionHandler = RejectionHandler { | |
case MalformedRequestContentRejection(msg, cause) :: Nil => | |
complete(StatusCodes.BadRequest, ErrorMessage("The request content was malformed", msg)) |
OlderNewer