Skip to content

Instantly share code, notes, and snippets.

@crakjie
crakjie / Docker GraalVm on alpine
Created August 1, 2018 13:29
Dockerfile that that create a ready to used graalvm
FROM alpine:3.8
MAINTAINER crakjie
ARG http_proxy
ARG https_proxy
RUN apk --update add --no-cache \
bash \
wget \
@crakjie
crakjie / Kafka-lag.md
Last active August 21, 2018 14:29
Kafka lag

Lag sum by consumer.

./kafka-consumer-groups.sh --new-consumer  --bootstrap-server localhost:9092 --describe --group csa_aggregator | tail -n +3 | awk '{ sum[$7] += $3 } END { for(i in sum) print i, sum[i] }'

Speed by consumer , the 10 number is '10 second' of sampling. the result is in message by secondes.

paste <(./kafka-consumer-groups.sh --new-consumer  --bootstrap-server localhost:9092 --describe --group csa_aggregator | tail -n +3 | awk '{ sum[$7] += $3 } END { for(i in sum) print i, sum[i] }' ) \
&lt;(sleep 10 &amp;&amp; ./kafka-consumer-groups.sh --new-consumer --bootstrap-server localhost:9092 --describe --group csa_aggregator | tail -n +3 | awk '{ sum[$7] += $3 } END { for(i in sum) print i, sum[i] }') | \
@crakjie
crakjie / Dichotomy.scala
Created December 19, 2018 09:23
Looking for the last point in a continuous function where the predicat "test" is true
import scala.annotation.tailrec
//Looking for the last point in a continuous function where the predicat "test" is true
@tailrec
def dichotomy(lower : Double, upper: Double)( test: Double => Boolean) : Double = {
val gap = (upper-lower)/ 2
val middle = lower + gap
if(gap <= 1)
lower
else if(test(middle)) {
if(middle == lower) //Float or Double precision error
@crakjie
crakjie / splitIn.scala
Created September 25, 2019 12:45
Split a list into n list containing an even number of element
/** Split a list in n List */
def splitIn[A](n: Int)(l: List[A]): List[List[A]] = {
l.zipWithIndex
.foldLeft(Array.fill(n)(List.empty[A])) {
case (b, a) =>
b(a._2 % n) = a._1 :: b(a._2 % n)
b
}
.filter(_.nonEmpty)
.map(_.reverse)(collection.breakOut)
@crakjie
crakjie / Transactioner.scala
Created October 14, 2019 16:23
cats effect transaction keeper
import cats._
import implicits._
import cats.effect._
import concurrent._
import cats.effect.implicits._
/**
* The transactioner help to make transaction by unsuring the transaction is open before runing task and task are ended before close
* @tparam F
*/
@crakjie
crakjie / Cargo.toml
Last active September 1, 2023 16:34
arrow rust
[package]
name = "ckfunc"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
arrow = { version = "45.0.0", features = ["ipc_compression"] }
intmap = "2.0.0"