Skip to content

Instantly share code, notes, and snippets.

View mehdichaouch's full-sized avatar
🤖
Happiness Developer

Mehdi Chaouch mehdichaouch

🤖
Happiness Developer
View GitHub Profile
@mehdichaouch
mehdichaouch / README.md
Last active November 30, 2023 17:33
🔧 WordPress Plugins Compatibility from command line with WP-CLI
@mehdichaouch
mehdichaouch / mysql_drop_all_tables.sh
Created November 29, 2022 21:12
Linux Delete/Drop all MySQL tables from the command-line in one command
#!/bin/bash
# /!\ keep space character at begening of command to avoid saving it in history
# real mysql DROP TABLE in one command -- very fast
mysqldump --add-drop-table --no-data -u[USERNAME] -p[PASSWORD] [DATABASE]| grep -e '^DROP \| FOREIGN_KEY_CHECKS'| mysql -u[USERNAME] -p[PASSWORD] [DATABASE]
# OR
# loop x time on DROP TABLE, but no mysqldump -- https://stackoverflow.com/a/38814457/293214
@mehdichaouch
mehdichaouch / getStringBetween.php
Created November 22, 2022 10:15
PHP - Get a substring between two strings
<?php
/**
* @param string $string
* @param string $start
* @param string $end
*
* @return bool|string
* @see https://stackoverflow.com/questions/5696412/how-to-get-a-substring-between-two-strings-in-php
*
*/
@mehdichaouch
mehdichaouch / CrowdFarming__Price_Per_Unit.js
Created November 9, 2022 23:14
🚧 WIP 👷 Add price per unit on CrowdFarming website
// Script for https://www.crowdfarming.com/
document.querySelectorAll(".project-card-container").forEach(function (element) {
var priceRaw = element.querySelector(".ds-oh-card-footer-price-quantity").textContent;
var price = priceRaw.replace(",", ".").match(/[+-]?\d+(\.\d+)?/g)[0];
var quantity = "";
if (element.querySelector(".ds-adoption-card-footer-price-weight") !== null) {
quantity = element.querySelector(".ds-adoption-card-footer-price-weight").textContent;
} else if (element.querySelector(".ds-select-box-selected-option span") !== null) {
quantity = element.querySelector(".ds-select-box-selected-option").textContent;
@mehdichaouch
mehdichaouch / csv_remove_column.sh
Created October 21, 2022 15:48
Command shell CSV transformation - Remove columns / drop a column / delete first column
#!/bin/bash
# Memo to found it quicker in future...
#
# Q: How to delete a column/columns of a CSV file which has cell values with a string enclosed in " , "?
# https://www.unix.com/302824377-post1.html
#
# A: https://www.unix.com/302825517-post6.html
# Dataset in: en_EN-export-sample.csv
@mehdichaouch
mehdichaouch / batocera.sh
Created October 14, 2022 21:38
🎮 Batocera command to reboot and fix files/folders permissions
#!/bin/bash
#alias bato_reboot="ssh root@batocera.local -t 'reboot'"
ssh root@batocera.local -t 'reboot'
#alias bato_fix_perms="sudo chown -R root:root . && sudo find . -type f -exec chmod -c 644 {} \; && sudo find . -type d -exec chmod -c 755 {} \;"
# to run from SHARE/roms folder
sudo chown -R root:root . && sudo find . -type f -exec chmod -c 644 {} \; && sudo find . -type d -exec chmod -c 755 {} \;
@mehdichaouch
mehdichaouch / README.md
Created April 11, 2022 11:59
🎞️🗜️ H.265 (HEVC) Video Compression using ffmpeg on Linux
ffmpeg -i VID_20210627_164901.mp4 -c:a copy -c:v libx265 -vtag hvc1 VID_20210627_164901_x265.mp4

for bulk check here

@mehdichaouch
mehdichaouch / fix_user_password.sql
Created April 5, 2022 16:45
Magento 2 SQL snippet to reset admin password
# xxxxxxxx is the salt - it can change or stay like that
# admin123 is the password, you must change it
UPDATE admin_user SET `password` = CONCAT(SHA2('xxxxxxxxadmin123', 256), ':xxxxxxxx:1') WHERE `username` = 'admin';
@mehdichaouch
mehdichaouch / Console_XSS_Warning.md
Last active November 29, 2022 21:25
⚠️ Console XSS Warning & others messages 🚨 display message to visitors in console