Skip to content

Instantly share code, notes, and snippets.

View aaabramov's full-sized avatar
👨‍💻
Focusing

Andrii Abramov aaabramov

👨‍💻
Focusing
View GitHub Profile
@aaabramov
aaabramov / ScalaDslAttempts
Created February 11, 2018 13:16
Attempt to create Anti Fraud DSL based on rules
package example.dsl
import scala.language.implicitConversions
case class Card(number: String, firstName: String, lastName: String)
case class User(username: String, email: String)
case class AntiFraudInput(card: Card, user: User, amount: Double)
@aaabramov
aaabramov / SignTest.scala
Last active March 16, 2018 09:05
Implicit parameter in traits
trait PrettyPrinted[A] extends (A => String)
object PrettyPrinted {
def apply[A](f: A => String): PrettyPrinted[A] = f(_)
}
trait Printable[A] {
implicit def printer: PrettyPrinted[A]
}
@aaabramov
aaabramov / Attempt1.conf
Last active February 17, 2019 16:17
Logstash PATCH behavior
input {
# ...
}
output {
elasticsearch {
index => "transactions"
document_id => "%{id}"
action => update
hosts => "es"
}
@aaabramov
aaabramov / bug.scala
Last active December 21, 2020 12:05
Mongo Integer ClassCastException issue
package the
import org.bson.codecs.configuration.CodecRegistries.fromRegistries
import org.mongodb.scala.MongoClient.DEFAULT_CODEC_REGISTRY
import org.mongodb.scala.bson.BsonInt64
import org.mongodb.scala.{Document, MongoClient}
import scala.concurrent.Await
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
@aaabramov
aaabramov / solution.scala
Created January 12, 2021 12:26
akka-http validate path param with reusable directive
// https://stackoverflow.com/questions/65669069/akka-http-validate-path-segment
import akka.http.scaladsl.model.Uri.Path
import akka.http.scaladsl.server.{Directive, Rejection}
import com.exabeam.scheduler.models.AppErrors
import org.bson.types.ObjectId
final case class MalformedPathParamRejection(parameterName: String, errorMsg: String) extends Rejection
object ValidatedObjectId {
@aaabramov
aaabramov / build.sbt
Last active January 13, 2021 11:44
SBT bug for scala 2.12.13
lazy val myProjectClient = (project in file("my-project-client"))
.settings(name := "myProjectClient")
.settings(commonSettings)
.enablePlugins(CustomPlugin)
lazy val service = (project in file("service"))
.settings(name := "myProjectSvc")
.settings(commonSettings)
.settings(serviceSettings)
.dependsOn(myProjectClient)
@aaabramov
aaabramov / code.scala
Last active April 7, 2021 15:47
Scala 0.asInstanceOf[B]
// Code example for https://stackoverflow.com/q/66989225/5091346
package com.github.aaabramov
import java.time.LocalDateTime
object Test extends App {
trait TestTrait[A] {
@aaabramov
aaabramov / abbreviations.md
Last active January 17, 2022 10:50
Popular abbreviations used in IT world.
Abbreviation Spelling Explanation
ASAP As soon as possible
AFAIK As far as I know used when you believe that something is true, but you are not completely certain
AFAIR As far as I remember
# See https://telegra.ph/Gratus-Bot-06-24
CREATE TABLE "data_entity"
(
"id" BIGSERIAL NOT NULL PRIMARY KEY,
"userId" BIGINT NOT NULL,
"chatId" BIGINT NOT NULL,
"createdAt" TIMESTAMPTZ NOT NULL DEFAULT NOW()
);
CREATE INDEX idx_data_entity_userId_chatId ON "data_entity" ("userId", "chatId");
@aaabramov
aaabramov / README.md
Created June 29, 2022 13:06
Bootstrap TypeScript npm project

Init project:

npm init

Install typescript & @types

npm install --save-dev \