Skip to content

Instantly share code, notes, and snippets.

@Mandorlo
Mandorlo / fill-form.js
Created December 5, 2023 16:17
Bookmarklet Fill Form
(async function() {
window.loadStyle = async (url) => {
if (Array.isArray(url)) return Promise.all(url.map(window.loadStyle));
if (/\.js$/gi.test(url)) return window.loadScript(url);
if (document.querySelector(`link[href="${url}"]`)) return;
let link = document.createElement('link');
link.rel = 'stylesheet';
link.href = url;
document.head.appendChild(link);
@Mandorlo
Mandorlo / PHP_CMD.php
Last active March 4, 2021 08:23
PHP command line library
<?php
/**
* Prompts for a password on the commandline
* characters are not visible while the user types
*
* @param string $prompt (optional default to "Enter Password:") the text inviting the user to enter the password
*
* @return string the password entered
*
@Mandorlo
Mandorlo / scroll.js
Created March 4, 2020 07:35
nice utility to amange scroll in a web page
/**
* This module allows to execute certain actions during scroll
* when a certain trigger is triggered
*
*/
function init_scroll(opt) {
let opt_default = {
scroll_container: 'html, body', // the element in which we want to scroll
@Mandorlo
Mandorlo / gist:04310ff21fa76554818dade19710745a
Last active March 6, 2020 08:29
useful list manipulation helpers in JS
We couldn’t find that file to show.
@Mandorlo
Mandorlo / JS_HTML_MISC.js
Last active April 1, 2020 09:44
Useful functions for html
/**
* waits for fn_cond() to return truthy value and then executes fn_exec()
*/
function retry(fn_cond, fn_exec, max_retries = -5) {
if (max_retries == 0) return;
if (fn_cond()) return fn_exec();
return setTimeout(_ => retry(fn_cond, fn_exec, max_retries-1), 100);
}
import * as moment from 'moment';
export const _ = {
sum,
mean,
traverse,
listMonths,
map2Obj,
sortBy,
values,
/* ======================================================= */
/* OPS SUR LES ENSEMBLES */
/* ======================================================= */
function xor(arr1, arr2, fn = null) {
let arr = []
let xor1 = identity(arr1)
let xor2 = identity(arr2)
if (fn && typeof fn == 'string') {
xor1 = arr1.map(el => el[fn])

Documentation LIB_FILES

TODO : ajouter la fonction Unzip (à nettoyer depuis Inventaire.xlsm)

Liste des fonctions

  • getDirsize : (dirPath, optional recursive = True) renvoie la taille du dossier en octets
  • getFileSize : (filePath) renvoie la taille du fichier en octets
  • readFile : (filePath, optional encoding = "utf-8") renvoie le contenu du fichier

Documentation LIB_EXCEL

Liste des fonctions

  • syncRemoteMatrices : synchronise des tableaux entre 2 classeurs ou 2 onglets
  • myCBool : comme CBool mais CBool("") = false
  • getOpt : fonction pour gérer les options dans les arguments de fonctions
  • rechercheLigne
  • rechercheV

Documentation LIB_LIST

Liste des fonctions

  • coll2arr : transforme une collection en array
  • trierArr : trie un array selon un critere
  • countOccurArr : compte le nombre d'occurence d'une chaine dans un array
  • arrayMerge : fusionne 2 arrays
  • arrayPadding : complète un array avec une chaine pour qu'il atteigne une certaine longueur