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.io.FileNotFoundException | |
import java.util.zip.GZIPInputStream | |
import scala.io.Codec | |
object ClasspathReader { | |
def getResourceAsStream(filename: String) = { | |
// why doesn't the more scala-like getClass.getResourceAsStream work? | |
val inputStream = Thread.currentThread().getContextClassLoader().getResourceAsStream(filename) | |
if (inputStream == null) throw new FileNotFoundException(s"Couldn't find $filename on the classpath") |
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.io.Closable | |
import scala.util.control.NonFatal | |
import scala.util.{ Success, Try } | |
// This should really be scala-standard-lib. | |
object TryWithResources { | |
def withClose[T <: Closeable, V](closable: T)(f: T => V): V = { | |
(Try(f(closable)), Try(closable.close())) match { | |
case (Success(v), Success(_)) => v | |
case (a, b) => throw preferFirstException(a, b).get |
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 io.lettuce.core.RedisURI | |
import io.lettuce.core.cluster.{ ClusterClientOptions, ClusterTopologyRefreshOptions, RedisClusterClient } | |
import scala.util.Random | |
object MGet { | |
def main(args: Array[String]): Unit = { | |
val host = args(0) | |
val port = args(1).toInt |
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.util.Map.Entry | |
import com.typesafe.config.{ Config, ConfigRenderOptions, ConfigValue, ConfigValueFactory } | |
import org.mindrot.jbcrypt.BCrypt | |
import scala.io.{ Codec, Source } | |
import scala.collection.JavaConverters._ | |
import scala.util.Try | |
import scala.util.matching.Regex |
OlderNewer