Skip to content

Instantly share code, notes, and snippets.

View ScriptAutomate's full-sized avatar
:shipit:
Automating All The Things

Derek Ardolf ScriptAutomate

:shipit:
Automating All The Things
View GitHub Profile
@ScriptAutomate
ScriptAutomate / pyenv-root.sls
Last active August 27, 2021 21:45
Install pyenv in root home on container
# Prereqs recommended for building Python
## ref: https://github.com/pyenv/pyenv/wiki#suggested-build-environment
## Ubuntu/Debian/Mint (includes Pop!_OS, Kali, etc.)
pyenv-prereq-pkgs:
pkg.installed:
- pkgs:
- git
- make
- build-essential
- libssl-dev
@ScriptAutomate
ScriptAutomate / pyenv.sls
Last active March 5, 2022 11:45
Configure pyenv with salt state
# This is tested/verified on Pop!_OS 20.04 and 20.10
# Older versions tested on Parrot OS 4.1.0
# This example state requires common:lookup:user value in a pillar file
{% set user_name = salt['pillar.get']('common:lookup:user') %}
# Prereqs recommended for building Python
## ref: https://github.com/pyenv/pyenv/wiki#suggested-build-environment
## Ubuntu/Debian/Mint (includes Pop!_OS, Kali, etc.)
pyenv-prereq-pkgs:
pkg.installed:
@ScriptAutomate
ScriptAutomate / replacer.py
Last active August 27, 2021 21:48
Replace literal strings in files via Python
"""
Replace tool
Source: https://superuser.com/questions/422459/substitution-in-text-file-without-regular-expressions
"""
import re
import sys
search_term = sys.argv[1]
replace_term = sys.argv[2]
target_file = sys.argv[3]
@ScriptAutomate
ScriptAutomate / audit-automodules.sh
Last active August 27, 2021 21:49
Search for automodule docs generations, in Python projects, that are referrencing non-existant files in Salt repo
AUTOMODULES=`grep -rn ".. automodule:: " doc/ | grep -v "_templates" | cut -d' ' -f3`
for MODULE in $AUTOMODULES; do
MODULE_FILE="$(echo $MODULE | sed 's:\.:\/:g').py"
if [[ ! -f "$MODULE_FILE" ]]; then
echo "$MODULE_FILE"
echo "--------"
echo "ERROR: Attempting to import $MODULE_FILE, which does not exist."
fi
done
@ScriptAutomate
ScriptAutomate / git-cheat-codes.md
Last active June 7, 2022 08:55
GitHub, GitLab, and git: Cheat codes

GitHub, GitLab, and git: Cheat codes

GitHub: Reviewing PRs with tons of modified files and Load diff buttons

For those doomed to try reviewing a major amount of diffs in GitHub for a single PR:

  • Scroll down the entire list of changes so that GitHub loads all of the collapsible boxes associated with all of the changes
  • Open up the inspector/console in the browser devtools. This is probably accessed easily with ctrl+i. We want to be in the Console, which in Firefox is ctrl+shift+k.
  • Type in the following to expand all diffs, in order to avoid needing to click on hundreds of Load diff buttons:
@ScriptAutomate
ScriptAutomate / keybase.md
Created January 3, 2021 07:15
Keybase.io Identity Proof

Keybase proof

I hereby claim:

  • I am scriptautomate on github.
  • I am cantevenio (https://keybase.io/cantevenio) on keybase.
  • I have a public key ASD2q_ML80IcjJJlhOrHxOPUwiX1KbX6-71DZXIMlye-jwo

To claim this, I am signing this object:

@ScriptAutomate
ScriptAutomate / gh-delete-auditor.sh
Last active May 22, 2024 02:49
Provided a PR that is deleting files from a project, checks all other open PRs to see what PRs may be impacted
#!/usr/bin/env bash
# Wraps around GitHub CLI (gh): https://cli.github.com/
# Check all other open PRs that are working on
# files being deleted by the target PR.
# Usage:
# ./gh-delete-auditor.sh <PR>
#
# Example:
# ./gh-delete-auditor.sh 57645
@ScriptAutomate
ScriptAutomate / install-salt-py3.sh
Created December 13, 2020 06:58
Install Latest Python 3 version of Salt on Manjaro Linux
#!/usr/bin/env bash
# By default, Manjaro seems to only have 2019.2.7
# Python 2 variant available for installation via pacman.
# Following the install directions doesn't work as expected, for latest:
# https://docs.saltstack.com/en/latest/topics/installation/arch.html
cd ~/Downloads
sudo pacman -S base-devel --noconfirm
wget https://aur.archlinux.org/cgit/aur.git/snapshot/salt-py3.tar.gz
tar xf salt-py3.tar.gz
@ScriptAutomate
ScriptAutomate / Install-ChocoStarterPackages.ps1
Last active May 22, 2024 02:38
Install Chocolatey on Windows 10 or 11 via PowerShell w/ Some Starter Packages
<#
Simple, nice bootstrap to get Windows 10 up-and-running with nice setup!
- Installs chocolatey (choco)
- Installs common software
I highly recommend Windows Subsystem for Linux (WSL), also, which is covered in
a separate gist. It also has a choco command for installing Docker Desktop after:
- https://gist.github.com/ScriptAutomate/f94cd44dacd0f420fae65414e717212d
#>
@ScriptAutomate
ScriptAutomate / Install-WSLAndUbuntu.ps1
Last active October 3, 2024 15:50
Enable WSL and Install Ubuntu 24.04 (or 22.04 / 20.04)
<#
- BIOS of host machine also needs to be configured to allow hardware virtualization
- Windows 10 Pro or otherwise is needed; Windows 10 Home Edition CANNOT get WSL
- This gist WSLv2, but can use WSLv1 instead. I needed v1 as I run Windows 10 in a VM in Virtualbox.
- WSLv2 has been giving me problems in Virtualbox 6.1, but WSLv1 works properly.
- vbox has issues with the GUI settings when it comes to nested virtualization on certain systems,
so run the following if needing to give a VM this enabled setting:
VBoxManage modifyvm <vm-name> --nested-hw-virt on
#>