Skip to content

Instantly share code, notes, and snippets.

View peterjaap's full-sized avatar

Peter Jaap Blaakmeer peterjaap

  • elgentos ecommerce solutions / Blaakmeer Webdevelopment
  • Groningen, the Netherlands
View GitHub Profile
@peterjaap
peterjaap / miyoo-games-backup-and-remove.sh
Created November 2, 2024 13:11
Script to clean Miyoo games list - remove 99% of all games
#!/bin/bash
# Define the backup directory
BACKUP_DIR=~/backup-miyoo-games
SOURCE_DIR="/mnt/sd-card/Roms"
# Create the backup directory if it doesn't exist
mkdir -p "$BACKUP_DIR"
WELL_KNOWN_GAMES=(
@peterjaap
peterjaap / mage-os-migration.sh
Created October 17, 2024 10:38
Mage OS migration shell script - you can use this if you want to move from Magento community edition to MageOS. This updates your composer.json file and your local patches.
#!/bin/bash
# Path to the composer.json file
COMPOSER_FILE="composer.json"
TEMP_FILE="composer_temp.json"
# Checkout the composer.json file to avoid unwanted changes
git checkout "$COMPOSER_FILE"
# Create a new file to hold updated content
@peterjaap
peterjaap / cleanup-sequence-tables.sql
Created September 19, 2024 06:58
Query to remove Magento 2 sequence tables for non-existing stores
SET @tables = NULL;
SELECT GROUP_CONCAT(table_schema, '.`', TABLE_NAME, '`') INTO @tables FROM (
SELECT *
FROM information_schema.tables AS t
WHERE t.table_schema = 'DB NAME'
AND t.table_name REGEXP "^sequence_(.+)_[0-9]+"
AND SUBSTRING_INDEX(t.table_name, '_', -1) NOT IN (SELECT DISTINCT store_id FROM sales_sequence_meta)
) TT;
SET @tables = CONCAT('DROP TABLE ', @tables);
@peterjaap
peterjaap / ACSD-51892_2.4.6.patch
Created July 11, 2023 07:28
Drop-in ACSD-51892 patch for 2.4.6 / 2.4.6-p1 in vaimo/composer-patches format
@package magento/framework
@level 4
@version >=103.0.6 <103.0.7
diff --git a/vendor/magento/framework/App/DeploymentConfig.php b/vendor/magento/framework/App/DeploymentConfig.php
index 6713baa3a1d..64f32d5516b 100644
--- a/vendor/magento/framework/App/DeploymentConfig.php
+++ b/vendor/magento/framework/App/DeploymentConfig.php
@@ -51,6 +51,16 @@ class DeploymentConfig
*/
@peterjaap
peterjaap / n8n.php
Created March 28, 2023 12:34
Deployer task n8n webhook to update PHP packages Airtable. Set the webhook URL to the env var N8N_WEBHOOK_PACKAGES
<?php
desc('Send the composer.lock file to our n8n endpoint to save package information in our overview');
task('update-packages-overview', function () {
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => getenv('N8N_WEBHOOK_PACKAGES'),
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POSTFIELDS => file_get_contents('composer.lock'),
@peterjaap
peterjaap / PHP_packages_composer_lock_Magento_projects.json
Last active March 30, 2023 09:31
N8N.io Workflow PHP packages composer.lock Magento projects
{
"name": "PHP packages composer.lock Magento projects",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "24577e32-bda2-48d3-9721-509294f9cc89",
"options": {}
},
"id": "525eb7eb-bdcb-4a47-a5a1-dc84d166c8a3",
@peterjaap
peterjaap / varnish6.vcl
Last active October 25, 2024 14:52
Updated Magento 2 Varnish 6 VCL, in cooperation with Varnish Software
# A number of these changes come form the following PR's; , combines changes in https://github.com/magento/magento2/pull/29360, https://github.com/magento/magento2/pull/28944 and https://github.com/magento/magento2/pull/28894, https://github.com/magento/magento2/pull/35228, https://github.com/magento/magento2/pull/36524, https://github.com/magento/magento2/pull/34323
# VCL version 5.0 is not supported so it should be 4.0 even though actually used Varnish version is 6
vcl 4.1;
import std;
# The minimal Varnish version is 6.0
# For SSL offloading, pass the following header in your proxy server or load balancer: '/* {{ ssl_offloaded_header }} */: https'
backend default {
.host = "/* {{ host }} */";
@peterjaap
peterjaap / server.security-txt
Last active October 31, 2024 11:53
Nginx rules for security.txt on Hypernode
# ~/nginx/server.security-txt
# Make Magento 2.4.x's security.txt available to the world
rewrite ^/.well-known/security.txt$ /securitytxt/index/securitytxt last;
rewrite ^/security.txt$ /securitytxt/index/securitytxt last;
@peterjaap
peterjaap / fix-order-invoice-confirmation-email-item-grid.sql
Last active November 9, 2022 19:35
These queries fix the order item list in customized order/invoice email templates. Basically you need to change order to order_id and invoice to invoice_id and add area="frontend" if it's not set. Check whether you need to fix it with the SELECT queries, run the UPDATE queries to fix them.
SELECT COUNT(*) FROM email_template WHERE template_text LIKE '%order=%';
SELECT COUNT(*) FROM email_template WHERE template_text LIKE '%invoice=%';
SELECT COUNT(*) FROM email_template WHERE template_text LIKE '%sales_email_order_items%' AND template_text NOT LIKE '%area="frontend"%';
SELECT COUNT(*) FROM email_template WHERE template_text LIKE '%sales_email_order_invoice_items%' AND template_text NOT LIKE '%area="frontend"%';
UPDATE email_template SET template_text = REPLACE(template_text, "order=$order", "order_id=$order_id") WHERE template_text LIKE '%order=%';
UPDATE email_template SET template_text = REPLACE(template_text, "invoice=$invoice", "invoice_id=$invoice_id") WHERE template_text LIKE '%invoice=%';
UPDATE email_template SET template_text = REPLACE(template_text, 'handle="sales_email_order_items"', 'area="frontend" handle="sales_email_order_items"') WHERE template_text LIKE '%sales_email_order_items%' AND template_text NOT LIKE '%area="frontend"%';
UPDATE email_template SET template_text = REPLACE
@peterjaap
peterjaap / Elastic-no-msi.patch
Created October 22, 2022 14:35
Patch elastic suite without msi
Removed dependency on MSI modules
@package smile/elasticsuite
@link https://github.com/Smile-SA/elasticsuite/issues/1222
diff --git src/module-elasticsuite-catalog/Model/Product/Indexer/Fulltext/Datasource/InventoryData.php src/module-elasticsuite-catalog/Model/Product/Indexer/Fulltext/Datasource/InventoryData.php
index ca4557d..f07e059 100644
--- src/module-elasticsuite-catalog/Model/Product/Indexer/Fulltext/Datasource/InventoryData.php
+++ src/module-elasticsuite-catalog/Model/Product/Indexer/Fulltext/Datasource/InventoryData.php
@@ -14,7 +14,6 @@