Skip to content

Instantly share code, notes, and snippets.

View RobinDev's full-sized avatar

Robin Delattre RobinDev

View GitHub Profile
@RobinDev
RobinDev / bookmarklet.js
Last active June 11, 2024 11:48
Bookmarklet - GA - Drupal 10 - Menu
javascript: (function () { function getIndentationLevel(row) {
const indentationDiv = row.querySelectorAll(".js-indentation");
return indentationDiv.length;
}
function getParentRow(row) {
const currentIndentLevel = getIndentationLevel(row);
console.log(currentIndentLevel);
let previousRow = row.previousElementSibling;
while (previousRow) {
@RobinDev
RobinDev / TooltipTpl.php
Last active December 27, 2023 08:10
Example League/Plates Fork
<?php
namespace App\Template\Partial; // src/Template/Partial/TooltipTpl.php
use League\Plates\Template\Template;
use League\Plates\Template\TemplateClassInterface;
use App\Plates\AbstractTemplate;
use App\Plates\TemplateExtension;
use function Symfony\Component\String\u;
@RobinDev
RobinDev / Autocomplete $this
Last active November 1, 2023 14:08
From Twig to Plates
find . -type f -name "*.php" -exec sed -i '1i\
<?php\
\
use My\\App\\Service\\PlatesTemplate;\
\
/**\
* @var PlatesTemplate $this\
*/\
\
?>' {} \;
@RobinDev
RobinDev / results.md
Created November 21, 2022 11:01
Fastest way to fin if a key exists in an array with PHP 8
array(4) {
  'array_key_exists' =>
  double(0.76186203956604)
  'isset' =>
  double(0.78142905235291)
  'noCheck' =>
  double(0.80179715156555)
  'empty' =>
 double(0.80491018295288)
@RobinDev
RobinDev / optimize.html
Created May 9, 2020 17:11
Optimize your title for you SEO : Wich size ? https://piedweb.com/seo/title
<html>
<head>
<meta charset="UTF-8">
<title>Optimiser sa title avec une taille parfaite !</title>
</head>
<input type=text placeholder="..." id=title> <div id=titleWidth></div>
<style>
#titleWidth {
font-size: 20px;
margin:0;
@RobinDev
RobinDev / getCommonUtf8CharsWidth.php
Created May 9, 2020 16:11
Get width for a given font-size for common utf-8 charachters
<html>
<head>
<meta charset="UTF-8">
<style>
h3 {
font-size: 20px;
margin:0;
padding:0;
border:0;
font-weight: 400;
@RobinDev
RobinDev / install-cke-for-piedwebcms.md
Last active March 14, 2019 12:09
Install CKE editor for PiedWeb CMS
@RobinDev
RobinDev / remove-ads-from-twitter.js
Last active January 15, 2019 15:39
Twitter Personalization : Remove Sidebar and Ads
// Share for educationnal purpose only
// --------------------
// To remove ads or sidebar from twitter, just inject this code (via cjs for example) :
// Current code work for the new Twitter TL from you favorite navigator (january 2019)
// --------------------
function removeSidebar() {
var elem = document.querySelector('[data-testid=sidebarColumn]');
if (elem) elem.parentNode.removeChild(elem);
}
@RobinDev
RobinDev / install
Last active January 7, 2019 09:30
Dev.piedweb.com
composer require piedweb/github
php render.php
@RobinDev
RobinDev / main.js
Last active November 8, 2018 11:53
Image simple lazy Loader with SEO enhancement
/**
* Simple Image Lazy Loader
* @author: Robin D. https://www.robin-d.fr/
* idea borrow from : https://davidwalsh.name/lazyload-image-fade
* Example : <span data-img="https://source.unsplash.com/collection/993239/600x400">Random Image from Unsplash</span>
* will be transform to : <img src="https://source.unsplash.com/collection/993239/600x400" alt="Random Image from Unsplash" />
*/
export function imgLazyLoad() {
[].forEach.call(document.querySelectorAll('[data-img]'), function(img) {
let newDomImg = document.createElement('img');