Skip to content

Instantly share code, notes, and snippets.

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

Alberto Schiabel jkomyno

🏠
Working from home
View GitHub Profile
@jkomyno
jkomyno / fastify-kafka.ts
Created February 23, 2022 02:12
fastify-kafka.ts
import { FastifyPluginCallback } from 'fastify';
import fp from 'fastify-plugin';
import kafka, { ProducerGlobalConfig, Producer } from 'node-rdkafka';
export class KafkaProducer {
constructor(private producer: Producer) {}
send = <T extends string>({ topic, key, payload }: { topic: string; key: string; payload: T }) =>{
this.producer.produce(
topic,
@jkomyno
jkomyno / redis_dev.sh
Last active May 3, 2021 10:49
Run Redis in Docker and monitor every Redis command received in real-time
#!/bin/bash
# Usage: ./redis_dev.sh
# Description: spawn a Redis instance in a background Docker container, and show the logs
# of each Redis command received in real-time. Hitting Ctrl+C will terminate the process and
# kill the Docker container used by the script.
set -e
# Edit this variables accordingly to your use case
@jkomyno
jkomyno / Expr.hs
Last active February 21, 2021 13:43
Haskell Exercises
module Expr where
data Expr a = Var a | Val Int | Add (Expr a) (Expr a)
deriving Show
instance Functor Expr where
-- fmap :: (a -> b) -> Expr a -> Expr b
fmap f (Var x) = Var $ f x
fmap _ (Val n) = Val n
fmap f (Add l r) = Add (fmap f l) (fmap f r)
// parallel processes the data in separate goroutines.
func parallel(start, stop int, fn func(<-chan int)) {
count := stop - start
if count < 1 {
return
}
procs := runtime.GOMAXPROCS(0)
if procs > count {
procs = count
const file2 = require('./file2');
console.log(`Greet -> ${file2.getGreet('Bares')}`);
console.log(`Sum -> ${file2.sum('1', '5')}`);
@jkomyno
jkomyno / clang-format_config.md
Created February 14, 2018 16:57 — forked from Uflex/clang-format_config.md
Configuration of clang-format for QtCreator

Clang-format in QtCreator

Edit: QtCreator 3.1 introduced a new plugin called Beautifier that supports clang-format. You still have to install the clang tools separately but you don't have to add them as external tools anymore. The plugin can be configured in the options dialog under the beautifier tab > Clang Format. Add a new style and copy the configuration below without the curly braces.

QtCreator doesn't allow using clang-format by default. Watch QTCREATORBUG-10111 for a better integration. As of today, you should use it as an external tool, either replacing your selection or the entire file. If you choose to replace the file, you will have to save it before launching the tool and QtCreator will reload the file, making it impossible to undo/redo afterwards. If you choose to replace your selection, you often have to select the whole function, otherwise you will lose the indentation; clang-format doesn't seem to k

@jkomyno
jkomyno / es2.cpp
Created January 29, 2018 21:56
P2 - 1° appello, 29.01.2018
#include <iostream>
using namespace std;
class A {
protected:
virtual void j() { cout << " A::j"; }
public:
virtual void g() const { cout << " A::g "; }
virtual void f() { cout << " A::f "; g(); j(); }
void m() { cout << " A::m "; g(); j(); }
@jkomyno
jkomyno / FitApp.h
Last active January 29, 2018 12:40
P2 - 1° appello 2015
#pragma once
#include <string>
#include <vector>
#include <list>
class Allenamento {
private:
int span;
public:
Allenamento(int s) :
@jkomyno
jkomyno / FileAudio.h
Last active January 29, 2018 12:42
P2 - 3° appello, 14.06.2016
#pragma once
class FileAudio {
private:
double dim;
public:
FileAudio(double d) :
dim(d) {}
~virtual FileAudio() {}
@jkomyno
jkomyno / Gallo.h
Last active January 29, 2018 12:44
GalloFile, OOP c++
#pragma once
#include <vector>
#include "GalloFile.h"
class Gallo {
private:
std::vector<GalloFile*> files;
public:
Gallo(const std::vector<GalloFile*> v) :