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.nio.ByteBuffer | |
import java.time.Instant | |
import java.time.temporal.ChronoUnit | |
import java.util.UUID | |
import akka.Done | |
import akka.actor.ActorSystem | |
import akka.serialization.SerializationExtension | |
import akka.serialization.SerializerWithStringManifest | |
import com.datastax.driver.core.BatchStatement |
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.language.implicitConversions | |
object OrderEnum extends Enumeration { | |
protected case class Val(actualValue: String, orderValue: String) extends super.Val | |
implicit def valueToVal(x: Value): Val = x.asInstanceOf[Val] | |
val A = Val("a", "c") | |
val B = Val("b", "b") | |
val C = Val("c", "a") | |
} |
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
//Test tag | |
case object DockerDatabaseTest extends Tag("DockerDatabase") | |
//Test harness | |
package utilities.database | |
import com.dimafeng.testcontainers.{ForAllTestContainer, PostgreSQLContainer} | |
import org.scalatest.mockito.MockitoSugar | |
import org.scalatest.{Assertion, Suite} | |
import org.scalatestplus.play.AppProvider |
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
package utilities.rabbitmq; | |
import com.rabbitmq.client.*; | |
import com.rabbitmq.utility.BlockingCell; | |
import net.jodah.lyra.config.Config; | |
import net.jodah.lyra.event.DefaultChannelListener; | |
import java.io.EOFException; | |
import java.io.IOException; | |
import java.util.Map; |
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.collection.mutable | |
class LRUCache(maxSize: Int) { | |
val map = mutable.LinkedHashMap[Int, String]() | |
def put(key: Int, value: String) = { | |
moveToBottom(key, value) | |
if (map.size > maxSize) { | |
val (firstKey, _) = map.head |
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 entryPoint = 0 | |
val points = List(-2, -1, 0, 1, 2, 3, 4) | |
val closest = points | |
.reduceLeftOption { | |
(point1, point2) => | |
val distance1 = Math.sqrt(Math.pow(entryPoint - point1, 2)) | |
val distance2 = Math.sqrt(Math.pow(entryPoint - point2, 2)) | |
if (distance1 < distance2) { |
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
person.choice === 'participate' ? it.bePartOf() : it.watchHappen(); |
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
/** | |
* @author Elon Musk | |
*/ | |
switch(person.choice) { | |
case 'PARTICIPATE': | |
it.bePartOf(); | |
default: | |
it.watchHappen(); | |
} |