Skip to content

Instantly share code, notes, and snippets.

View Nolwennig's full-sized avatar
🐘
Focusing

Nolwennig Nolwennig

🐘
Focusing
View GitHub Profile
@Nolwennig
Nolwennig / delete_wp_revisions.sql
Last active April 12, 2023 08:43
This query deletes all post revisions that were modified more than 30 days ago from the current date. Note that this query can potentially delete a large number of revisions, so be sure to back up your data before running it.
DELETE FROM wp_posts
WHERE post_type = 'revision'
AND post_modified < DATE_SUB(NOW(), INTERVAL 30 DAY);
@Nolwennig
Nolwennig / color_headings.js
Created February 14, 2023 14:13
color each h2-h6 from DOM with a dotted border
let headings = document.querySelectorAll('h2, h3, h4, h5, h6');
for (let i = 0; i < headings.length; i++) {
let heading = headings[i];
let level = parseInt(heading.tagName.charAt(1));
let color;
switch (level) {
case 2:
color = "red";
break;
case 3:
@Nolwennig
Nolwennig / xdebug_lastest_version.sh
Created July 1, 2022 15:21
Get lastest tags version number from Xdebug
git ls-remote --tags https://github.com/xdebug/xdebug.git | grep -vE 'refs/tags/XDEBUG|{}' | tail -n1 | cut -d'/' -f3
# todo
# Inspired from https://gist.github.com/Nolwennig/57156f68d2aab1931e863a029cbf5dc0
# commmand list all containers docker
docker ps -a
# command to shown docker active
docker ps
# diff beetween active and all containers
# with the diff result pipe to sed to retrieve only container id
# use container ids result feed docker rm command
@Nolwennig
Nolwennig / docker-status.sh
Last active June 29, 2022 19:43
Docker ps: - run: 0 --all: 32 --lastest: CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
echo 'docker ps:';
echo '- run:' $((`docker ps | wc -l` -1));
echo '--all:' $((`docker ps -a | wc -l` -1));
echo '--lastest:' ;\docker ps -l;
@Nolwennig
Nolwennig / cleanup_session.sh
Last active June 20, 2022 00:47
Magento delete session files when var/session directory contain a too massive number of sess_* files
#!/bin/sh
# Place this script in magento/var/ directory
for n in `seq 0 9`
do
for u in `seq 0 9`
do
for m in `seq 0 9`
do
name="sess_"$n$u$m*
@Nolwennig
Nolwennig / mysql_splitdump.sh
Created May 23, 2018 13:26 — forked from jasny/mysql_splitdump.sh
Split MySQL dump SQL file into one file per table or extract a single table
#!/bin/bash
####
# Split MySQL dump SQL file into one file per table
# based on http://blog.tty.nl/2011/12/28/splitting-a-database-dump
####
if [ $# -lt 1 ] ; then
echo "USAGE $0 DUMP_FILE [TABLE]"
exit
@Nolwennig
Nolwennig / readme.md
Last active August 26, 2021 10:40
Magento adminhtml - Wysiwyg editor with microdata tagging support

Magento adminhtml

Editeur Wysiwyg supportant le balisage microdata

Actuellement comme éditeur de texte dans le back-office, nous avons :

  • Tiny mce 3.5.11 sur catalog
  • Redactor v10.1.2 dans le module mage_pleasure blog

Aucun des deux ne permets de saisir de manière simplifié du contenu microdata.

<!DOCTYPE html>
<html>
<body>
<h1>This is heading 1</h1>
<p>My first paragraph.</p>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
@Nolwennig
Nolwennig / OwebiaShippingHelper.php
Created April 21, 2021 10:47
non well formed numeric value
public static function parseSize($size)
{
$strSize = trim($size);
$last = strtolower($strSize[strlen($strSize)-1]);
$size = rtrim($strSize, $last);
switch ($last) {
case 'g': $size *= 1024;
case 'm': $size *= 1024;
case 'k': $size *= 1024;
}