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 java.util | |
import java.util.{Map => JMap, List => JList} | |
import scala.reflect.runtime.universe._ | |
object PatternMatching extends App { | |
val o: JMap[String, Any] = new util.HashMap[String, Any]() | |
val o2: JList[JMap[String, Any]] = new util.ArrayList[JMap[String, Any]]() |
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
app.post('/verify', function(req, res) { | |
var digest = crypto.createHmac('sha1', '--- priv key----').update("---pub key---").digest(encoding="base64"); | |
if (req.body.sig_verify == digest) { | |
res.redirect('/demo/success.html') | |
} | |
else { | |
res.redirect("/demo/failure.html") | |
} | |
}); |
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
def find[A](s:Seq[A], e:A => Boolean):Option[A] = { | |
s match { | |
case Seq(h,t) if e(h) => Some(h) | |
case Nil => None | |
case _ => find(s.tail, e) | |
} | |
} |
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
class VoltDbClientProvider @Inject()(settings: AppSettings) extends Provider[Client] { | |
val cf = settings.getSection("voltdb") | |
val nodes = cf.getConfigList("nodes").toList | |
var client: Option[Client] = None | |
private val executor = Executors.newCachedThreadPool(new ThreadFactory() { | |
def newThread(runnable: Runnable): Thread = { | |
val thread = new Thread(runnable, "Retry Connection") | |
thread.setDaemon(true) |
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
20:06:26.509 [qtp1697386933-197] ERROR c.c.c.r.a.resources.ResultsResource - Parsing the request body failed, because: | |
org.eclipse.jetty.io.EofException: null | |
at org.eclipse.jetty.server.HttpInput$3.noContent(HttpInput.java:473) ~[jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609] | |
at org.eclipse.jetty.server.HttpInput.read(HttpInput.java:124) ~[jetty-server-9.2.1.v20140609.jar:9.2.1.v20140609] | |
at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:284) ~[na:1.8.0_05] | |
at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:326) ~[na:1.8.0_05] | |
at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:178) ~[na:1.8.0_05] | |
at java.io.InputStreamReader.read(InputStreamReader.java:184) ~[na:1.8.0_05] | |
at java.io.BufferedReader.read1(BufferedReader.java:210) ~[na:1.8.0_05] | |
at java.io.BufferedReader.read(BufferedReader.java:286) ~[na:1.8.0_05] |
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
abstract class BaseResource | |
extends ScalatraServlet with FutureSupport with JacksonJsonSupport with SwaggerSupport with Imports { | |
override protected val applicationName = Some("messaging-api") | |
protected def applicationDescription = "Messaging Services API" | |
protected implicit val defaultTimeout = Timeout(5 seconds) | |
override val jsonpCallbackParameterNames: Iterable[String] = Some("callback") |
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
CREATE TABLE results ( | |
event_id BIGINT NOT NULL, | |
race_id BIGINT NOT NULL, | |
bracket_id BIGINT NOT NULL, | |
interval_id BIGINT NOT NULL, | |
entry_id BIGINT NOT NULL, | |
iv_time_millis BIGINT NOT NULL, | |
iv_gun_time_millis BIGINT NOT NULL, | |
bib VARCHAR(15), | |
pace VARCHAR(23), |
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
object Runner { | |
// this is my entry object as specified in sbt project definition | |
def main(args: Array[String]) { | |
val port = if (System.getenv("PORT") != null) System.getenv("PORT").toInt else 8080 | |
val server = new Server(port) | |
val context = new WebAppContext() | |
context setContextPath "/" | |
context.setResourceBase("src/main/webapp") |
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
new AsyncResult { | |
val is = Future { | |
try { | |
val results = searchService.findEntry(eventId.toLong, term, limit) | |
Ok("DUDE") | |
} | |
catch { | |
case e:Throwable => e.printStackTrace(); Ok(e.getMessage) | |
} | |
} |
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
/* | |
* /routes/user.js | |
*/ | |
/* | |
* /users -> list | |
* /user/:id -> get | |
* /users/:id -> get | |
* | |
*/ |