Skip to content

Instantly share code, notes, and snippets.

View mttjohnson's full-sized avatar

Matt Johnson mttjohnson

View GitHub Profile
@mttjohnson
mttjohnson / arduino_student_kit_class.md
Last active April 10, 2022 20:52
Intro to Programming and Electronics - Sycamore Club Class

Intro to Programming and Electronics - Sycamore Club Class

Arduino Student Kit February-April 2022 lead by Matt Johnson

Intro Description

Arduino Student Kit

@mttjohnson
mttjohnson / web_dev_intro.md
Last active December 26, 2021 20:19
Web Development Intro
@mttjohnson
mttjohnson / shell_prompt_config.sh
Last active October 27, 2022 21:27
shell prompt config (zsh, bash)
# ZSH - ~/.zshrc
# Luke's config for the Zoomer Shell (https://gist.github.com/LukeSmithxyz/e62f26e55ea8b0ed41a65912fbebbe52)
autoload -U colors && colors
PS1="%B%{$fg[red]%}[%{$fg[yellow]%}%n%{$fg[green]%}@%{$fg[blue]%}%M %{$fg[magenta]%}%~%{$fg[red]%}]%{$reset_color%}$%b "
PS1='$("$POWERLINE_COMMAND" $=POWERLINE_COMMAND_ARGS shell aboveleft -r .zsh --last-exit-code=$? --last-pipe-status="$pipestatus" --renderer-arg="client_id=$$" --renderer-arg="shortened_path=${(%):-%~}" --jobnum=$_POWERLINE_JOBNUM --renderer-arg="mode=$_POWERLINE_MODE" --renderer-arg="default_mode=$_POWERLINE_DEFAULT_MODE" --width=$(( ${COLUMNS:-$(_powerline_columns_fallback)} - ${ZLE_RPROMPT_INDENT:-1} )))'
# BASH - ~/.bash_profile
PS1="\[\033[0;5m\]\u@\h\[\033[0m\]:\@:\[\033[0;31m\]\w\[\033[0m\]#"
PS1="\[\033[0;36m\]\u@\h\[\033[0m\]:\@:\[\033[0;37m\]\w\[\033[0m\]$"
@mttjohnson
mttjohnson / ssh_config_notes
Created October 29, 2021 15:19
ssh config examples - multiple identity files
AddKeysToAgent ask
# Managing multiple github keys with host entries and defaults with exclusions
# Test with:
# ssh -T git@asdf
# ssh -T git@github.com
Host github.com
UseKeychain yes
AddKeysToAgent yes
IdentityFile ~/.ssh/id_rsa
@mttjohnson
mttjohnson / validate_ssh_key.sh
Last active February 1, 2023 05:49
Validating ssh keys
# When you SSH into a server for the first time it prompts you if you trust the remote server's host key
# To validate that they key you received is the same as the server you just logged into you can check
# the fingerprint of the host key on the remote server itself.
# Output fingerprint of system's host key
ssh-keygen -l -f /etc/ssh/ssh_host_ecdsa_key.pub
# You can fingerprint both the private and public key from a file
# They should both produce the same fingerprint value.
ssh-keygen -l -f ~/.ssh/id_ed25519.pub
@mttjohnson
mttjohnson / detect_php_encoded_files.sh
Last active May 20, 2021 16:04
Detect PHP Encoded Files (ionCube / Source Guardian)
# Detect Source Guardian encoded files search for 'sg_load(' in php encoded files
# Detect ionCube encoded files search for 'ioncube_loader_' in php encoded files
@mttjohnson
mttjohnson / check_postgres_ssl_cert.sh
Created April 23, 2021 15:44
Check Postgres SSL Cert
# Heroku Postgres spins up instances that could be using self-signed certificates
# You can view the details of a Postgres certificate to validate it
openssl version
# version 1.1.1+ supports postgres client connections
# RHEL 8 / CentOS 8 should have a new enough version of openssl
# macOS 11 uses LibreSSL and does not have support for this
POSTGRES_HOST="my_postgres_db.lan"
POSTGRES_PORT="5432"
@mttjohnson
mttjohnson / magento2_order_by_date_hour.sql
Created April 22, 2021 22:17
Magento 2 - Order Count by Date/Hour
-- Magento 2 Order Summary by date/hour
select date_format( created_at, '%Y-%m-%d %H:00' ) date_hour,
count(*) order_count
from sales_order o
where o.created_at > '2021-01-01' and o.created_at < '2021-04-10'
group by date_format( created_at, '%Y%m%d%H' )
having order_count > 100
order by order_count desc;
@mttjohnson
mttjohnson / color_code_files.sh
Last active January 28, 2023 22:40
Colorize code files on shell
# Install Pygments (https://pygments.org/)
pip install Pygments
brew install pygments
# XML
cat myfile.xml | xmllint --format - | pygmentize -l xml
# JSON
cat myfile.json | jq . | pygmentize -l json
@mttjohnson
mttjohnson / find_non_innodb_tables.sql
Created March 8, 2021 17:51
Find non-transactional (not innodb) tables in MySQL database
SELECT
TABLE_NAME,
ENGINE
FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA='xxxxxx_database_name_here_xxxxxx'
and ENGINE != 'InnoDB';