Skip to content

Instantly share code, notes, and snippets.

@sjb9774
sjb9774 / elasticsearch.sh
Last active February 25, 2021 21:11
ElasticSearch CURL Commands
ES_HOST='elasticsearch-host' # for example 127.0.0.1
ES_PORT='elasticsearch-port' # default 9200
# get indices
curl $ES_HOST:$ES_PORT/_cat/indices
ES_INDEX='index-name'
# get first 5 results from empty
curl $ES_HOST:$ES_PORT/$ES_INDEX/_search | jq .
@mttjohnson
mttjohnson / parse_nginx_web_request_access_logs.sh
Last active November 10, 2021 00:00
Parsing nginx web request access logs
# 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
@erikhansen
erikhansen / sync_prod_to_stage.sh
Last active November 11, 2022 23:31
Magento 2 script to push DB and `pub/media` changes from prod>stage
#!/bin/bash
# stop on errors
set -e
# turn on debugging if you're running into issues
#set -x
# Static variables
ENVIRONMENT=$1
RED='\033[0;31m'
NC='\033[0m' # No Color
@ericthehacker
ericthehacker / install-source-guardian-php70.sh
Last active October 16, 2019 19:34
Install source guardian on web70 VM
#!/bin/bash
# This quick and dirty script installs the Source Guardian loader on the web70 VM.
# Similar commands should work on other version of PHP -- simply replace the .lin file copied and the .ini file with the correct version.
cd /tmp
wget https://www.sourceguardian.com/loaders/download/loaders.linux-x86_64.tar.gz -O ./source-guardian.tgz
mkdir source-guardian
@mttjohnson
mttjohnson / web_request_performance_timing.sh
Last active May 14, 2024 08:00
Web (Curl) Request Performance Timing (with HTTPS DNS resolver caching to alternate hosts)
# Some output format parameters require newer versions of curl
# These examples were done with Curl 7.54.0 with HTTP/2 Support
# The kind of output you would expect to see with the two functions here (time_url and url_ping) would look like this:
[user@683dd22606f5 /]# URL_TO_CHECK="https://venia.magento.com/graphql?query=query+getProductDetailForProductPage..."
[user@683dd22606f5 /]# time_url "${URL_TO_CHECK}"
@mttjohnson
mttjohnson / mysql_drop_all_db_contents.sh
Last active November 30, 2020 22:27
mysql drop all tables views triggers routines events
#!/usr/bin/env bash
set -eu
if [ $# -ne 1 ]
then
echo "Usage: $0 {MySQL-Database-Name}"
echo "Drops all tables, views, triggers, routines, and events from a MySQL database"
echo "This script expects mysql client credentials to be supplied in a user's .my.cnf"
exit 1