Skip to content

Instantly share code, notes, and snippets.

View vaughany's full-sized avatar
🎢
Operating from an interim headquarters

Paul Vaughan vaughany

🎢
Operating from an interim headquarters
View GitHub Profile
@vaughany
vaughany / gist:ba00088853e352073584a4f7b65dd1cf
Created July 4, 2018 15:17
grep to show all lines and highlight search terms
sudo tail -f /var/log/mail.log | grep -Ei "ATTR35|from=|$"
@vaughany
vaughany / queries.txt
Last active June 22, 2018 10:38
Investigating postgres
\c coach_in_a_box_production
select relname, idx_tup_fetch + seq_tup_read as totalreads, idx_tup_fetch, seq_tup_read
from pg_stat_all_tables
where schemaname = 'public'
order by totalreads desc;
https://www.tutorialspoint.com/postgresql/postgresql_indexes.htm
https://shoaibmir.wordpress.com/2009/09/13/finding-top-read-tables-in-the-database/
@vaughany
vaughany / commands.md
Last active June 12, 2018 12:54
Updating just Passenger

$ passenger-status

Version : 5.2.0

$ sudo apt-get update

$ apt list --upgradable

$ sudo apt-get install --only-upgrade passenger

@vaughany
vaughany / poop.sh
Created June 7, 2018 08:58
For messing around with people...
#!/bin/bash
LOOPS=93
LINES=5
TESTS=0
FAILS=0
CERRORS=0
PASSES=0
@vaughany
vaughany / .bash_aliases
Created June 7, 2018 08:56
Bash aliases
alias poop="~/poop.sh"
alias c="clear"
alias cls="clear"
alias gits="git status"
alias gita="git add ."
alias gitb="git branch -a"
alias gitd="git diff"
alias gitdw="git diff --word-diff"
@vaughany
vaughany / nginx-tls.sh
Last active May 15, 2018 21:12
Shell script to grep all Nginx logs for TLS entries (requires modified nginx.conf script to include `$ssl_protocol/$ssl_cipher` in the access log definition).
#!/bin/bash
# Script to check the versions of TLS clients are connecting to our Nginx proxy with. Written by Paul Vaughan [gist.]github.com/vaughany
# https://gist.github.com/vaughany/48e12cfc0c645cf95eb630fbda34df22
# Many thanks to: https://misc.flogisoft.com/bash/tip_colors_and_formatting
#
# Copy this script to the proxy server and make it executable.
# ssh to the remote server and type: `sudo ./nginx-tls.sh` or run locally via ssh: `ssh 10.10.9.10 sudo ./nginx-tls.sh`
if [[ $EUID -ne 0 ]]; then
@vaughany
vaughany / nginx.conf
Created May 9, 2018 10:35
Nginx log config to log SSL protocols and ciphers.
log_format main '$remote_addr - $ssl_protocol/$ssl_cipher - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
@vaughany
vaughany / Dockerfile
Last active August 24, 2019 09:56
Dockerfile to install Ubuntu, Apache2 and PHP7.2
# A basic apache server with PHP. To use either add or bind mount content under /var/www
# https://docs.docker.com/engine/reference/builder/
FROM ubuntu:16.04
# Use bash instead of sh.
SHELL ["/bin/bash", "-c"]
WORKDIR /app
ADD . /app
@vaughany
vaughany / free-remote.sh
Created January 31, 2018 13:48
Pulls memory stats from servers at IP addresses of your choice.
#!/bin/bash
IPS="10.10.10.10 10.10.10.11 10.10.10.12"
for s in $IPS; do
echo -en "\n\e[7;49m $s - " && echo -n $(ssh -q -F /dev/null $s "hostname") && echo -e ": \e[0m"
RESULT=$(ssh -q -F /dev/null $s "lsb_release -r")
if [[ $RESULT = *"14.04"* ]]
then
ssh -q -F /dev/null $s "free -h"
else
@vaughany
vaughany / Vagrantfile
Last active January 26, 2018 14:56
Vagrantfile for a basic ubuntu 16.04 LTS setup (initially configured for Redis)
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.box_check_update = true
config.vm.define "redis", primary: true do |web|
config.vm.network "forwarded_port", guest: 6379, host: 6379
config.vm.network "private_network", ip: "10.10.10.10"
# config.vm.synced_folder "../data", "/vagrant_data"
config.vm.provider "virtualbox" do |vb|