Skip to content

Instantly share code, notes, and snippets.

@michielgerritsen
michielgerritsen / instructions.md
Last active April 17, 2025 05:44
Find old Luma code so you can convert it to Hyvä Alpine.js code

Introduction

The goal of this script is to help you migrate you old Magento Luma code to Hyvä compliant code. Luma used to rely on Require.js to manage it's javascript components. Hyvä relies on Alpine.js for this. For a lot of modules there are already compatibility modules available. Custom code you have to convert yourself.

Usage

There are several ways to use this code:

  • Using Tampermonkey (Chrome) or Greasemonkey (Firefox). If you have that installed just click on "Raw" by the requirejs-finder.user.js file.
  • (Temporary) By injecting it into Magento's head. Open the admin and navigate to Content -> Design -> Click your theme -> HTML -> Head -> Add `` and place the code above between the two script tags.
@JeroenBoersma
JeroenBoersma / NGINX - Magento 2 Static files optimization.md
Last active September 6, 2024 17:43
NGINX - Magento 2 Static files optimization

Introduction

Because Varnish doesn't support SSL, most people choose a setup where Nginx SSL will forward all traffic to Varnish and Varnish will forward will forward the traffic it cannot handle back to nginx. Or worse, bind Varnish on port 80 and direct all traffic into Varnish. This will already degrade performance, because Varnish will purge more because static files are also taking up room in the cache.

Default configuration

Next up, the Nginx configuration of Magento will handle static files.

@ProxiBlue
ProxiBlue / gist:ad1bc6db0f74e4494f92f94d04423b4b
Last active January 26, 2022 22:06
cypress random test from sitemap.xml that old site and new site match data
Add the following to plugins/index.js
module.exports = (on, config) => {
on('task', {
log (message) {
console.log(message)
return null
}
})
}
@davidalger
davidalger / kubectl-list_images
Last active April 8, 2021 07:14
List all non-Google/GKE/k8s/Stackdriver images in a cluster using fully qualified names and without tags.
#!/usr/bin/env bash
kubectl get all --all-namespaces -o yaml \
| grep \ image: \
| egrep -iv 'image:\ sha256|(gke|k8s)\.gcr\.io|gcr\.io/(gke|google|stackdriver|kubernetes)-.*' \
| perl -pe 's#^[\W-]+image:\W+([^\@:]+)([:@].+)?$#$1#i' \
| perl -pe 's#^([a-z0-9-_]+)$#docker.io/library/$1#i' \
| perl -pe 's#^([a-z0-9-_/]+)$#docker.io/$1#i' \
| sort -n | uniq
@WinstonN
WinstonN / flatten_additional_attributes.py
Last active March 16, 2021 19:58
Flatten additional_attributes from Magento 2 export csv
"""
This script formats a magento product export file, and sets each
additional_attribute as a new column in a target file
"""
import csv
# real files
source_file = './catalog_product_20210316_044037.csv'
target_file = './catalog_product_20210316_044037_formatted.csv'
@hostep
hostep / composer-v2-support-older-magento2-versions.md
Last active February 4, 2025 10:24
Add composer v2 support to older Magento2 versions

Add composer v2 support to older Magento2 versions

Magento 2.3.7 and 2.4.2 ship with composer v2 support out of the box but as far as I can see the only thing that needs to happen is to use some more modern versions of certain composer plugins which are used by certain dependencies of Magento.

This means we should be able to add composer v2 support to older Magento2 versions as well if we get a bit creative.

See below for diffs of the composer.json files you can apply to your projects, be sure to keep a mental note of these things, they will need to maintained by yourself in case newer versions of these modules are released. And if one day you update to Magento 2.3.7 or 2.4.2 or higher, you can remove these changes again.

⚠️ Disclaimer: use these tricks at your own risk!

@magenx
magenx / mage2spam
Last active December 11, 2020 11:24
magento 2 light spammer
#!/bin/bash
curl -k -X POST "$1/rest/V1/customers" \
-H "Content-Type:application/json" \
--data @<(cat <<EOF
{
"customer": {
"extension_attributes": {
"is_subscribed": true
<?php
declare(strict_types=1);
namespace [Namespace]\Core\Plugin;
use Magento\Framework\View\Layout;
use Magento\PageCache\Model\Config;
class LayoutPlugin
{
@gimesi
gimesi / mobile-subnavigation-toggle.html
Last active December 22, 2024 23:50
A navigation menu for mobile with toggle function for sublevel links powered by AlpineJS
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>AlpineJS Mobile Menu with Subnavigation Toggle</title>
<link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet" type="text/css">
<link href="https://cdn.jsdelivr.net/npm/@tailwindcss/ui@latest/dist/tailwind-ui.min.css" rel="stylesheet" type="text/css">
<link href="https://rsms.me/inter/inter.css" rel="stylesheet" type="text/css">
</head>
@PayasR
PayasR / routing_algorithm_implementations.txt
Last active December 25, 2023 08:52 — forked from systemed/gist:be2d6bb242d2fa497b5d93dcafe85f0c
Routing algorithm implementations
**Interesting/widely used implementations of pathfinding algorithms.
==========================================================================
A* Ruby https://github.com/georgian-se/shortest-path
A* (bidirectional with shortcuts) C++ https://github.com/valhalla/valhalla
A* Unity https://arongranberg.com/astar/front
NBA* JS https://github.com/anvaka/ngraph.path
NBA* Java https://github.com/coderodde/GraphSearchPal
NBA* Java https://github.com/coderodde/FunkyPathfinding
NBA* (Parallel) C++ https://github.com/janhsimon/PNBAStar