Skip to content

Instantly share code, notes, and snippets.

@Naedri
Naedri / A100-Coding-Rules.md
Last active December 5, 2023 06:17
Coding rules such as : linting, formatting, versionning and code development.

Coding rules

Coding rules such as : linting, formatting, versionning and code development.

@Naedri
Naedri / useEffect-comparison.tsx
Last active July 28, 2022 13:24
Comparing `useEffect` runs (React and Ionic flavors).
import { useIonViewWillEnter, IonText } from '@ionic/react';
import { FC, useRef, useEffect } from 'react';
export interface ComponentProps {
data: any;
}
const Component: FC<ComponentProps> = ({ data }: ComponentProps) => {
const compoRef = useRef<HTMLDivElement>(null);
const isFirstRender = useRef(true);
@Naedri
Naedri / reduce.js
Created August 6, 2022 07:28
Simple example of reduce function.
const totalAdresse = docs.reduce((prevValue, contrat) => {
console.log(prevValue, contrat);
if (prevValue.includes(contrat.adresse)) {
return prevValue;
} else {
return [...prevValue, contrat.adresse];
}
}, []);
const totalAchatAndVente = docs.reduce(
@Naedri
Naedri / format.color.ts
Last active August 9, 2022 14:03
Color conversion and tool with RGB & hexadecimal code.
// Working in all environments
// https://stackoverflow.com/a/39077686
/**
* Converting RGB to hex
* @param r red
* @param g green
* @param b blue
* @returns Hexacode color
* @example rgbToHex(0, 51, 255); // '#0033ff'
@Naedri
Naedri / Object_concatenation.js
Last active August 25, 2022 22:03
Objects concatenation with redondant values.
let obj1, obj2, obj3;
/**
* spread_synthax
*/
//with non redondant values, everyone stay
obj1 = { food: 'pizza', car: 'ford' };
obj2 = { animal: 'dog' };
obj3 = { ...obj1, ...obj2 };
console.log(obj3); // => { food: "pizza", car: "ford", animal: "dog" }
@Naedri
Naedri / alarm.sh
Last active February 1, 2023 22:49
To retrieve my laptop quickly
#!/bin/bash
# To lock session if needed
# loginctl lock-session
echo && date
echo 'Starting alarm.sh'
SOUND_PERCENT=150
SOUND_FREQUENCY=1000
@Naedri
Naedri / 00_from_google_maps_to_geojson_by_osm.sh
Last active May 16, 2023 21:14
To parse places from a google maps list into a .geojson file powered by OSM, with ordered and linked points.
#!/bin/bash
# This script executes the four Python files sequentially to perform a series of tasks.
# Make sure you have Python installed and the necessary dependencies for each Python script.
# pip install -r requirements.txt
# Step 1: Convert maps to JSON
python 01_maps_to_json.py --address_suffix ", Krakow"
# Step 2: Convert JSON to GeoJSON
@Naedri
Naedri / swap.c
Created June 13, 2023 13:40
Exemples simples de fonctions de swap en C et en C++ pour différents types de passage de paramètres
#include <stdio.h>
void swapByCopy(int a, int b) {
int temp = a;
a = b;
b = temp;
}
// Le passage par pointeur pour obtenir un comportement similaire au passage par référence en C++.
// Cela implique de passer l'adresse des variables à une fonction et d'utiliser les pointeurs pour accéder et modifier les valeurs des variables d'origine.
@Naedri
Naedri / javascript-testing-frameworks-comparison.md
Last active August 29, 2023 14:02
Comparison of Various JavaScript Testing Frameworks and Libraries for UI and Beyond

| Criteria | Comments | WebdriverIO | TheIntern | Nightwatch | TestCafé | Playwright | | -------------------------------------- | ----------------------------------------------- | -------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------- | ----------------------------