Skip to content

Instantly share code, notes, and snippets.

View lachezar's full-sized avatar
:shipit:
Type safety lobbyist

Lachezar Yankov lachezar

:shipit:
Type safety lobbyist
View GitHub Profile
@tjarvstrand
tjarvstrand / Middleware.scala
Created July 25, 2023 12:39
zio-telemetry middleware
import io.opentelemetry.api.baggage.Baggage
import io.opentelemetry.api.baggage.propagation.W3CBaggagePropagator
import io.opentelemetry.context.propagation.TextMapGetter
import io.wolverinebeach.zio.telemetry.Tracing
import zio.Trace
import zio.ZIO
import zio.ZIOAspect
import zio.http.*
import java.lang
@btlines
btlines / F.scala
Created September 6, 2020 13:34
A better Future
package effects
import cats.{MonadError, StackSafeMonad}
import scala.concurrent.{ExecutionContext, Future}
import scala.util.{Failure, Success, Try}
final case class F[+E, +A](value: Future[Either[E, A]]) extends AnyVal {
def fold[B](fe: E => B, fa: A => B)(implicit ec: ExecutionContext): Future[B] = value.map {
@domnikl
domnikl / build.gradle.kts
Last active April 12, 2024 22:34
Gradle Kotlin DSL: set main class attribute for jar
tasks.withType<Jar> {
manifest {
attributes["Main-Class"] = "com.example.MainKt"
}
}

Building pgModeler in MacOS with Homebrew

The official installation instructions for pgModeler recommends installing Xcode and the Enterprise DB distribution of Postgres to fulfill its build requirements. Luckily, Homebrew's got us covered!

  1. Checkout the source

    git clone https://github.com/pgmodeler/pgmodeler.git
    
@linasm
linasm / unapply.scala
Last active March 15, 2021 06:17
Output of live coding session "Scala pattern matching: apply the unapply"
import java.time.{LocalDate, LocalDateTime, LocalTime}
/*case */class FullName(val first: String, val last: String)
object FullName {
def apply(first: String, last: String): FullName =
new FullName(first, last)
def unapply(full: FullName): Some[(String, String)] =
Some((full.first, full.last))
@smarter
smarter / gadt.md
Last active March 6, 2024 23:33
GADTs in Scala

Generalized Algebraic Data Types in Scala

Basic GADTs

Here's an ADT which is not a GADT, in Haskell:

data Expr = IntExpr Int | BoolExpr Bool
@ursuad
ursuad / kafka-cheat-sheet.md
Last active March 14, 2024 10:32
Quick command reference for Apache Kafka

Kafka Topics

List existing topics

bin/kafka-topics.sh --zookeeper localhost:2181 --list

Describe a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --describe --topic mytopic

Purge a topic

bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --config retention.ms=1000

... wait a minute ...

@lachezar
lachezar / Devices.java
Last active September 14, 2015 15:17
Helper class to get the consumer friendly device name. Upvote http://stackoverflow.com/a/27836910/1048340
/*
* Copyright (C) 2015 Jared Rummler <jared.rummler@gmail.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@ejhayes
ejhayes / README.md
Last active November 29, 2019 14:09
Prose theme for zsh