Skip to content

Instantly share code, notes, and snippets.

View derekmurawsky's full-sized avatar

Derek Murawsky derekmurawsky

View GitHub Profile
@derekmurawsky
derekmurawsky / clean_common_dependencies.sh
Last active September 6, 2024 17:42
A simple cleanup script that looks for common local dependency caches below your current directory and deletes them
#!/bin/bash
find . -name '.yarn' -type d -prune -exec rm -rf '{}' +
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' +
# Note: There may be things to consider with deleting the .terraform directory. For me, this works
# but think through it for you're use case. https://developer.hashicorp.com/terraform/cli/init#working-directory-contents
find . -name '.terraform' -type d -prune -exec rm -rf '{}' +
@derekmurawsky
derekmurawsky / git-backup.sh
Created September 6, 2024 17:09
A simple git repo backup script. It can back up a list of git repos with the -m option, or update a list of already mirrored directories with the -u option.
#!/bin/bash
# This simple script backs up all the repositories in a list
# To generate the list, you can do something like the following:
# gh repo list [org_name] --limit [limit] --json nameWithOwner --jq '.[] | "https://github.com/"+.nameWithOwner+".git"' >> git_urls.txt
# Then you can use this script to run a `git clone --mirror` for each repository in the list
# To get a worktree from the repobackup, run `git clone mirrored_repository normal_repository`
while getopts "hum" option; do
case $option in
h) # display Help
@derekmurawsky
derekmurawsky / setuplldp.sh
Created June 5, 2024 21:21
Set up LLDP on Pi running Ubuntu
#!/bin/bash
# This script installs LLDP in ubuntu systems. It should be run as root.
# It is based on the install notes from: https://enterprise-support.nvidia.com/s/article/howto-enable-lldp-on-linux-servers-for-link-discovery
TARGET_INTERFACE=eth0
apt-get -y install lldpad
lldptool set-lldp -i $TARGET_INTERFACE adminStatus=rxtx
lldptool -T -i $TARGET_INTERFACE -V sysName enableTx=yes
@derekmurawsky
derekmurawsky / pushAwsSecrets.sh
Last active May 30, 2024 20:34
Bash script to push secrets to multiple AWS accounts based on configured CLI profiles.
#!/bin/bash
# This script pushes secrets to multiple AWS accounts. It should be used with IAC where IAC creates the secret for this script to push to.
# This ensures that IAC knows where the secrets are stored, but that the secrets themselves can be managed by a separate process.
# This script relies on the AWS CLI being installed and configured properly (profiles and auth) with the necessary permissions.
# The default behaviour is to update a secret with a new value. To create a new secret, use the -c flag.
usage() { echo "Usage: $0 [-p target,aws,profiles] [-s <secret string>] -d \"Description\" -k \"KMS Key Id create only\" -n \"Secret Name\" " 1>&2; exit 1; }
while getopts ":cd:kn:p:s:" flag
do
@derekmurawsky
derekmurawsky / commands.sh
Last active July 23, 2021 15:21
Do a rudimentary transcription using vosk
# Largely followed this post https://itectec.com/ubuntu/ubuntu-speech-recognition-app-to-convert-mp3-to-text/
# Download the show, https://selfhosted.show/49
wget https://aphid.fireside.fm/d/1437767933/7296e34a-2697-479a-adfb-ad32329dd0b0/1cbfb286-6182-404e-a59b-e969e60c7a44.mp3
# Convert it into the format vosk is epxecting
ffmpeg -i downloaded-mp3-file.mp3 -ar 16000 -ac 1 file.wav
# Install vosk
pip3 install vosk
@derekmurawsky
derekmurawsky / .gitmessage.txt
Created October 24, 2019 14:34
git commit message template
# < declarative subject > (Max 50 char)
# One of ["feat","fix","docs","style","refactor","perf","test","chore"]:
# |<---- Using a Maximum Of 50 Characters ---->|
# Explain why this change is being made
# |<---- Try To Limit Each Line to a Maximum Of 72 Characters ---->|
# More detailed explanatory text, if necessary. The blank line
@derekmurawsky
derekmurawsky / setupMacEnvironment.sh
Last active March 19, 2019 19:23
Environment Setup
# Install homebrew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
# Install basics
brew install git python nmap docker node nvm wget jq cookiecutter curl git nano
brew cask install iterm2 google-chrome
# Manually configure iterm2 with pro theme from the below clone
git clone https://github.com/mbadolato/iTerm2-Color-Schemes.git
### Keybase proof
I hereby claim:
* I am derekmurawsky on github.
* I am dmurawsky (https://keybase.io/dmurawsky) on keybase.
* I have a public key whose fingerprint is D0A7 74AE F15D 01B7 DA66 39E9 05F7 5B3B 7816 E0AE
To claim this, I am signing this object:
@derekmurawsky
derekmurawsky / get-sslSigningAlgorithm.ps1
Last active May 9, 2016 22:38
Check for certificate signing algorithm from a web server using powershell. Based on the Test-WebServerSSL cmdlet from http://en-us.sysadmins.lv/Lists/Posts/Post.aspx?List=332991f0-bfed-4143-9eea-f521167d287c&ID=60 which is the same as https://pspki.codeplex.com/wikipage?title=Test-WebServerSSL I think. Modified with input from the Philly Powers…
function get-SSLSigningAlgorithm {
[CmdletBinding()]
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true, Position = 0)]
[string]$URL,
[Parameter(Position = 1)]
[ValidateRange(1,65535)]
[int]$Port = 443,
[Parameter(Position = 2)]
[Net.WebProxy]$Proxy,
@derekmurawsky
derekmurawsky / forfiles.bat
Created February 25, 2014 14:43
A simple way to delete files older than X days in windows. This command is native and works as far back as server 2003.
REM Deletes files in specified path older than X days.
forfiles -p "C:\path\to\files" -s -m *.* -d -360 -c "cmd /c del @path"
REM Alternate way to do it. Deletes all files in current directory older than X days.
forfiles -s -m *.* -d -360 -c "cmd /c del @path"