Skip to content

Instantly share code, notes, and snippets.

@mttjohnson
mttjohnson / m1_extract_redis_session_value.php
Created February 13, 2019 16:53
Extract gzipped redis session value for Magento 1.x
<?php
require_once 'app/Mage.php';
Mage::setIsDeveloperMode(true);
Mage::app();
$credis = new Cm_RedisSession_Model_Session();
@mttjohnson
mttjohnson / curl_testing_web_servers.sh
Created February 12, 2019 00:36
Curl Testing Web Servers
# Curl manual: https://curl.haxx.se/docs/manpage.html
URL="https://www.example.org/"
HTTP_AUTH="-u name:passwd"
CURL_OPT="--trace -"
CURL_OUT="-o /dev/null"
curl -s ${HTTP_AUTH} ${CURL_OPT} ${CURL_OUT} -w "%{http_code} - ${URL}\n" "${URL}"
URL="https://www.example.org/"; HTTP_AUTH=""; CURL_OPT=""; CURL_OUT="-o /dev/null"; \
@mttjohnson
mttjohnson / m2_redis_config_cache.php
Created February 6, 2019 05:04
Magento 2 Separation of Config Cache from default Object Cache Redis Storage
<?php
# You can store a specific cache type separately from the default object cache storage
return [
'cache' => [
'frontend' => [
'default' => [
'backend' => 'Cm_Cache_Backend_Redis',
@mttjohnson
mttjohnson / m1_extract_redis_value.php
Last active January 28, 2019 21:17
Extract gzipped redis value for Magento 1.x cached config
<?php
# Find Magento crontab configs
# redis-cli -p 6379 KEYS \* | grep -i CONFIG_GLOBAL_CRONTAB
# redis-cli -p 6379 hget zc:k:c62_CONFIG_GLOBAL_CRONTAB d
# Find config value from redis object store
# redis-cli -p 6379 KEYS \* | grep -i CONFIG_GLOBAL
# redis-cli -p 6379 HGET zc:k:c62_CONFIG_GLOBAL d
@mttjohnson
mttjohnson / filterstamp
Last active July 10, 2023 19:51
An inline input parser for timestamped and filtered output
#!/usr/bin/env bash
set -eu
########################################
## Introduction
########################################
HELP_INFO=$(cat <<'CONTENTS_HEREDOC'
input_filter v0.1
@mttjohnson
mttjohnson / memcached_monitoring.sh
Created January 22, 2019 20:46
memcached monitoring
# Connect via socket
echo 'stats' | nc -U /var/run/memcached-multi/example.com_sessions.sock
# Connect via TCP port
echo 'stats' | nc localhost 11211
# Get max memory usage limit from stats
echo 'stats' | nc -U /var/run/memcached-multi/example.com_sessions.sock \
| grep ' limit_maxbytes ' \
| cut -d" " -f3
@mttjohnson
mttjohnson / mysql_file_security_testing.sql
Created January 20, 2019 21:15
MySQL File Security Testing
select @@secure_file_priv;
select @@local_infile;
CREATE TABLE load_data_local_infile (
file_id int unsigned not null auto_increment primary key,
content text not null
);
CREATE TABLE load_file (
file_id int unsigned not null auto_increment primary key,
file_name varchar(255) not null,
@mttjohnson
mttjohnson / solr_testing.sh
Created January 18, 2019 21:53
Solr Administration Testing
# Get Solr system info
curl -s http://127.0.0.1:8983/solr/admin/system?wt=json | jq .
# Create tunnel to remote server, and separately send request
ssh -L 8983:127.0.0.1:8983 server_host
curl -s http://127.0.0.1:8983/solr/admin/system?wt=json | jq .
# Create temporary (10 seconds) tunnel in backgorund, then send web request
ssh -f -o ExitOnForwardFailure=yes -L 8983:127.0.0.1:8983 server_host sleep 10
curl -s http://127.0.0.1:8983/solr/admin/system?wt=json | jq .
@mttjohnson
mttjohnson / rpm_tips.sh
Last active January 4, 2019 19:10
RPM Tips (package info and file list)
# Get package information -qip
rpm -qip https://www.percona.com/downloads/percona-release/redhat/0.1-6/percona-release-0.1-6.noarch.rpm
rpm -qip percona-release
# List files in the package
rpm -qlp https://www.percona.com/downloads/percona-release/redhat/0.1-6/percona-release-0.1-6.noarch.rpm
rpm -qlp percona-release
# Install RPM from URL
yum install https://www.percona.com/downloads/percona-release/redhat/0.1-6/percona-release-0.1-6.noarch.rpm