View jsonschema.scala
import com.github.fge.jsonschema.core.report.ProcessingMessage | |
import scala.collection.JavaConversions._ | |
import com.fasterxml.jackson.databind.JsonNode | |
import com.github.fge.jsonschema.main.JsonSchemaFactory | |
import org.json4s._ | |
import org.json4s.jackson.JsonMethods._ |
View Scala.Dockerfile
# This uses the Docker builder pattern. | |
# The first container runs SBT to stage our application. | |
# todo - use a Docker image that has already downloaded SBT | |
FROM hseeberger/scala-sbt AS builder | |
WORKDIR /app | |
COPY src src | |
COPY project project | |
COPY build.sbt build.sbt | |
RUN sbt stage |
View tail-kinesis.sh
if [ -z "$1" ] | |
then | |
echo "Usage: ./kinesis-messages.sh <stream-name>" | |
exit 1 | |
fi | |
streamname=$1; aws kinesis describe-stream --stream-name $streamname --output text | grep SHARDS | awk '{print $2}' | while read shard; do aws kinesis get-shard-iterator --stream-name $streamname --shard-id $shard --shard-iterator-type LATEST --output text | while read iterator; do while output=`aws kinesis get-records --shard-iterator $iterator --output text`; do iterator=`echo "$output" | head -n1 | awk '{print $2}'`; echo "$output" | awk 'NR > 1' | grep RECORDS | while read record; do echo $record | awk '{print $3}' | base64 -D | jq .; done; done; done; done | |
View cilic_v_berankis.txt
Berankis 15:0 15:15 15:30 15:40, BP 6-3 4-6 7-6 4-6 7-5 | |
Cilic 0:15 15:15 15:30 15:40 30:40 40:40 A:40 6-3 4-6 7-6 4-6 6-5 | |
Berankis 15:0 30:0 40:0 40:15 6-3 4-6 7-6 4-6 5-5 | |
Cilic 15:0 30:0 40:0 6-3 4-6 7-6 4-6 5-4 | |
Berankis 15:0 30:0 40:0 6-3 4-6 7-6 4-6 4-4 | |
Cilic 15:0 15:15 30:15 40:15 40:30 6-3 4-6 7-6 4-6 4-3 | |
Berankis 0:15 15:15 30:15 40:15 6-3 4-6 7-6 4-6 3-3 | |
Cilic 0:15 15:15 15:30 15:40 30:40 40:40 A:40 40:40 A:40 6-3 4-6 7-6 4-6 3-2 | |
Berankis 15:0 15:15 30:15 40:15 6-3 4-6 7-6 4-6 2-2 | |
Cilic 15:0 30:0 40:0 6-3 4-6 7-6 4-6 2-1 |
View RomanNumerals.scala
class RomanNumerals { | |
def toInt(romanNumerals: String): Int = { | |
@annotation.tailrec | |
def recur(l: List[Int], total: Int): Int = { | |
l match { | |
case h :: Nil => total + h | |
case h :: tail if h < tail.head => recur(tail, total - h) | |
case h :: tail => recur(tail, total + h) | |
case Nil => total // romans didn't have zero though | |
} |
View NinetyNineProblems.scala
/** | |
* Problems from | |
* http://aperiodic.net/phil/scala/s-99/ | |
*/ | |
object NinetyNine extends App { | |
// P02 | |
def penultimate[A](l: List[A]): A = l match { | |
case h :: _ :: Nil => h | |
case h :: tail => penultimate(tail) |
View Fibonacci Functions
package io.github.cjwebb | |
import scala.annotation.tailrec | |
object Fibonacci extends App { | |
/** Get the nth fibonacci number */ | |
def fib_iter(n: Int) = { | |
if (n < 2) n | |
else { |
View Akka Camel and ActiveMQ
import akka.actor._ | |
import akka.camel.{CamelExtension, CamelMessage, Consumer, Producer, Oneway} | |
import org.apache.activemq.camel.component.ActiveMQComponent | |
import org.apache.activemq.ScheduledMessage | |
case class Message(body: String) | |
class SimpleConsumer() extends Actor with Consumer { | |
def endpointUri: String = "activemq:foo.bar" |
View graph.elm
import Color exposing (..) | |
import Graphics.Collage exposing (..) | |
import Graphics.Element exposing (..) | |
main : Element | |
main = | |
collage 300 300 | |
[ blueLine | |
, xAxis | |
, yAxis |
View pymeals_create_ttl_index.txt
db.user_invites.ensureIndex( { "expiry_time": 1 }, { expireAfterSeconds: 1 } ) |
NewerOlder