Skip to content

Instantly share code, notes, and snippets.

View ivanobulo's full-sized avatar

Ivan Luzyanin ivanobulo

View GitHub Profile
@ivanobulo
ivanobulo / git_log.md
Last active March 22, 2022 17:31 — forked from olivierlacan/git_log.md
My git log custom output aliases
git config --global alias.hist "log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short"
git config --global alias.lol "log --graph --decorate --pretty=oneline --abbrev-commit --all"
git config --global alias.mylog "log --pretty=format:'%h %s [%an]' --graph"
git config --global alias.last 'log -1 HEAD'
git config --global alias.s 'status -s'

To check that they've been added correctly, first run git config --list. You should see something like this in the midst of all your other configuration:

def justify(words: Array[String], maxWidth: Int): Vector[String] = {
val (lines, lastWords, width) = words.foldLeft((Vector.empty[String], Vector.empty[String], 0)) {
case ((resultLines, wordAcc, currentLineLen), word) =>
if ((currentLineLen + word.length + (wordAcc.size - 1)) < maxWidth) {
(resultLines, wordAcc :+ word, currentLineLen + word.length)
} else {
val line = buildLine(wordAcc, maxWidth, currentLineLen)
(resultLines :+ line, Vector(word), word.length)
}
}
def buildLine(words: Vector[String], maxWidth: Int, wordsWidth: Int): String = {
val spacePlacements = words.size - 1
val missingSpaces = maxWidth - wordsWidth
val numSpace = missingSpaces / Math.max(spacePlacements, 1)
val remSpaces = missingSpaces % Math.max(spacePlacements, 1)
words.zipWithIndex.foldLeft(new StringBuffer()) { case (buf, (word, pos)) =>
buf.append(word)
if (pos == 0 || pos < words.size - 1) { // first or not last
buf.append(Array.fill(numSpace + (if (pos < remSpaces) 1 else 0))(' '))
lazy val ecrGetLogin = taskKey[Unit]("Login to ECR")
ecrGetLogin in ThisBuild := {
val os = new java.io.ByteArrayOutputStream
(s"aws ecr get-login --no-include-email --registry-ids ${ecrCallerId.value}" #> os).!
os.close()
// this will run 'docker login ...' that 'aws ecr get-login' have returned
os.toString.!
}
import scala.sys.process._
lazy val ecrCallerId = settingKey[String]("AWS caller ID")
ecrCallerId in ThisBuild := {
val os = new java.io.ByteArrayOutputStream
("aws sts get-caller-identity --output text" #> os).!
os.close()
val output = os.toString.trim
output.takeWhile(_ != '\t')
def writeAll[K, V](driver: TopologyTestDriver, records: Seq[(K, V)])(
implicit recordFactory: ConsumerRecordFactory[K, V]
) = ???
def writeAll[K : KafkaAvroSerde, V : KafkaAvroSerde](driver: TopologyTestDriver, records: Seq[(K, V)])(
implicit recordFactory: ConsumerRecordFactory[K, V]
) = ???
object SerdeImplicits {
implicit def consumedAuto[K, V](implicit kSerde: KafkaAvroSerde[K], vSerde: KafkaAvroSerde[V]): Consumed[K, V] = ???
implicit def producedAuto[K, V](implicit kSerde: KafkaAvroSerde[K], vSerde: KafkaAvroSerde[V]): Produced[K, V] = ???
}
trait KafkaAvroSerde[T] {
def keySerde: Serde[T]
def valueSerde: Serde[T]
}
@ivanobulo
ivanobulo / EventSourcing.scala
Last active March 26, 2018 06:27 — forked from szoio/EventSourcing.scala
Event Sourcing with Free Monads
package eventsourcing
import java.time.Instant
import cats._
import cats.data.EitherK
import cats.free.{Free, InjectK}
import cats.implicits._
import doobie.imports._
import fs2.Stream