Skip to content

Instantly share code, notes, and snippets.

@davideicardi
davideicardi / docker-compose.yml
Last active March 29, 2024 07:18
Kafka on docker
# https://github.com/wurstmeister/kafka-docker
# https://medium.com/big-data-engineering/hello-kafka-world-the-complete-guide-to-kafka-with-docker-and-python-f788e2588cfc
version: '3'
services:
zookeeper:
image: wurstmeister/zookeeper:3.4.6
ports:
- "2181:2181"
@davideicardi
davideicardi / AutoVersion.scala
Last active August 31, 2020 10:08
Calculate version for an SBT project
/*
Calculate project's version using GIT tags and commits.
Main idea is to avoid having a version written in the source code but instead link it to the GIT repository.
It is similar to sbt-git plugin but increment the PATCH part when there are additional commits.
The version is calculated using the last tag and the last commit (using `git describe` output).
If there is at least one commit after the last tag the PATCH part is incremented by 1
and `-SNAPSHOT` is added as a suffix.
Otherwise the tag is used as is.
@davideicardi
davideicardi / sw-audio-in
Last active February 2, 2020 10:05
Switch audio scripts bash script for Ubuntu
#!/bin/bash
set -e
NEW_SOURCE=1
DEFAULT_SOURCE=`pacmd list-sources | grep '* index' | cut -f5 -d' '`
if [ $DEFAULT_SOURCE -eq 1 ]
then
NEW_SOURCE=0
fi
@davideicardi
davideicardi / README.md
Last active February 7, 2021 12:02
Package a Python Lambda for AWS

Package a Python Lambda for AWS

Python virtual env

Create Python virtual env

python3 -m venv v-env

Activate

@davideicardi
davideicardi / README.md
Created August 6, 2019 18:56
Read kinesis data from aws cli

aws kinesis get-shard-iterator --stream-name YOUR_STREAM_NAME --shard-id 0 --shard-iterator-type TRIM_HORIZON

aws kinesis get-records --shard-iterator YOUR_SHARD_ITERATOR

@davideicardi
davideicardi / markdown-merge.js
Last active January 29, 2023 03:13
Node.js script to merge markdown files and processing it. Using node.js streams.
const fs = require("fs");
const { Transform, PassThrough } = require('stream');
function concatStreams(streams) {
let pass = new PassThrough();
let waiting = streams.length;
for (let stream of streams) {
pass = stream.pipe(pass, {end: false});
stream.once('end', () => --waiting === 0 && pass.emit('end'));
}
@davideicardi
davideicardi / REAME.md
Last active December 30, 2022 18:03
Scala AES-CTR encryption, MAC, HMAC, ... with Bouncy Castle example

Scala AES-CTR encryption Bouncy Castle example

Add the following library:

libraryDependencies += "org.bouncycastle" % "bcprov-jdk16" % "1.46"

AESCTR.scala

@davideicardi
davideicardi / README.md
Last active March 8, 2023 15:05
Write and read Avro records from bytes array

Avro serialization

There are 4 possible serialization format when using avro:

@davideicardi
davideicardi / README.md
Last active January 21, 2019 12:39
VerneMq Kubernetes StatefulSet + LoadBalancer

Deploy VerneMq inside Kubernetes

Allow the default service account to read pods data, by adding a role binding:

TODO: Now the yaml works only for the dev1 namespace, how can I make it more generic?

kubectl apply -f ./add-read-pods-binding.yaml
@davideicardi
davideicardi / README.md
Last active April 23, 2023 01:13
Gradle minimal multi-projects scala build

Gradle multi-projects scala build

Assume that you have the following directory structure:

  • your-app
    • project1
      • src
        • main
          • scala
  • App.scala