Skip to content

Instantly share code, notes, and snippets.

View zipang's full-sized avatar
🧑‍🚀
@Mention

Christophe Desguez zipang

🧑‍🚀
@Mention
  • EIDOLON LABS
  • France
View GitHub Profile
@zipang
zipang / objects-properties.js
Created June 26, 2023 15:48
Set and get deep properties on objects
/**
* Split a path to a property into its keys
* (property names or array indexes)
* @example
* splitPath("persons[0].address.street") => ["persons", "0", "address", "street"]
* @param {String} path
* @return {Array}
*/
export const splitPath = (path = "") => path.split(/[,[\].]+?/).filter(Boolean);
@zipang
zipang / iframe-messages-sender.markdown
Created September 30, 2022 09:15
IFRAME MESSAGES SENDER

IFRAME MESSAGES SENDER

This codepen is used to be embedded and show how to send message to its parent page

A Pen by zipang on CodePen.

License.

/**
* Build a promise that resolve in `ms` milliseconds with the response provided
* NOTE: response may be a function, whose evaluation would be delayed by ms
* @param {Number} ms The delay to wait before resolving the Promise
* @param {Any} response The data to return after ms.
* @return {Promise}
*/
export const delay = (ms, response) =>
new Promise((resolve) =>
setTimeout(
@zipang
zipang / play.sh
Created January 29, 2021 13:44
Play the content of a dir (mp3)
#!/bin/bash
if [ ! -f "playlist.m3u" ]; then
ls *.mp3 -v -1 > playlist.m3u
fi
mplayer -playlist ./playlist.m3u
@zipang
zipang / node-app.js
Created October 9, 2019 11:47
How to import es6 modules from inside a commn js executable node application
#!/usr/bin/env node
/**
* babel-register is all that is needed to require es6 module transparently
*/
require("babel-register")({
presets: ["env"]
});
const { someNamedExport } = require("./es6-module");
const someDefaultExport = require("./es6-module.js").default; // Notice how we must access the `default` property to access the default export
@zipang
zipang / Events.js
Last active September 23, 2019 08:25
Indispensable event throttling and debouncing utiilities
/**
* Wait that functions calls run below a delay of @ms
* to trigger the function @fn
* @param {Function} fn - the function to debounce
* @param {Number} [ms=250] - the delay (in ms) between each function call
* @param {Object} [ctx] - An optional context to bind the function to
* @return {Function} that will execute only after the specified delay between calls has elapsed
*/
export const debounce = (fn, ms = 250, ctx) => {
return function(...args) {
@zipang
zipang / CV.md
Last active November 24, 2021 17:18
My CV

Développeur full-stack JS / Architecte

RESUME

25 ans d'expérience en SSIIs, startups et freelance comme Chef de Projet, Lead Dev ou Architecte Système.

Tout en veillant continuellement à me tenir à jour sur les derniers outils, langages, mon intérêt s'étend aujourd'hui de plus en plus à toutes les étapes du Design Produit (Product Design, Service Design Thinking).
Ces méthodologies ont comme objectif de toujours garder en ligne de mire un objectif simple : créer la meilleure expérience utilisateur (UX) possible pour son produit.
Cela consiste notamment à faire des recherches sur les problèmes récurrents des utilisateur, les modéliser sous forme de personas, imaginer les nouveaux parcours utilisateur pour qu'ils accomplissent leurs tâches, et s'assurer de ne livrer que des fonctionalités utiles puis de mesurer l'impact des livrables pour continuer à améliorer de manière incrémentale le produit.

@zipang
zipang / gist:84e543dd2f664b45fece9e3a3a0dbcf3
Created July 5, 2018 11:24
Array prototype partition
/**
* Partition an array on the result of a boolean test
* @return {Array[Array]} where the first array contains the element that passed the test
*/
Array.prototype.partition = (test) => this.reduce(
(accumulator, val) => {
accumulator[test(val)?0:1] = val
return accumulator
})([[], []])
}
@zipang
zipang / captation.svg
Last active April 19, 2017 15:30
Captation
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@zipang
zipang / formData.js
Last active June 29, 2017 07:02
Serialize form data into a usable JS object(jQuery plugin)
/**
* jQuery plugin to convert form fields to a plain JS Object
* @usage var contactForm = $("form.contact").formData();
* @returns {'fieldName': 'fieldValue', (...)}
*/
$.fn.formData = function() {
var data = {},
keyValues = this.serializeArray();
$.each(keyValues, function() {
var field = this.name, val = this.value;