Skip to content

Instantly share code, notes, and snippets.

View Sergey80's full-sized avatar

Sergey Starodubtsev Sergey80

View GitHub Profile
@oliverdaff
oliverdaff / GutenbergCrunch
Created October 31, 2011 22:50
Parse Gutenberg using scala pull parser
import java.io.{FileInputStream, BufferedInputStream}
import scala.io.Source
import scala.xml.pull.{XMLEventReader, EvElemStart, EvElemEnd, EvText}
object GutenbergCrunch
{
private def parseBook( parser : XMLEventReader ) : (String, String, String) =
@Sergey80
Sergey80 / AsyncController.diff
Last active February 16, 2019 05:51 — forked from jriecken/AsyncController.diff
Contextual Logging
import play.api.Logger
import org.slf4j.MDC
+import scala.concurrent.{ExecutionContext, Future}
import java.util.UUID
+import java.util.concurrent.Executors
-object SyncController extends Controller {
- def syncEndpoint(profileId: Long) = Action(parse.json) { req =>
+object AsyncController extends Controller {
+ implicit val ec = ExecutionContext.fromExecutor(Executors.newFixedThreadPool(2))
+ // For this example, ensure the threads in the pool are already created