Instantly share code, notes, and snippets.

View eitherT.scala
import scalaz._
import Scalaz._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration.Duration
import scala.concurrent.{Await, Future}
object Main extends App {
val getEitherTFutures1: Seq[EitherT[Future, Throwable, String]] = {
Seq(
View test.scala
trait Foo {
def execute(): Unit
}
object Foo extends Foo {
def execute(): Unit = println("foo")
}
trait Bar {
val foo: Foo = Foo
View WrappedNumericLike.scala
trait WrappedNumericLike[A] {
def value: A
}
abstract class WrappedNumeric[A, N <: WrappedNumericLike[A]](value: A)(implicit num: Integral[A])
extends WrappedNumericLike[A] {
val companion: A => N
def +(x: N): N = companion(num.plus(value, x.value))
def -(x: N): N = companion(num.minus(value, x.value))
def /(x: N): N = companion(num.quot(value, x.value))
View Dockerfile
FROM ruby:2.4.1-alpine
RUN apk --no-cache --update add \
libstdc++ \
build-base \
openssl-dev \
sqlite \
sqlite-dev \
ruby-dev && \
gem install mailcatcher && \
View Dockerfile
FROM ruby:2.4.2
MAINTAINER Dai Akatsuka <d.akatsuka@gmail.com>
ENV DOCKER 1
ENV NVM_DIR /usr/local/nvm
ENV NODE_VERSION 8.9.0
ENV NODE_PATH $NVM_DIR/v$NODE_VERSION/lib/node_modules
ENV PATH $NVM_DIR/versions/node/v$NODE_VERSION/bin:$PATH
ENV ENTRYKIT_VERSION 0.4.0
ENV APP_ROOT /app
View ListKeys.scala
import scala.collection.JavaConverters._
val request = new ListObjectsV2Request()
request.setBucketName(bucket)
request.setPrefix(prefix)
@tailrec
def fetch(req: ListObjectsV2Request, xs: Iterable[String]): Iterable[String] = {
val result = s3Client.listObjectsV2(req)
val keys = xs ++ result.getObjectSummaries.asScala.map(_.getKey)
View entrypoint.sh
#!/usr/bin/env bash
migrate() {
echo -n "waiting for TCP connection to $DATABASE_HOST:$DATABASE_PORT..."
while ! nc -z $DATABASE_HOST $DATABASE_PORT
do
echo -n .
sleep 3
done
View Handler.scala
import akka.http.scaladsl.server.{ Directive, Directive0, Directive1, Route }
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.directives.OnSuccessMagnet
import akka.http.scaladsl.server.util.Tupler
import akka.http.scaladsl.util.FastFuture._
import de.heikoseeberger.akkahttpcirce.CirceSupport
import io.circe.export.Exported
import io.circe.generic.decoding.DerivedDecoder
import io.circe.generic.encoding.DerivedObjectEncoder
import io.circe.{ Decoder, ObjectEncoder }
View ecs-instance-with-dd-agent.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ecs:RegisterContainerInstance",
"ecs:DeregisterContainerInstance",
"ecs:DiscoverPollEndpoint",
"ecs:StartTelemetrySession",
View filter_replace_key.rb
module Fluent
class ReplaceKeyFilter < Filter
Fluent::Plugin.register_filter('replace_key', self)
config_param :pattern, :string
config_param :replacement, :string
attr_reader :pattern, :replacement
def configure(conf)