Skip to content

Instantly share code, notes, and snippets.

Davide Icardi davideicardi

Block or report user

Report or block davideicardi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@davideicardi
davideicardi / README.md
Last active Sep 16, 2019
Package a Python Lambda for AWS
View README.md

Package a Python Lambda for AWS

Python virtual env

Create Python virtual env

python3 -m venv v-env

Activate

@davideicardi
davideicardi / README.md
Created Aug 6, 2019
Read kinesis data from aws cli
View README.md

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 Nov 10, 2018
Node.js script to merge markdown files and processing it. Using node.js streams.
View markdown-merge.js
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 May 20, 2019
Scala AES-CTR encryption, MAC, HMAC, ... with Bouncy Castle example
View REAME.md

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 Oct 7, 2019
Write and read Avro records from bytes array
View README.md

Avro serialization

There are 4 possible serialization format when using avro:

@davideicardi
davideicardi / README.md
Last active Jan 21, 2019
VerneMq Kubernetes StatefulSet + LoadBalancer
View README.md

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
Created Jul 5, 2018
Gradle minimal multi-projects scala build
View README.md

Gradle multi-projects scala build

Assume that you have the following directory structure:

  • your-app
    • project1
      • src
        • main
          • scala
            • App.scala
@davideicardi
davideicardi / ConditionalFlow.scala
Created Jun 29, 2018
Conditional Akka Stream Flow
View ConditionalFlow.scala
import akka._
import akka.stream._
import akka.stream.scaladsl._
import akka.actor._
// WARNING: Ordering is not guaranteed.
// The problem with this Graph is that when splitting the flow
// we obtain 2 concurrent flows.
// The result of conditionalFlow can returns after another messages is processed in the brodcast.
// ie. If you have 10 messages from 0 to 9. Let's say that we run a conditional flow only for element 0.
View PassThroughFlow.scala
/*
https://scalafiddle.io/sf/sniohcZ/3
(old version: https://scalafiddle.io/sf/sniohcZ/1)
Use PassThroughFlow when you have a message that should be used in a
flow that trasform it but you want to maintain the original message for
another following flow.
For example if you consume messages from Kafka (CommittableMessage).
You process the message (transform, save it inside a database, ...) and then you need again the original message
to commit the offset.
@davideicardi
davideicardi / README.md
Last active Jun 26, 2018
Alpakka HBase connector, write Akka messages to HBase
View README.md
You can’t perform that action at this time.