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)
View ecs-deploy.go
package main
import (
"errors"
"fmt"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/ecs"
kingpin "gopkg.in/alecthomas/kingpin.v2"
"log"
View statefulMapConcat.scala
implicit val system = ActorSystem()
implicit val executor = system.dispatcher
implicit val materializer = ActorMaterializer()
val source: Source[Int, NotUsed] = Source(1 to 10)
val flow1: Flow[Int, Int, NotUsed] = Flow[Int].map(_ * 10)
val flow2: Flow[Int, Int, NotUsed] = Flow[Int].filter(_ % 3 == 0)
val flow3: Flow[Int, Int, NotUsed] = Flow[Int].statefulMapConcat { () =>
var sequence = 0
i =>
View ipv4.scala
import java.net.{Inet4Address, InetAddress, NetworkInterface}
import scala.collection.JavaConversions._
def privateIPv4: Option[String] = NetworkInterface.getNetworkInterfaces
.filter(iface => iface.isUp && !iface.isLoopback && iface.getInetAddresses.hasMoreElements)
.foldLeft(List.empty[InetAddress])((acc, iface) =>
iface.getInetAddresses.foldLeft(acc) { (addresses, address) => address :: addresses }
)
.filter(_.isInstanceOf[Inet4Address])
.filter(_.isSiteLocalAddress)