Skip to content

Instantly share code, notes, and snippets.

View aspen-roller's full-sized avatar

James Roller, Jr. aspen-roller

View GitHub Profile
@aspen-roller
aspen-roller / delete-dirs.sh
Created December 3, 2020 19:50
delete directories by age #util
# delete directories older than 14 days
find . -maxdepth 1 -type d -mtime +14 -exec rm -rf {} \;
@aspen-roller
aspen-roller / list-cronjobs.sh
Created December 3, 2020 19:51
view all cronjobs #util #cron
# RedHat
sudo bash -c 'tail -n +1 /var/spool/cron/*'
# Debian
sudo bash -c 'tail -n +1 /var/spool/cron/crontabs/*'
@aspen-roller
aspen-roller / test-metricbeat.sh
Created December 3, 2020 19:53
debug elasticsearch connection #debug #elasticsearch #metricbeat
# on webserver, testing metricbeat connection to elasticsearch
sudo metricbeat test output -e -d "*"
# metricbeat configuration
sudo vi /etc/metricbeat/metricbeat.yml
@aspen-roller
aspen-roller / recordHeapdump.js
Created December 3, 2020 20:35
automatically record heapdump snapshots in node.js #nodejs #debug #util
'use strict';
/* eslint-disable no-console */
// NOTE: update the debug scope
const debug = require('debug')('recordHeapdump');
const heapdump = require('heapdump');
var interval;
var nextThreshold_MB = 0;
@aspen-roller
aspen-roller / .bash_aliases
Last active December 3, 2020 20:39
hunt for files with grep #util
hunt() {
find ./ -type f -regex "$1" -exec grep -Hn "$2" /dev/null {} +
}
@aspen-roller
aspen-roller / .profile
Last active May 28, 2021 23:28
automatically start ssh-agent #ssh #util
# SSH key must already be created
SSH_ENV=$HOME/.ssh/environment
function start_agent {
echo "Initializing new SSH agent..."
/usr/bin/ssh-agent | sed 's/^echo/#echo/' >| "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
# load all private ssh keys
@aspen-roller
aspen-roller / rename-files.sh
Created December 3, 2020 20:54
rename multiple files #util
# Rename multiple files
# http://www.24hourapps.com/2009/03/linux-tips-10-rename-multiple-files.html
# Renaming multiple files in Linux is surprisingly difficult given the simplistic power
# provided by many other system commands. Unlike DOS, which provided a rename command that
# allowed wild cards, Linux's rename/mv command is less versatile. Therefore to rename files
# one needs to write a loop. Luckily bash helps a lot here.
# Lets say we have in our directory a number of .txt files that we need to rename to .nfo.
# To do this we would need to use the command:
@aspen-roller
aspen-roller / settings.json
Created December 3, 2020 23:06
windows terminal settings #ref #win
// This file was initially generated by Windows Terminal 1.3.2651.0
// It should still be usable in newer versions, but newer versions might have additional
// settings, help text, or changes that you will not see unless you clear this file
// and let us generate a new one for you.
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
@aspen-roller
aspen-roller / .bashrc
Last active December 7, 2020 20:30
python venv for ansible testing #ansible #python
# colorize molecule test outputs
export PY_COLORS=1
# encrypted variables
export ANSIBLE_VAULT_PASSWORD_FILE=~/.ansible/.vault_password
@aspen-roller
aspen-roller / fix_apt_pkg.sh
Created December 7, 2020 21:25
fix could not import python modules: apt apt_pkg #debug #python
# This was done in Ubunut-20.04
# I've observed this in other Ubuntu releases when Python gets updated
# https://github.com/ansible/ansible/issues/14468#issuecomment-459630445
cd /tmp
# download and unarchive python3-apt
apt-get download python3-apt
dpkg -x python3-apt_2.0.0ubuntu0.20.04.1_amd64.deb python3-apt