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
// See https://docs.aws.amazon.com/athena/latest/ug/application-load-balancer-logs.html for regex pattern and column names | |
val raw = spark.read.text("s3://some_s3_path/albname/AWSLogs/accountId/elasticloadbalancing/region/year/month/day/") | |
val regex = """([^ ]*) ([^ ]*) ([^ ]*) ([^ ]*):([0-9]*) ([^ ]*)[:-]([0-9]*) ([-.0-9]*) ([-.0-9]*) ([-.0-9]*) (|[-0-9]*) (-|[-0-9]*) ([-0-9]*) ([-0-9]*) \"([^ ]*) (.*) (- |[^ ]*)\" \"([^\"]*)\" ([A-Z0-9-_]+) ([A-Za-z0-9.-]*) ([^ ]*) \"([^\"]*)\" \"([^\"]*)\" \"([^\"]*)\" ([-.0-9]*) ([^ ]*) \"([^\"]*)\" \"([^\"]*)\" \"([^ ]*)\" \"([^\s]+?)\" \"([^\s]+)\" \"([^ ]*)\" \"([^ ]*)\"""" | |
val albLogs = raw.select( | |
regexp_extract($"value", regex, 1).as("type"), | |
regexp_extract($"value", regex, 2).as("time"), | |
regexp_extract($"value", regex, 3).as("elb"), |
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 org.http4s.circe._ | |
import org.http4s.dsl.io._ | |
import org.http4s.implicits._ | |
import org.http4s.server.blaze.BlazeServerBuilder | |
import org.http4s.{ HttpApp, HttpRoutes, Request } | |
import cats.data.Kleisli | |
import cats.effect._ | |
import cats.effect.concurrent.Ref | |
import cats.implicits._ |
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 fs2.{ Pipe, Pull } // Version 1.0.5 | |
import cats.effect.{ ExitCode, IO, IOApp } | |
object BreakingPipe extends IOApp { | |
def onlyOnNonEmpty[F[_], A, B](innerPipe: fs2.Pipe[F, A, B]): fs2.Pipe[F, A, B] = { s => | |
s.pull.peek.flatMap { | |
case None => Pull.pure(None) | |
case Some((_, ss)) => ss.through(innerPipe).pull.echo |
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 shapeless._ | |
import shapeless.ops.hlist | |
object mapper extends Poly1 { | |
implicit def caseOpt[T] = at[Option[T]](_ => Option.empty[T]) | |
} | |
def foo[S, SRep <: HList, O <: HList](s: S)(implicit | |
labelledGeneric: Generic.Aux[S, SRep], | |
map: hlist.Mapper.Aux[mapper.type, SRep, O], |
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
aws s3api list-objects --bucket BUCKET_NAME --prefix WTVR/PREFIX/ --query 'Contents[?!contains(Key,`SUCCESS`)].{Key:Key}' --output json | jq '[.[] | .["url"] = "s3://BUCKET_NAME/" + .Key | .["mandatory"] = true | del(.Key)] | { entries: .}' |
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
aws s3api list-objects --bucket BUCKET_NAME --prefix "whateverprefix/" --output json --query "[sum(Contents[].Size), length(Contents[])]" |
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
Alias for loopback that container can see: | |
`sudo ifconfig lo0 alias 10.0.2.2` | |
container can now access stuff running on host at `10.0.2.2`! |
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
testOnly *MySuite -- -z foo | |
to run only the tests whose name includes the substring "foo". For exact match rather than substring, use -t instead of -z. |
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
Ref: https://ariejan.net/2009/10/26/how-to-create-and-apply-a-patch-with-git/ | |
git format-patch master --stdout > whatever.patch | |
git apply --check whatever.patch | |
git am --signoff < whatever.patch |
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
for i in *; do ( cd $i; git grep foo HEAD ); done |
NewerOlder