Skip to content

Instantly share code, notes, and snippets.

View dynnamitt's full-sized avatar
:atom:
yolo

Kjetil Midtlie dynnamitt

:atom:
yolo
  • Norway
View GitHub Profile
@dynnamitt
dynnamitt / opentofu_setup.sh
Last active March 7, 2024 11:19
Install OpenTofu via tenv
#!/bin/sh
mkdir -p $HOME/tofuutils/tenv
# wget https://github.com/tofuutils/tenv/releases/download/v1.2.0/tenv_v1.2.0_Linux_x86_64.tar.gz
tar -xvf tenv_v1.2.0* -C $HOME/tofuutils/tenv
for f in $HOME/tofuutils/tenv/{tenv,terraform,tofu,tf}
do
ln -s $HOME/$f $HOME/.local/bin/$(basename $f)
done
@dynnamitt
dynnamitt / interweb_LSP_unzip.sh
Last active March 6, 2024 10:02
direct unzip from wget pipe (interactive selector)
#!/bin/sh
URL=${1:-https://releases.hashicorp.com/terraform-ls/0.32.7/terraform-ls_0.32.7_linux_amd64.zip}
wget -qO- $URL | bsdtar -xvf-
@dynnamitt
dynnamitt / nvm-purescript.sh
Last active July 6, 2023 22:03
purescript-nvm
#!/bin/sh
# From intro-video https://www.youtube.com/watch?v=Ng1YPjveaWg&t=1010s
# https://github.com/nvm-sh/nvm#installing-and-updating
nvm install v18.16.1 -- node
nvm install v18.16.1 -- npm
npm install -g purescript purescript-psa spago pscid
@dynnamitt
dynnamitt / wrap_awscli_calls.sh
Created February 21, 2023 09:50
terraform shell-provider, script-wrapper when using aws-cli role-arns
#!/bin/sh
# ========================================================================
#
# This is requires since we always assume a ROLE inside Terraform(go-sdk),
# BUT when we RETURN to shell we have a different IDENTITY.
# This shell IDENTITY must again assume the same "inside-TF ROLE" to
# be successful in using aws-cli
#
# =========================================================================
@dynnamitt
dynnamitt / lookup_events.sh
Created January 31, 2023 14:15
cloudtrail lookup on username
#!/bin/sh
# improved some of guide:
# https://aws.amazon.com/premiumsupport/knowledge-center/troubleshoot-iam-permission-errors/
usage() {
echo >&2 "Usage: $0 <[email protected]|user_id> [hours_back]"
exit 1
}
@dynnamitt
dynnamitt / gitlab-star-deep-clone.sh
Last active March 15, 2022 09:17
GITLAB ::: git-clone ALL favs into deep-nested dirs (( curl | jq | parallel ))
#!/bin/sh
# Make sure you have a PRIVATE_TOKEN in the file ~/.gitlab_token
GL_TOKEN=$(cat ~/.gitlab_token)
[ -z $GL_TOKEN ] && (printf "\n\nno token!\n\n\n";exit 1)
# USERID from username ARG1 on command-line
USER_NAME=${1:-kjetil.midtlie}
USERID=$(curl "https://gitlab.com/api/v4/users?private_token=$GL_TOKEN&username=$USER_NAME" | jq -r '.[0]|.id')
# bonus: sexy logfile ;)
sudo su
printf "#\!/usr/bin/env sh\n(date;docker rmi \$(docker images -q);echo +++++;) \
>> /var/log/docker_rmi_cron.log 2>&1\n" > /etc/cron.weekly/docker-rmi
chmod +x /etc/cron.weekly/docker-rmi
@dynnamitt
dynnamitt / squash.sh
Last active October 8, 2015 08:15
Git Pull PREPARE
# Switch to the master(or dev) branch and make sure you are up to date.
# Taken from http://makandracards.com/makandra/527-squash-several-git-commits-into-a-single-commit
# ===================================================================================================
# ------ basically ggpull 1st;
git checkout dev
git fetch upstream # eller `git fetch origin` HVIS gatekeeper
git merge upstream/dev # eller `git pull` HVIS gatekeeper
# start here ;
@dynnamitt
dynnamitt / inotify_delay_cmd
Last active August 29, 2015 14:11
Run CMD in an inotify loop, restarting inotifywait each time to ensure new dirs get hooked in. Runs on $PWD
#!/bin/sh
#function for yo .bashrc/.zshrc
inotify_delay_cmd() {
while true; do
inotifywait -r -e create -e delete -e modify --exclude '^\./\..+' .
"$@"
done
}
@dynnamitt
dynnamitt / steal_site alias
Last active August 29, 2015 14:11
rip a site via http
alias steal_site='wget --mirror --convert-links --adjust-extension --page-requisites --no-parent'