Skip to content

Instantly share code, notes, and snippets.

View trevor-vaughan's full-sized avatar

Trevor Vaughan trevor-vaughan

View GitHub Profile
@trevor-vaughan
trevor-vaughan / load_tokens_from_pass.sh
Created November 16, 2022 14:27
Load and clear tokens from pass
# Source this script to load your tokens from `pass` into your current session
#
# Not brilliant but better than having them hang out forever
# Number of seconds to keep your tokens in your session
# Suggest making it slightly random so you don't accidentally kill some other sleep
keep_seconds=1234
function tokens_clear() {
@trevor-vaughan
trevor-vaughan / podman-gui-noroot.sh
Created March 30, 2022 22:40
Podman with non-root GUI
#!/bin/bash
args="${@}"
container=<container>:<release>
uid=$( podman run --rm -it $container id -u | tr -d [:space:] )
gid=$uid
subuidSize=$(( $(podman info --format "{{ range .Host.IDMappings.UIDMap }}+{{.Size }}{{end }}" ) - 1 ));
@trevor-vaughan
trevor-vaughan / memmap_info.rb
Last active September 28, 2021 13:02
Get application and stack size in a form useful for using with pam_limits
#!/usr/bin/ruby
# Get application and stack size in a form useful for using with pam_limits
require 'json'
PAGE_SIZE = %x(getconf PAGESIZE).to_i
UID = Process.uid
mem_info = Hash.new
@trevor-vaughan
trevor-vaughan / container_basedir.sh
Last active January 23, 2021 23:44
Extract a container image and run the container against the underlying directory
#!/bin/sh
set -e
container_name="centos:8"
clean_container_name=$( echo "${container_name}" | tr ':' '_' )
export_file="${clean_container_name}.tar"
if [ -f "${export_file}" ]; then
echo "Found ${export_file}; remove the file to re-extract"
@trevor-vaughan
trevor-vaughan / gen_word_list.sh
Created January 7, 2020 14:17
Generate word list of given lengths from aspell dictionaries
#!/bin/sh
aspell -l en dump master | grep -v "'" | grep -v "^[[:upper:]]" | sort -n | grep -x '.\{3,10\}' > test_dict
@trevor-vaughan
trevor-vaughan / gist:f86f50a5c720543d128285925d5a8f09
Created December 2, 2019 18:25
Tlog syslog file session discovery
ruby -rjson -rpp -e 'output={}; File.read("/var/log/tlog.log").lines.map{|x| l=x.split(/\s/); foo=JSON.load(l[3..-1].join(" ")); output[foo["rec"]] ||= {:user => foo["user"], :start_time => l[0]}; output[foo["rec"]][:end_time] = l[0]}; pp output'
polkit.addRule(function(action, subject) {
if (action.id == "org.libvirt.unix.manage" && subject.local && subject.active && subject.isInGroup("wheel")) {
return polkit.Result.YES;
}
});
@trevor-vaughan
trevor-vaughan / README.md
Created November 26, 2018 19:24 — forked from openscript/README.md
This bash script can be used to encrypt secrets for a Travis CI configuration (`.travis.yml`) with the project specific public key.

Usage

  • Download script travis-encrypt.sh
  • Make it executable chmod +x travis-encrypt.sh
  • Run the script with ./travis-encrypt.sh -r username/repositoryname -e example
    • It will return something like O+woVD9K+PeFrcyu5GCjKSFvfcSPwDW0kyDYEQnNbwt/iSkqjpl2OPA9W//KEKEB9UUSZD+XmQ3Ij0gnvJnOowcWY5sSeJlVEVTrSer0kW6uWpa/uWzDHCBz2YhBnI6u9SfYfMkhDl22pcaCEwaUkmK2gjcVo+v0bS8vAQFz0Na5/WiKj0GkSX50iIGgfaXheuC8KgIC25T0h+czpap7vb13OlblMnClfyTH9+TmAwTlcV7ljXpv1QY+K72L8jK1/CQVZ8quBYrBwwxO2V6cpXRMMCIw4m4lqxUyN4FBGnq7cJ7BWLzeqSMpFBoP+ZxAqS5yem8KLh1VkEo7PVjCkZE6M+2meFf2VJEVUs/KJY9xnH3eDzipWkwXon2qVpCkT7FDEzGFs/DapYsSo7eCO6pUYYhcpaYpWeYV9DSSV0QcrOeZp664iJMHWPSmrs/lESbbHpKWsM/AFVB9X75q/OB+QU0tQxpReZmKw3ZHbDVMlmlwhP8VSiQ05LV2W6gYzADGiUiL6n1X8teeHEVDSZnD7nrxMD/FchnWI5La3tZeFovRMf6hH3NItW+QZaGaGNftJrP488J/F2hCycPJk3+YrxbBCGHE2X379QbkMz3S0B5UiAcJKmwuTstF6X3CCurZVYIkUGGXhnmalPtVpEqxeTiLw5RU6C9z2qSwhhw=
  • Use the encrypted secret in your .travis.yml according to https://docs.travis-ci.com/user/encryption-keys/#Usage
require 'yaml'
require 'nokogiri'
# This is extracted from the DISA STIG content
input_doc = 'U_Red_Hat_Enterprise_Linux_7_STIG_V1R2_Manual-xccdf.xml'
# You have to pull this file out of the STIGViewer Java JAR file
cci_mapping = 'U_CCI_List.xml'
def cci2nist(cci, ccidoc)
@trevor-vaughan
trevor-vaughan / find_symlink_dir_git.rb
Created March 26, 2018 21:42
Find symlinks replaced by directories and the reverse in git