Skip to content

Instantly share code, notes, and snippets.

View markosski's full-sized avatar
🏠
Working from home

Marcin Kossakowski markosski

🏠
Working from home
View GitHub Profile
import zio._
object logging {
type Logging = Has[Logging.Service]
object Logging {
trait Service {
def info(msg: String, data: Map[String, Any] = Map()): Task[Unit]
}
def liveWithData(initData: Map[String, Any]): Layer[Nothing, Logging] = ZLayer.succeed {
import cats.effect.ExitCode
import cats.data.{NonEmptyList}
import org.http4s.HttpRoutes
import org.http4s.dsl.io._
import org.http4s.server.blaze._
import org.http4s.implicits._
import org.http4s.server.Router
import org.http4s.Header
import org.http4s.StaticFile
import Data.Maybe
data User = User {
userId :: Maybe Int,
name :: String,
age :: Int
} deriving (Show)
data S3Config = S3Config {
region :: String,
import Data.Maybe
data User = User {
userId :: Maybe Int,
name :: String,
age :: Int
} deriving (Show)
data S3Config = S3Config {
region :: String,
@markosski
markosski / thunk.scala
Created December 21, 2018 01:08
thunks
sealed trait Stream[+A]
case object Empty extends Stream[Nothing]
case class Cons[+A](h: () => A, t: () => Stream[A]) extends Stream[A]
object Stream {
def cons[A](hd: => A, tl: => Stream[A]): Stream[A] = {
lazy val head = hd
lazy val tail = tl
Cons(() => head, () => tail)
}
def empty[A]: Stream[A] = Empty
@markosski
markosski / filesizerer.scala
Created August 23, 2018 01:55 — forked from quelgar/filesizerer.scala
Simple Scala example of a pure functional program that does I/O
/*
* Referentially transparent program to print the size of files.
*
* Techniques inspired by:
* "Dead-Simple Dependency Injection"
* Rúnar Óli Bjarnason
* Northeast Scala Symposium, 2012
*
* To run: "scala filesizerer.scala"
* When prompted, enter a file name.
@markosski
markosski / kafka-cheat-sheet.md
Created October 6, 2017 15:16 — forked from sahilsk/kafka-cheat-sheet.md
Apache Kafka Cheat Sheet

Kafka Cheat Sheet

Display Topic Information

$ kafka-topics.sh --describe --zookeeper localhost:2181 --topic beacon
Topic:beacon	PartitionCount:6	ReplicationFactor:1	Configs:
	Topic: beacon	Partition: 0	Leader: 1	Replicas: 1	Isr: 1
	Topic: beacon	Partition: 1	Leader: 1	Replicas: 1	Isr: 1