Skip to content

Instantly share code, notes, and snippets.

function fromLeonardoColorToTokenStudio(leonardoColors) {
return {
"colors": leonardoColors.reduce(function (memo, entry) {
if (entry.values) {
for (const value of entry.values) {
const [name, shade] = value.name.split(/(?=[1-9])/g);
memo[name] = {
...(memo[name] || {}),
@germain-gg
germain-gg / contenteditable-utils.js
Last active October 26, 2020 15:46
Utils to get and set the caret position in a content editable
var getCaretOffsetWithin = function(node) {
var treeWalker = createTreeWalker(node);
var sel = window.getSelection();
var pos = {
start: 0,
end: 0
};
@germain-gg
germain-gg / DistanceUtils.php
Last active August 29, 2015 14:03
PHP Function to check if a latitude/longitude point is nearer than a distance thresold
<?php
/*
* Check if the tournament is nearer than the distance thresold
* according to the latitude and longitude parameters
*
* param1 : $latitude of the user
* param2 : $longitude of the user
* param3 : max distance
*
* Formula : http://www.movable-type.co.uk/scripts/latlong.html