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
object SbtAmazonEcr extends App { | |
while(true) { | |
println("Hello Docker.") | |
Thread.sleep(3000) | |
} | |
} |
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
public final class BusyApp { | |
public static void main(String []args) throws Exception { | |
final java.util.Random generator = new java.util.Random(); | |
while (true) { | |
generator.ints(1000000, 0, 100).sorted(); | |
Thread.sleep(5000L); | |
} | |
} | |
} |
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 scala.io.Source | |
case class Observation(time: Int, value: BigDecimal) | |
class Memory(val length: Int, val observation: Option[Observation], val pastEvents: List[Observation]) { | |
def record(newObservation: Observation): Memory = { | |
val newEvents = (newObservation :: pastEvents).takeWhile(_.time > newObservation.time - length) | |
new Memory(length, Some(newObservation), newEvents) | |
} |
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 java.time._ | |
import org.apache.curator.framework._ | |
import org.apache.curator.retry._ | |
import org.apache.zookeeper.CreateMode._ | |
object ZooKeeperReader extends App { | |
val connectionString = "192.168.59.201:2181,192.168.59.202:2181,192.168.59.203:2181,192.168.59.204:2181,192.168.59.205:2181" | |
val retryPolicy = new RetryOneTime(1000) | |
val client = CuratorFrameworkFactory.newClient(connectionString, retryPolicy) | |
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 org.junit.runner.RunWith | |
import org.scalatest.selenium.HtmlUnit | |
import org.scalatest.{FlatSpec, ShouldMatchers} | |
import org.springframework.boot.test.{SpringApplicationConfiguration, WebIntegrationTest} | |
import org.springframework.test.context.TestContextManager | |
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner | |
@RunWith(classOf[SpringJUnit4ClassRunner]) | |
@SpringApplicationConfiguration(classes = Array(classOf[Application])) | |
@WebIntegrationTest(value = Array("server.port=9000")) |
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 java.math.BigInteger; | |
import java.text.MessageFormat; | |
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.Collection; | |
import java.util.Collections; | |
import java.util.List; | |
import java.util.Scanner; | |
import java.util.function.BiFunction; | |
import java.util.stream.Collectors; |
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 collection.JavaConversions._ | |
import org.springframework.beans.factory.annotation._ | |
import org.springframework.context.ApplicationContext | |
import org.springframework.context.annotation._ | |
import org.springframework.stereotype._ | |
package com.example.core { | |
@ComponentScan(basePackages = Array("com.example.core")) | |
@Configuration |
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 javax.servlet.ServletContext | |
import org.eclipse.jetty.server.Server | |
import org.eclipse.jetty.webapp.WebAppContext | |
import org.json4s.{DefaultFormats, Formats} | |
import org.scalatra._ | |
import org.scalatra.json._ | |
import org.scalatra.servlet.ScalatraListener | |
case class User(id: Int, name: 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
object Log4j2WithMongoAppenderDemo extends App { | |
val logger = org.slf4j.LoggerFactory.getLogger(Log4j2WithMongoAppenderDemo.getClass) | |
logger.trace("A trace message") | |
logger.debug("A debug message") | |
logger.info("An info message") | |
logger.warn("A warning message") | |
logger.error("An error message") | |
logger.error("An error message with an exception", new Exception("Some serious problem")) |
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 rapture._ | |
import core._, io._, net._, uri._, json._, codec._ | |
import encodings.`UTF-8` | |
import jsonBackends.jackson._ | |
case class PostContainer(kind: String, data: Post) | |
case class Post(id: String, subreddit: String, score: Int, title: String, author: String, permalink: String) { | |
lazy val topComment = { | |
val json = Json.parse(uri"http://www.reddit.com/r/${subreddit}/comments/${id}.json?sort=top&limit=1&depth=1".slurp[Char]) |