This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Display all ansible facts from remote machines | |
ansible -i inventories/example all -m setup | |
# Write value to json file | |
TEMP_PLAYBOOK_FILE="TEMP_PLAY.yml" | |
PLAYBOOK_CONTENTS=$(cat <<'CONTENTS_HEREDOC' | |
--- | |
- hosts: all |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Magento 2 Sandbox Snippet - You can copy and paste into any shell in a Magento root directory | |
# Extended: https://docs.classyllama.net/disciplines/engineering/magento/sandbox-file-m2 | |
set +H # disable history expansion | |
PHP_CODE=$(cat <<'PHP_CODE' | |
<?php | |
header('Content-type: text/plain'); | |
require __DIR__ . '/app/bootstrap.php'; | |
$bootstrap = \Magento\Framework\App\Bootstrap::create(BP, $_SERVER); | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Comment out all load_from_slave entries in env.php | |
PERL_COMMANDS=$(cat <<'PERL_HEREDOC' | |
s/^(\s*)(?='load_from_slave')(.*)$/$1#$2/;print | |
PERL_HEREDOC | |
) | |
ENV_PHP=$(cat app/etc/env.php | perl -nle ${PERL_COMMANDS}) | |
echo "${ENV_PHP}" > app/etc/env.php | |
# Uncomment all load_from_slave entries in env.php | |
PERL_COMMANDS=$(cat <<'PERL_HEREDOC' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Yesterday's and today's access log | |
# Filter to only show place order actions submitting payment requests that fail (400) or not | |
# get a count of the number of events in the logs | |
cat $(find . -regex '.*/www-prod_backend-access\.log-[0-9]+' -print0) www-prod_backend-access.log \ | |
| grep -E 'POST \/rest\/[A-Za-z0-9_]+\/V1\/guest-carts\/[A-Za-z0-9]*\/payment-information HTTP\/[1-2]\.[0-1]" 400' \ | |
| wc -l | |
cat $(find . -regex '.*/www-prod_backend-access\.log-[0-9]+' -print0) www-prod_backend-access.log \ | |
| grep -E 'POST \/rest\/[A-Za-z0-9_]+\/V1\/guest-carts\/[A-Za-z0-9]*\/payment-information HTTP\/[1-2]\.[0-1]" [^4]00' \ | |
| wc -l |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eu | |
# Add configs values to env.php | |
echo "Add configs values programmatically to env.php" | |
set +H # disable history expansion | |
PHP_CODE=$(cat <<'PHP_CODE' | |
<?php | |
$existing_env = include("app/etc/env.php"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* dangerous_functions.php | |
* Perry Holden <[email protected]> | |
* | |
* Usage: php dangerous_functions.php [type: folder|file] [folder_or_filename] | |
* Example: php dangerous_functions.php folder vendor/businessname/module-name | |
*/ | |
if (!isset($argv[1])) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# These examples provide some simple and quick ways to experiment | |
# with the differences between PHP curl requests and using the | |
# curl command from a bash shell or script. The commands are arranged | |
# so they can be easily copy and pasted into a shell for experimenting. | |
# Use netcat listening locally for testing running netcat from one | |
# shell and execute the client requests from a separate shell. This | |
# can be useful to see newline characters and any additional characters |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# This script crawls all urls in a /sitemap.xml file and loads them, effectively priming the cache | |
# Usage: ./warm_cache.sh www.example.com | |
time wget --quiet https://$1/sitemap.xml --output-document - | \ | |
egrep -o "https?://[^<]+" | \ | |
grep $1 | \ | |
grep -v "jpg" | \ | |
xargs -i -d '\n' curl --output /dev/null --silent --write-out '%{http_code} %{time_total}ms %{url_effective} \n' {} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example for CRONTAB_ENTRIES | |
# This is useful for testing scenarios | |
set +H # disable history expansion | |
CRONTAB_ENTRIES=$(cat <<CONTENTS_HEREDOC | |
# Edit this file to introduce tasks to be run by cron. | |
# | |
# Each task to run has to be defined through a single line | |
# indicating with different fields when the task will be run | |
# and what command to run for the task | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# View system limit configurations | |
cat /etc/security/limits.conf | |
# There may be overrides to limits in limits.d | |
cat /etc/security/limits.d/90-nproc.conf | |
# find active number of file descriptors per user | |
ps -A x | grep [w]ww-prod | awk '{print $1}' | xargs -I '{}' ls /proc/{}/fd | wc -l | |
# Alternate count of file decriptors |