Skip to content

Instantly share code, notes, and snippets.

View wsargent's full-sized avatar

Will Sargent wsargent

View GitHub Profile
fooapp@srv:~$ cat app/env/PLAY_OPTS
export DATABASE_URL="jdbc:postgresql://127.0.0.1/foobar"
# We could wire a different configuration file here
# or set up a different database on the fly
export PLAY_OPTS="-DapplyEvolutions.default=true -DapplyDownEvolutions.default=true -Ddb.default.url="$DATABASE_URL" -Ddb.default.user=fooapp -Ddb.default.password=fooapppw -Ddb.default.driver=org.postgresql.Driver"
package backend
import akka.actor.{Actor, ActorRef, Cancellable}
import scala.concurrent.duration.FiniteDuration
import scala.util.control.NoStackTrace
private case class SchedulerException(msg: String) extends akka.AkkaException(msg) with NoStackTrace
/**
@wsargent
wsargent / URL
Created November 10, 2014 10:56
https://docs.google.com/a/typesafe.com/presentation/d/1QBhMeRRq5Gs5UfgaqvZ_3-LaxC-fQviLbPi5O8fA71c/edit?usp=sharing
#!/usr/bin/env bash
#
# A more capable sbt runner, coincidentally also called sbt.
# Author: Paul Phillips <paulp@typesafe.com>
# todo - make this dynamic
declare -r sbt_release_version=0.13.5
declare -r sbt_unreleased_version=0.13.5
declare -r buildProps=project/build.properties
> testOnly play.it.http.websocket.AkkaHttpWebSocketSpec
[info] AkkaHttpWebSocketSpec
[info]
[info] Plays WebSockets should
[info] allow handling WebSockets using Akka streams
[info] + allow consuming messages
[info] + allow sending messages
[info] + close when the consumer is done
[info] + allow rejecting a websocket with a result
@wsargent
wsargent / Hello.scala
Last active December 17, 2015 21:50
Prograde example
package com.example
object Hello {
def main(args: Array[String]): Unit = {
val runtime = Runtime.getRuntime
val cwd = System.getProperty("user.dir")
val process = runtime.exec(s"$cwd/testscript.sh") // pick something harmless
println("Process executed without security manager interference!")
}
}
// GeneratePolicyFromDeniedPermissions - timestamp: Thu Dec 17 13:24:58 PST 2015
grant codeBase "file:/home/wsargent/work/activator-play-tls-example/target/universal/activator-play-tls-example-1.0.0/lib/activator-play-tls-example.activator-play-tls-example-1.0.0-sans-externalized.jar" {
permission java.io.FilePermission "certs/clientca.jks", "read";
permission java.io.FilePermission "certs/example.com.jks", "read";
permission java.io.FilePermission "certs/password", "read";
permission java.util.PropertyPermission "play.ssl.needClientAuth", "read";
};
grant codeBase "file:/home/wsargent/work/activator-play-tls-example/target/universal/activator-play-tls-example-1.0.0/lib/ch.qos.logback.logback-classic-1.1.3.jar" {
import play.api.libs.ws.ahc.AhcWSClient
import akka.stream.ActorMaterializer
import akka.actor.ActorSystem
implicit val system = ActorSystem()
implicit val materializer = ActorMaterializer()
val ws = AhcWSClient()
val req = ws.url("http://example.com").get().map{
resp => resp.body
// a Train "at" time produces a TrainFromOps
// a TrainFromOps "from" station produces a Train
// a TrainInfo "at" time produces a TrainInfoFromOps
// a TrainInfoFromOps "from" station produces a TrainInfoAtOps
// a TrainInfoAtOps "at" time produces a TrainFromOps
// TrainOps(train)
// TrainInfoOps(info: TrainInfo)
// TrainFromOps(info, scheudle, time)
@wsargent
wsargent / Scala-Play-App-Docker-Deploy.md
Created July 15, 2016 00:21 — forked from IncludeSecurity/Scala-Play-App-Docker-Deploy.md
Deploying Scala Play Framework Applications on AWS Beanstalk using Docker containers