Skip to content

Instantly share code, notes, and snippets.

View kiwimato's full-sized avatar

Mihai kiwimato

View GitHub Profile

Keybase proof

I hereby claim:

  • I am kiwimato on github.
  • I am maihai (https://keybase.io/maihai) on keybase.
  • I have a public key ASBG4EX09k6eGU90d1qYPG_Xplu3k49sYXg6FyPLHhHJsAo

To claim this, I am signing this object:

@kiwimato
kiwimato / check_iaai.sh
Last active September 21, 2021 14:13
Checks a iaai.com link if the auction is not assigned
#!/bin/bash
# checks a iaai.com auction link if the auction is still not assigned
# Produces output like this:
# 2021-09-21_16:06:23 https://iaai.com/vehicledetails/40812556?tenant=US&RowNumber=2 - Auction still not assigned
# 2021-09-21_16:06:34 https://iaai.com/vehicledetails/40812556?tenant=US&RowNumber=2 - Auction still not assigned
URL_LIST="
https://iaai.com/vehicledetails/40812556?tenant=US&RowNumber=2
"
SLEEP_SECONDS=10 # Number of seconds to sleep between calls
@kiwimato
kiwimato / .bashrc
Last active November 16, 2021 23:11
.bashrc
## Custom stuff
# Yubikey
#export SSH_AUTH_SOCK="/run/user/$UID/gnupg/S.gpg-agent.ssh"
export GPG_TTY="$(tty)"
export SSH_AUTH_SOCK=$(gpgconf --list-dirs agent-ssh-socket)
gpgconf --launch gpg-agent
# echo "UPDATESTARTUPTTY" | gpg-connect-agent > /dev/null 2>&1
alias ykrestart='gpg-connect-agent updatestartuptty /bye'
# Switch between yubikeys with same key on them
alias ykswitch='gpg-connect-agent "scd serialno" "learn --force" /bye'
@kiwimato
kiwimato / chronyd-restart.sh
Created October 6, 2021 18:00
Creates a service which automatically restarts chronyd after suspend or hibernation upon resume
cat > /usr/lib/systemd/system/chronyd-restart-after-sleep.service <<'EOF'
[Unit]
Description=Restart Bluetooth after resume
After=suspend.target hibernate.target hybrid-sleep.target suspend-then-hibernate.target
[Service]
Type=simple
ExecStart=/usr/bin/systemctl --no-block restart chronyd
#ExecStart=/usr/bin/systemctl --no-block restart bluetooth.service
@kiwimato
kiwimato / nuke_aws_waf_resources.sh
Created October 11, 2021 16:24
Some scripts which will help to automate removal of WAF v1 resources in Amazon. Will iterate through most resources and remove them. This is just a beta, and not fully tested.
# configure this for AWS credentials, I use aws-vault
function aws_credentials(){
aws-vault exec foobar
}
# this function removes all filters assigned to conditions
function remove_filters(){
command=$1
command_list=list-${command}
command_get=get-${command%*s}
@kiwimato
kiwimato / extract_pipelines.sh
Created October 22, 2021 11:03
Extract pipeline names and links from Azure DevOps api response with jq and outputs in Jira format [pipeline name|https://link]
cat response.json | jq -r '.value[] | select(.name | contains ("project") and contains("master") and (contains("test")|not)) | "[\(.name)|\(._links.web.href)]"'
@kiwimato
kiwimato / vim.sh
Created November 16, 2021 23:14
Disable annoying vim mouse feature
cat >~/.vimrc<<'EOF'
source $VIMRUNTIME/defaults.vim
set mouse-=a
EOF
@kiwimato
kiwimato / vivaldi-1pass.sh
Created November 16, 2021 23:29
Adds Vivaldi as allowed browsers for 1Password linux app
sudo mkdir /etc/1password
echo vivaldi-bin | sudo tee /etc/1password/custom_allowed_browsers
sudo chown root:root /etc/1password/custom_allowed_browsers
sudo chmod 755 /etc/1password/custom_allowed_browsers
@kiwimato
kiwimato / shutdown-agent-if-idle.sh
Created November 17, 2021 18:11
Azure DevOps: stop the agent by issuing a shutdown if the agent is idle and it ran at least one job. If a job is running, it waits for it to finish. Useful with EC2 spot based instances as agents.
# Create a service:
cat > /lib/systemd/system/azure-devops-shutdown-when-idle.service<<'EOF'
[Unit]
Description=Issues as shutdown in case the agent is idle, to avoid long running ec2 spot instances
[Service]
Type=simple
ExecStart=/bin/bash /root/shutdown_when_idle.sh
[Install]
@kiwimato
kiwimato / .xsession
Created November 27, 2021 15:25
.xsession gpg-agent SSH_AGENT SSH_AUTH_SOCK Yubikey Jetbrains Pycharm IntelliJ IDEA
AGENT_SOCK=$(gpgconf --list-dirs | grep agent-socket | cut -d : -f 2)
if [[ ! -S $AGENT_SOCK ]]; then
gpg-agent --daemon --use-standard-socket &>/dev/null
fi
export GPG_TTY=$TTY
# Set SSH to use gpg-agent if it's enabled
GNUPGCONFIG="${GNUPGHOME:-"$HOME/.gnupg"}/gpg-agent.conf"
if [[ -r $GNUPGCONFIG ]] && command grep -q enable-ssh-support "$GNUPGCONFIG"; then