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
/* | |
Code for illustrative purposes only, to demonstrate a particular behavior. | |
I already know that it doesn't run (throws ClassFormatError), and I wouldn't | |
write it this way to begin with :) | |
*/ | |
package eg | |
class Base() { | |
def foo = "bar" |
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 akka.actor.ActorSystem | |
import akka.testkit.{DefaultTimeout, ImplicitSender, TestKit} | |
import com.typesafe.config.ConfigFactory | |
import org.scalatest.BeforeAndAfterAll | |
import org.scalatest.FunSuiteLike | |
class AgentServerSuite extends TestKit(ActorSystem("AgentServerSuite")) | |
with FunSuiteLike | |
with DefaultTimeout | |
with ImplicitSender |
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
/* | |
Separate integration and unit tests (put in project/ITConfic.scala) | |
See: http://www.scala-sbt.org/release/docs/Testing.html#Integration+Tests | |
*/ | |
object ITConfig extends Build { | |
lazy val root = | |
Project("service-agent", file(".")) | |
.configs(IntegrationTest) | |
.settings(Defaults.itSettings: _*) |
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
/* | |
spray.io custom SSLContext to bypass security checks (when testing, etc.); see http://spray.io/documentation/1.2.2/spray-can/http-server/#ssl-support | |
Bringing it into scope removes errors | |
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target | |
*/ | |
implicit val trustfulSslContext: SSLContext = { | |
object NoCheckX509TrustManager extends X509TrustManager { | |
override def checkClientTrusted(chain: Array[X509Certificate], authType: String) = () | |
override def checkServerTrusted(chain: Array[X509Certificate], authType: String) = () |
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 scala.concurrent.duration._ | |
object Measurements { | |
/* | |
Partially-aplied function to measure elapsed times. | |
Usage: | |
val myTimer = buildTimer // start the timer | |
// code under measurement | |
val elapsedTime1 = myTimer() // record elapsed time 1, leave the timer running |
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
val timeout1 = Promise[Any]() | |
system.scheduler.scheduleOnce(callTimeout(cnt))(timeout1.success('timeout)) |
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
val path = FileSystems.getDefault.getPath(dirName) | |
if (Files.exists(path) && Files.isDirectory(path)) { | |
Files.walkFileTree(path, new FileVisitor[Path] { | |
def visitFileFailed(file: Path, exc: IOException) = FileVisitResult.CONTINUE | |
def visitFile(file: Path, attrs: BasicFileAttributes) = { | |
Files.delete(file) | |
FileVisitResult.CONTINUE | |
} |
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
cmdbTopology = context.actorOf(Props(new CmdbTopology { | |
override val supervisorStrategy = OneForOneStrategy() { | |
case nai: NotApplicableToItem => Resume // ensure recipe exception do not stop the actor | |
} | |
}).withDispatcher("topology-dispatcher"), "cmdb-topology") |
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
complete git p/1/"(add bisect branch checkout clone commit diff fetch grep init log merge mv pull push rebase reset rm show status tag)"/ | |
complete nova p/1/"(absolute-limits actions add-fixed-ip add-floating-ip aggregate-add-host aggregate-create aggregate-delete aggregate-details aggregate-list aggregate-remove-host aggregate-set-metadata aggregate-update boot credentials delete describe-resource diagnostics dns-create dns-create-private-domain dns-create-public-domain dns-delete dns-delete-domain dns-domains dns-list endpoints flavor-create flavor-delete flavor-list floating-ip-create floating-ip-delete floating-ip-list floating-ip-pool-list get-vnc-console image-create image-delete image-list image-meta image-show keypair-add keypair-delete keypair-list list live-migration meta migrate pause rate-limits reboot rebuild remove-fixed-ip remove-floating-ip rename rescue resize resize-confirm resize-revert resume root-password secgroup-add-group-rule secgroup-add-rule secgroup-create secgroup-delete sec |