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
| class testCase() { | |
| val smallFile = Array[Byte](-1,-40,-1,-32,0,16,74,70,73,70,0,1,1,1,0,109,0,109,0,0,-1,-37,0,67,0,8,6,6,7,6,5,8,7,7,7,9,9,8,10,12,20,13,12,11,11,12,25,18,19,15,20,29,26,31,30,29,26,28,28,32,36,46,39,32,34,44,35,28,28,40,55,41,44,48,49,52,52,52,31,39,57,61,56,50,60,46,51,52,50,-1,-37,0,67,1,9,9,9,12,11,12,24,13,13,24,50,33,28,33,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,50,-1,-64,0,17,8,1,0,1,0,3,1,34,0,2,17,1,3,17,1,-1,-60,0,31,0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0,0,1,2,3,4,5,6,7,8,9,10,11,-1,-60,0,-75,16,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125,1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,-127,-111,-95,8,35,66,-79,-63,21,82,-47,-16,36,51,98,114,-126,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,-125,-124,-123,-122,-121,-120,-119,-118,-110,-109,-108,-107,-106,-105,-1 |
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
| - Options("/generate/imageId/OneToOne/800").withHeaders(List(HttpHeaders.Origin(Seq(HttpOrigin("http", Host("allowedhost.com")))))) ~> myroute ~> check { | |
| + Options("/generate/imageId/OneToOne/800") ~> addHeader("Origin", "http://allowedhost.com") ~> myroute ~> check { | |
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
| - Options("/generate/imageId/OneToOne/800").withHeaders(List(HttpHeaders.Origin(Seq(HttpOrigin("http", Host("allowedhost.com")))))) ~> myroute ~> check { | |
| + Options("/generate/imageId/OneToOne/800") ~> addHeader("Origin", "http://allowedhost.com") ~> myroute ~> check { | |
| Above is scalatest spray example of adding headers to request |
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
| #!/bin/sh | |
| if [ $# -eq 0 ]; then | |
| echo "Usage: ./monitor.sh /my/log/file.log" | |
| fi | |
| if [ $# -eq 1 ]; then | |
| LOGFILE=$1 | |
| fi |
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
| #!/bin/sh | |
| if [ $# -eq 0 ]; then | |
| echo "Usage: ./monitor.sh /my/log/file.log [sleep time (s)]" | |
| echo "Will output a dot for each second monitored that there are no changes" | |
| echo "Will stop script once no changes are detected to log file" | |
| fi | |
| if [ $# -eq 1 ]; then | |
| LOGFILE=$1 |
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
| package com.github.edgecaseberg.test { | |
| import scala.reflect.runtime.universe | |
| import scala.reflect.runtime.universe.typeOf | |
| import scala.util.Random | |
| import org.scalatest._ | |
| trait ParsingTest extends FlatSpec with Matchers { | |
| val random = new Random() | |
| def randomCase(s: String): String = { |
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
| 1. look up process id, | |
| 2. cd to /proc/{id}/fd | |
| 3. tail -f 1 |
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
| //https://groups.google.com/forum/#!topic/simple-build-tool/rcPh-lWbDtk | |
| lazy val versionReport = TaskKey[String]("version-report") | |
| // Add this setting to your project. | |
| versionReport <<= (externalDependencyClasspath in Compile, streams) map { | |
| (cp: Seq[Attributed[File]], streams) => | |
| val report = cp.map { | |
| attributed => | |
| attributed.get(Keys.moduleID.key) match { | |
| case Some(moduleId) => "%40s %20s %10s %10s".format( |
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
| import play.Logger | |
| scala> implicit class LogHelper(val sc: StringContext) extends AnyVal { | |
| | def log(args: Any*): Unit = { | |
| | Logger.info(sc.s(args:_*)) | |
| | println(sc.s(args:_*)) | |
| | }} | |
| defined class LogHelper | |
| scala> log"Hello $hi" |
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
| import com.typesafe.scalalogging.slf4j.Logging | |
| import sun.misc.BASE64Decoder | |
| import play.api.mvc._ | |
| import scala.concurrent.Future | |
| import play.mvc.Results._ | |
| import play.api.libs.concurrent.Execution.Implicits.defaultContext | |
| object BasicAuthFilter extends Filter with Logging { | |
| private lazy val unauthResult = Results.Unauthorized.withHeaders(("WWW-Authenticate", | |
| "Basic realm=\"myRealm\"")) |