Skip to content

Instantly share code, notes, and snippets.

View Zacaria's full-sized avatar
🦀

Zacaria Chtatar Zacaria

🦀
View GitHub Profile
@Zacaria
Zacaria / init_kafka.yml
Created February 16, 2024 00:53
Kafka init docker-compose
version: '3.7'
services:
init-kafka:
image: confluentinc/cp-kafka:${KAFKA_VERSION}
entrypoint: [ '/bin/sh', '-c' ]
command: |
"
# block until kafka is reachable
kafka-topics --bootstrap-server kafka-broker-1:9092 --list
@Zacaria
Zacaria / index.js
Created September 25, 2022 13:20
Compute your process duration without the time when you are waiting for at least one remote call
// Say that you have a script that does multiple parallel calls
// You want to know how much time you spent in your own process
// While there was not a remote call at the same moment
// You can easily get backendCalls by saving the timestamp before and after a request
export const callsToPointInTime = (requestTimings, call) => {
if (
typeof call.startTime === "undefined" ||
typeof call.endTime === "undefined"
@Zacaria
Zacaria / index.js
Created January 25, 2022 15:20
Add value to clipboard from sessionStorage
const value = JSON.parse(sessionStorage.user).some_value
document.oncopy = function(event) {
event.clipboardData.setData("Text", value);
event.preventDefault();
};
document.execCommand("Copy");
document.oncopy = undefined;
@Zacaria
Zacaria / index.js
Last active August 14, 2020 12:09
memoization lvl 2
function concat(start, end) {
return start + '' + end;
}
function memo(fn) {
let cache = {};
return (...args) => {
const hash = JSON.stringify(args);
if(!(hash in cache)) {
@Zacaria
Zacaria / index.js
Created July 23, 2020 07:37
memoization lvl 1
function concat(start,end) {
return start + '' + end;
}
function memo() {
let cache = {};
return (start, end) => {
console.log()
if(!((start+''+end) in cache)) {
@Zacaria
Zacaria / index.js
Created July 23, 2020 07:37
memoization lvl 1
function concat(start,end) {
return start + '' + end;
}
function memo() {
let cache = {};
return (start, end) => {
console.log()
if(!((start+''+end) in cache)) {
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="http://cmx.io/v/0.1/cmx.css">
<script src="http://cmx.io/v/0.1/cmx.js" charset="utf-8"></script>
<style>.cmx-user-scene4 .cmx-text-border .cmx-path {stroke: orange}</style>
<body>
<div style="max-width:900px; -webkit-transform:rotate(0deg)">
<scene id="scene1">
<label t="translate(0,346)">
<tspan x="0" y="0em">Where it all begins</tspan>
@Zacaria
Zacaria / alertes_FI9_desactiver.csv
Created November 15, 2019 08:14
Stream csv into sql queries
ID email
7645528 g.titi@netc.fr
7531625 g.toto@netc.fr
7147364 g.terter@netc.fr
7147337 g.rezrz2@netc.fr
7147327 th.coucou@hotmail.fr
7145492 mercijeff@mail.ru
6209349 merlin.ariane@free.fr
@Zacaria
Zacaria / index.js
Created October 5, 2019 11:32
async await aws DynamoDB csv seed
exports.handler = async (event) => {
const AWS = require('aws-sdk');
const fs = require('fs');
const DDB = new AWS.DynamoDB;
AWS.config.update({
region: 'us-east-1',
});
const puts = fs
@Zacaria
Zacaria / index.js
Created September 6, 2018 09:13
dot notation object key to object structure
import _ from 'lodash';
const resolveObjects = input => {
return Object.getOwnPropertyNames(input)
.map(dotKey => dotKey.split('.')
.reverse()
.reduce((object, key) => {
if(!object) return {[key]: input[dotKey]}
return {[key]: object}
}, null)