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
.greenid-so-content #greenid-container .btn-primary { | |
background-color: #0000FF; | |
color: white; | |
text-transform: lowercase; | |
padding: 15px; | |
width: 100%; | |
font-size: 17px; | |
border: none; | |
-webkit-border-radius: 0; | |
-moz-border-radius: 0; |
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
(def.factory app.Product [$resource] | |
($resource "/products/:id" (obj :id "@id"))) | |
(def.controller app.ProductController [$scope Product] | |
(! $scope.products (. Product query)) | |
(! $scope.updateProduct (fn [product] | |
(. product $save))) | |
(! $scope.deleteProduct (fn [product] | |
(. product $remove | |
(fn [] |
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
(defroutes product-routes | |
(context "/products" [] | |
(GET "/" [] {:body (get-products)}) | |
(GET "/index.html" [] (layout/render "product.html")) | |
(POST "/" {product :body-params} {:body (create-product product)}) | |
(context "/:id" [id] | |
(GET "/" [] {:body (retrieve-product id)}) | |
(POST "/" {product :body-params} {:body (update-product id product)}) | |
(DELETE "/" [] (delete-product id))))) |
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
(defentity products) | |
(defn get-products [] | |
(select products)) | |
(defn create-product [product] | |
(insert products (values product))) | |
(defn retrieve-product [id] | |
(select products |
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
object AuditLogger { | |
implicit def actionToSimpleFuture[T](action: Action[T])(implicit request: Request[T]): Future[SimpleResult] = { | |
action.apply(request) | |
} | |
def audit[M](audit: Audit)(f: => Future[M])(implicit ctx: ExecutionContext): Future[M] = { | |
val future = f // do the call by name only once, otherwise another future is created | |
future.onComplete { | |
case Success(_) => insert(audit) | |
case Failure(_) => // don't care if future has failed, just let is bubble up |
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
(def.module app [ngResource]) | |
(def.service app.productFactory [$resource] | |
($resource "/products")) | |
(def.controller app.productController [$scope productFactory] | |
(! $scope.products (. productFactory query))) |
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
event.getCause match { | |
// IO exceptions happen all the time, it usually just means that the client has closed the connection before fully | |
// sending/receiving the response. | |
case e: IOException => nettyExceptionLogger.trace("Benign IO exception caught in Netty", e) | |
event.getChannel.close() | |
case e: TooLongFrameException => nettyExceptionLogger.warn("Handling TooLongFrameException", e) | |
val response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.REQUEST_URI_TOO_LONG) | |
response.setHeader("connection", "close") | |
val dme = new DownstreamMessageEvent(ctx.getChannel, Channels.future(ctx.getChannel), response, ctx.getChannel.getRemoteAddress) | |
ctx.sendDownstream(dme); |
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
case class TestRequestHeader(headers: Headers, method: String = "GET", uri: String = "/", path: String = "", remoteAddress: String = "127.0.0.1", version: String = "HTTP/1.1", id: Long = 666, tags: Map[String, String] = Map.empty[String, String], queryString: Map[String, Seq[String]] = Map(), secure: Boolean = false) extends RequestHeader | |
val rh = TestRequestHeader(headers = new Headers { | |
val data = Seq(play.api.http.HeaderNames.CONTENT_TYPE -> Seq("""multipart/form-data; boundary=----68766594719920667221395339924"""), play.api.http.HeaderNames.CONTENT_LENGTH -> Seq("380")) | |
}) | |
val multipartFormData = BodyParsers.parse.multipartFormData | |
val testStr = """Content-Type: multipart/form-data; boundary=---------------------------68766594719920667221395339924 | |
Content-Length: 380 |
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
def uploadFile(docId: String) = { | |
import scalax.io._ | |
val output = Resource.fromFile("target/test-upload.txt") | |
output.write("hello world")(Codec.UTF8) | |
val testFile = new File("target/test-upload.txt") | |
val file = TemporaryFile(testFile) | |
val data = new MultipartFormData(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
val batchSize = 100 // for some reason we need to throttle down the import, putting everything in sometimes causes a future already completed | |
Async { | |
fetch("/instrument").map { instruments => | |
Logger.debug(s"importing ${instruments.size} instruments") | |
instruments.grouped(batchSize).foreach { batch => | |
res.batchInsert(Enumerator.enumerate(batch)) | |
} | |
NewerOlder