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 / clean-core-config-data-duplicate-values.sql
Last active June 7, 2022 08:49
Delete core_config_data values where the fallback value in scope 0 is the same
DELETE FROM core_config_data WHERE config_id IN (SELECT config_id
FROM (SELECT DUPS.*
FROM core_config_data ORIG
LEFT JOIN core_config_data DUPS
ON ORIG.path = DUPS.path AND (ORIG.value = DUPS.value OR (ORIG.value IS NULL AND DUPS.value IS NULL))
AND DUPS.scope != "default" AND DUPS.scope_id != 0
WHERE ORIG.scope = "default"
AND ORIG.scope_id = 0
AND DUPS.path IS NOT NULL) as tmp)
@peterjaap
peterjaap / run-profile.php
Created May 22, 2021 18:42
Run Magento export profile CLI
<?php
set_time_limit(0);
//THIS SCRIPT JUST INITIALS THE PROFILE TO BE RUN VIA MAGENTO ADMIN "RUN PROFILE IN POPUP". Its the same thing as click just via this file that you can run via cron
$profileId = $argv[1]; // SYSTEM - IMPORT/EXPORT - DATAFLOW PROFILES PROFILES <-- you need to go into your magento admin and grab the exact profile ID
require_once 'app/Mage.php';
umask(0);
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
find app/design/frontend/Limburgia/default -maxdepth 1 -type d | grep -vE "web|etc|i18n|media"
app/design/frontend/Limburgia/default
app/design/frontend/Limburgia/default/Magento_Customer
app/design/frontend/Limburgia/default/Magento_ConfigurableProduct
app/design/frontend/Limburgia/default/Magento_LayeredNavigation
app/design/frontend/Limburgia/default/Magento_ReCaptchaCustomer
app/design/frontend/Limburgia/default/Magento_Wishlist
app/design/frontend/Limburgia/default/Magento_Checkout
app/design/frontend/Limburgia/default/Magento_CatalogSearch
app/design/frontend/Limburgia/default/Magento_Tax
{
"exception":{
"values":[
{
"type":"ReferenceError",
"value":"Unable to process binding \"if: function(){return isMsrpApplicable($row()) }\"\nMessage: isMsrpApplicable is not defined",
"stacktrace":{
"frames":[
{
"colno":30,
@peterjaap
peterjaap / hypernode-incident-quick-analysis.md
Created December 18, 2020 18:39
Hypernode incident quick analysis

Quick analysis script to check an incident.

Script

#!/bin/bash
echo "Quick analysis incident $1"
echo "\nTCP connections from specific IPs"
cat $1/*tcp-connections.txt | grep -v 127.0.0.1 | awk '{print $5}'  | cut -d ':' -f1 | sort | uniq -c | sort -n | tail -n 20
echo "\nCPU-intensive processes:"
sort -nk4 $1/*process-list.txt | tail -n3
@peterjaap
peterjaap / purge-imgix.md
Created December 16, 2020 13:17
Purge Imgix through bash function

Put this in your ~/.zshrc. Be sure to have your API token in IMGIX_API_TOKEN;

export IMGIX_API_TOKEN=yourtokenhere
purge() {
  URL=$1
 echo "Purging ${URL}"
@peterjaap
peterjaap / tailwind-font-weights-check.md
Last active December 16, 2020 11:20
Tailwind font-weights check

Tailwind font-weights check

Check which font weights are used. I used this to determine which Google Fonts I want to include.

Before;

https://fonts.googleapis.com/css2?family=Lato:wght@100;200;300;400;500;600;700;800;900&display=swap
@peterjaap
peterjaap / lighthouse-locally.md
Last active December 15, 2020 09:26
Run Lighthouse locally

Run Lighthouse locally

You only need Docker installed. Add to ~/.zshrc, or ~/.bashrc, or whatever you're using;

lh() {
  mkdir -p lighthouse && \
  docker run --rm -it -v "$PWD":/usr/src -w /usr/src markhobson/node-chrome /bin/bash -c "npm i -g lighthouse && lighthouse --enable-error-reporting --chrome-flags=\"--headless --no-sandbox\" $1 --output html --output-path ./lighthouse/index.html" && \
  open lighthouse/index.html
}
@peterjaap
peterjaap / .dbdiff
Created November 30, 2020 12:42
dbdiff config file for M2 - see https://github.com/DBDiff/DBDiff
server1:
user: peterjaap
password:
port: 3306
host: db
server2:
user: peterjaap
password:
port: 3306
host: db
@peterjaap
peterjaap / quick-magento-2-install.sh
Last active September 21, 2023 14:24
Quick Magento 2 install
#!/bin/bash
composer create-project --repository-url=https://repo.magento.com/ magento/project-community-edition magento2
cd magento2
DB_NAME=dbnamehere php bin/magento setup:install --base-url=http://elgentos.magento2.localhost/ --db-host=db --db-name=${DB_NAME} --db-user=peterjaap --admin-firstname=PJ --admin-lastname=Blaakmeer --admin-email=peterjaap@elgentos.nl --admin-user=peterjaap --admin-password=peterjaap123 --language=en_US --currency=EUR --timezone=Europe/Amsterdam --use-rewrites=1 --backend-frontname=admin --amqp-host=rabbitmq --amqp-port=5672 --amqp-user=guest --amqp-password=guest --amqp-virtualhost="/" --search-engine=elasticsearch7 --elasticsearch-host=elasticsearch7 --elasticsearch-port=9200 --elasticsearch-enable-auth=0 --elasticsearch-index-prefix=magento2_${DB_NAME} --elasticsearch-timeout=15 --use-sample-data
php bin/magento deploy:mode:set developer