Skip to content

Instantly share code, notes, and snippets.

@sholokhov
sholokhov / Main.scala
Created January 12, 2023 16:44
fs2-kafka performance benchmark
package pro.sholokhov
// deps
//"org.typelevel" %% "cats-effect" % "3.3.13"
//"org.typelevel" %% "cats-effect-kernel" % "3.1.1"
//"org.typelevel" %% "cats-effect-std" % "3.1.1"
//"com.github.fd4s" %% "fs2-kafka" % "3.0.0-M9"
import cats.effect.{Clock, IO, IOApp}
import fs2.Stream

Advanced Functional Programming with Scala - Notes

Copyright © 2016-2017 Fantasyland Institute of Learning. All rights reserved.

1. Mastering Functions

A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.

val square : Int => Int = x => x * x
@sholokhov
sholokhov / sbtopts
Created June 8, 2017 09:44
Prevent SBT StackOverflowError on large projects
# increase stack size
-Xmx2G
-Xss16M
@sholokhov
sholokhov / latency.txt
Created November 13, 2016 17:42 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers
--------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@sholokhov
sholokhov / rhel6-docker-install.md
Last active September 6, 2016 16:01
How to install docker on Red Hat Linux 6

You need kernel version at least 2.6.32-431 or higher (check it with uname -r command).

curl -O -sSL https://get.docker.com/rpm/1.7.1/centos-6/RPMS/x86_64/docker-engine-1.7.1-1.el6.x86_64.rpm

Then install package via yum:

yum localinstall --nogpgcheck docker-engine-1.7.1-1.el6.x86_64.rpm

Try to run it:

@sholokhov
sholokhov / LruCache.java
Created July 29, 2016 21:37
Lru simple cache
//
// simple least recently used cache
//
import java.util.LinkedHashMap;
import java.util.*;
class LruCache {
private LinkedHashMap cache = new LinkedHashMap<String, String>() {