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 / swapfile.md
Created March 6, 2020 14:03
Configuring swap files and swapiness.

Swap file creation, use and deletion

Info

$ free -h
              total        used        free      shared  buff/cache   available
Mem:            31G        3.8G        7.1G        1.2G         20G         25G
Swap:          979M          0B        979M
@vaughany
vaughany / kill-pulse-vpn.sh
Last active April 26, 2024 13:24
Small script to kill the Pulse VPN service and UI, 'cos they seem to hang sometimes, for no reason.
#!/bin/bash
# Finds and kills the Pulse Secure VPN background service and UI.
if [[ $EUID -ne 0 ]]; then
echo -e "\e[1;41mThis script must be run as root.\e[0m"
exit 1
fi
IDS=$(ps -ax | grep -i 'pulse[ui|svc]' | tr -s ' ' | sed 's/^ *//g' | cut -d ' ' -f 1)
@vaughany
vaughany / .tmux.conf
Last active July 16, 2024 23:03
A shell script to open tmux with a selection of windows and panes.
# Remap prefix from 'C-b' to 'C-a'.
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix
# Reload config file.
bind-key r source-file ~/.tmux.conf\; display ' Reloaded tmux config.'
# Split panes using | and -.
bind-key | split-window -h -c '#{pane_current_path}'
@vaughany
vaughany / check-java.sh
Created October 30, 2019 09:32
JRE and JDK version checker:
#!/bin/bash
# If they're not installed, install with:
# sudo apt-get install default-jre
# sudo apt-get install default-jdk
echo -e "\e[1mJava Runtime Environment:\e[0m"
java --version
echo -e "\n\e[1mJava Development Kit:\e[0m"
@vaughany
vaughany / .bashrc
Created March 20, 2019 11:31
Additions to .bashrc for time and Ansible-devel version.
# Just adding the time to the start of the prompt, so I can tell when a command was run (roughly).
# Colours: https://misc.flogisoft.com/bash/tip_colors_and_formatting
export PS1="\e[2m\A\e[0m $PS1"
# Ansible (2.8 development branch) - comment out to get the regular Ansible version (2.7.8?).
source /home/username/repositories/ansible/hacking/env-setup
@vaughany
vaughany / .garglkrc
Last active January 3, 2019 22:22
Gargoyle-free (interactive fiction player) config file.
#===============================================================================
# Fonts, sizes and spaces
# (Tweak this if you choose other fonts, or want bigger text)
#-------------------------------------------------------------------------------
#
# The 'standard' fonts.
# Omit to use the builtin fonts, or specify a font family.
monofont Liberation Mono
monosize 16
@vaughany
vaughany / gist:23ca93e5642bd1ebf6e335a77cb2d983
Last active December 21, 2018 17:50
Saving ansible-playbook logs
# Requires: sudo apt install expect
$ unbuffer ansible-playbook debug.yml | tee logs/$(date "+%F_%T.%3N").log
# Will produce a filename like: logs/2018-12-21_17:49:57.771.log
@vaughany
vaughany / install_postgres.sh
Created November 21, 2018 12:30
Installing postgres into any version of Ubuntu.
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" >> /etc/apt/sources.list.d/pgdg.list'
sudo wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get install postgresql-10
@vaughany
vaughany / log_min_duration_statement.md
Created October 8, 2018 16:16
Changing Postgres' log_min_duration_statement setting

Changing Postgres' log_min_duration_statement setting on the fly

Check the setting:

SELECT * FROM pg_settings WHERE name = 'log_min_duration_statement';

Change the setting:

SET log_min_duration_statement TO 1000; >

Adding a new user to an Ubuntu Linux machine

Do all this in Bash.

1. Create the new user

Obviously change the username laptop-admin to whatever you like:

$ sudo adduser laptop-admin