Skip to content

Instantly share code, notes, and snippets.

View erikhansen's full-sized avatar

Erik Hansen erikhansen

View GitHub Profile
@erikhansen
erikhansen / 1_README.md
Last active June 29, 2026 18:21
Connecting Claude Code to New Relic to assist with DDoS/traffic troubleshooting on an Adobe Commerce Cloud environment

Overview

This document is intended to help with fighting off DDoS/bad traffic targeting Adobe Commerce Cloud sites.

With Adobe Commerce Cloud, all server access logs are streamed from the web server(s) to New Relic. This means it's not possible to pull the log files directly from the server an analyze them like you would be able to on a traditional hosting environment.

To overcome this, you can use a combination of New Relic MCP and a New Relic User API Key to download all traffic data and then use Claude Code to analyze the traffic for problematic patterns.

Note: If you have New Relic sitting in front of Adobe Commerce Cloud, make sure you are forwarding user IP addresses.

@erikhansen
erikhansen / readme.md
Last active June 29, 2026 19:27
Adobe Commerce Cloud w/ Cloudfare VCL configuration

Overview

We (Kraken Commerce) recommend using Cloudflare in front of Adobe Commerce Cloud environments, as Cloudflare provides excellent bot-fighting and performance tools. However a small change is needed in the Magento VCL to pass the user's IP from Cloudflare>Fastly/Varnish>Nginx so that user's IPs are stored in the access logs correct.

Steps:

  1. Login to the Magento admin and go to STORES > Configuration > ADVANCED > System and expand the Full Page Cache > Fastly Configuration > Custom VCL Snippets section.
  2. Click the "Create" button and add this information:
    1. Name: forward_client_ip (or whatever you want to call it)
    2. Type: recv
@erikhansen
erikhansen / issue_report.md
Last active December 5, 2025 21:25
Issue Report Best Practices

Use the format below to document issues. Use screenshots and/or screen recording when necessary, using a tool like Monosnap.

Summary

TODO: write a summary of the issue.

Steps to reproduce

  1. TODO Describe steps needed to trigger the issue.
@erikhansen
erikhansen / guide.md
Last active August 6, 2025 15:49
Kraken screenshot recommendation

Screenshot best practices

  1. If taking a screenshot of a website, always include the url in the screenshot (or the full application, if not a website). This gives the viewer full context for what they are looking at.
  2. Use annotations (arrows or a box) to draw attention to the relevant part of the screenshot
  3. Blur any sensitive information

Examples

474726596-b6e1dfd0-31db-4412-b1a7-92ed1e5a65d7

@erikhansen
erikhansen / run_in_console.js
Created June 6, 2024 17:12
Force ReCaptcha to be invalid before submitting a form—for testing purposes
document.querySelectorAll("[name='g-recaptcha-response'], [name='token']").forEach(function(element) {
element.value = 'bad-recaptcha-token';
});
@erikhansen
erikhansen / gist:d80b54dca751d92a585fea84651fbac3
Created March 6, 2024 16:33
module-shipper-show-company-name-in-addresses-in-checkout.patch
Index:/src/view/frontend/web/template/shipping-address/address-renderer/default.html
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/view/frontend/web/template/shipping-address/address-renderer/default.html b/src/view/frontend/web/template/shipping-address/address-renderer/default.html
--- a/src/view/frontend/web/template/shipping-address/address-renderer/default.html
+++ b/src/view/frontend/web/template/shipping-address/address-renderer/default.html (date 1709742374536)
@@ -11,6 +11,11 @@
<div class="shipping-address-item" css="'selected-item' : isSelected() , 'not-selected-item':!isSelected()">
@erikhansen
erikhansen / README.md
Last active March 25, 2025 17:42
Troubleshoot long-running PHP script in Magento 2 on Warden

For future reference:

I just had to troubleshoot a script that ran so long that it eventually died without any relevant errors ([pid 6048:tid 139809649469184] (104)Connection reset by peer: [client 184.4.89.70:0] FastCGI: comm with server "/var/run/a49982b9-remi-safe-php81.fcgi" aborted: read failed, referer was getting written to the Apache error logs).

Thankfully I was able to reproduce the issue locally. Here are the steps I took in Warden to troubleshoot:

In pub/index.php I added this line: set_time_limit(15); above the $bootstrap->run($app);

cd <PATH TO MAGENTO 2 DIRECTORY>
@erikhansen
erikhansen / _README.md
Last active July 28, 2023 02:08
MacOS Automator Script to export list of on-premise Jira issues to PDF

Instructions

This document covers how to export Jira tickets to PDF from the on-premise version of Jira. For the cloud version of Jira, you can write a script to download Word versions of each issue (e.g., https://krakencommerce.atlassian.net/si/jira.issueviews:issue-word/DMC-95/DMC-95.doc) and you don't need this approach.

  1. Prepare a text file containing all urls of the Jira issues you want to export. For example:
https://krakencommerce.atlassian.net/browse/DMC-1
https://krakencommerce.atlassian.net/browse/DMC-2
@erikhansen
erikhansen / warmer-cron.sh
Created August 4, 2020 16:54 — forked from davidalger/warmer-cron.sh
Script to crawl and warm the cache two levels deep on Magento demo Pods via CronJob spec
#!/bin/bash
set -euo pipefail
FRONT_URL="${FRONT_URL:-https://app.exampleproject.test/}"
echo "==> [$(date +%H:%M:%S)] waiting on readiness"
ELAPSED_SECONDS=0
while : ; do
ELAPSED_SECONDS=$(echo ${ELAPSED_SECONDS}+2 | bc)
RESPONSE_CODE=$(curl -sI "${FRONT_URL}" 2>/dev/null | head -n1 | awk '{print $2}')
@erikhansen
erikhansen / README.md
Last active July 15, 2020 20:14
Issue with using flock with Magento's cron

Overview

This applies to Magento 2.3+.

If you have your crontab configured to run the bin/magento cron:run command using flock, you should either:

  • Remove flock, since it's technically not necessary as of Magento 2.3.2
  • Pass the -o command to flock, as this will prevent the indefinitely running bin/magento queue:consumers:start processes spawned by bin/magento cron:run from holding a lock when they shouldn't be.

Before: