Skip to content

Instantly share code, notes, and snippets.

@stefan-matic
stefan-matic / move-files.ahk
Last active April 3, 2022 18:48
Allow moving files to specified folders in the code based on the key pressed. Edit lines 6-10 for key binds and 16-25 for folder paths. F1 suspends the hotkeys so you can use the keyboard normally
GroupAdd, WinGroupFolder, ahk_class CabinetWClass
GroupAdd, WinGroupFolder, ahk_class ExploreWClass
#IfWinActive ahk_group WinGroupFolder
F1::Suspend
q::
t::
f::
g::
d::
@stefan-matic
stefan-matic / swap-ec2-volumes.sh
Last active May 25, 2022 10:15
Swaps volumes of two EC2 instance using AWS CLI. Includes Terraform to spawn two ec2 instances for testing.
#!/bin/bash
AWS_PROFILE="YOUR-AWS-PROFILE"
AWS_REGION="YOUR-AWS-REGION"
# OLD INSTANCE INFO
OLD_INSTANCE_ID="i-0123456789abcdef0"
OLD_INSTANCE_VOLUME_ID="vol-0123456789abcdef0"
OLD_INSTANCE_MOUNT_POINT="/dev/sda1"
@stefan-matic
stefan-matic / init-terraform-backend.sh
Last active October 17, 2023 16:08
Quick and easy script to create an S3 bucket and dynamodb for the Terraform S3 backend. Run the script without parameters to create everything (e.g. ./init-terraform-backend.sh) or call each function individually if you want to do step-by-step (e.g ./init-terraform-backend create_terraform_s3_bucket).
#!/bin/bash
# Edit these variables:
# Make sure that the PROJECT is something unique,
# since the s3 bucket name needs to be globally unique
export PROJECT="YOUR_PROJECT"
export AWS_REGION="YOUR_REGION"
export BUCKET="${PROJECT}-terraform-state-files"
export LOCK_TABLE="${PROJECT}-terraform-locks"
@stefan-matic
stefan-matic / transfer.fish
Last active October 18, 2023 14:59
Easy file sharing from the command line using http://transfer.sh through fish shell
function transfer --description 'Easy file sharing from the command line using http://transfer.sh'
if test (count $argv) -eq 0
echo -e "No arguments specified. Usage:\necho transfer /tmp/test.md\ncat /tmp/test.md | transfer test.md";
return 1;
end
set tmpfile ( mktemp -t transferXXX );
if tty -s
set basefile (basename $argv[1] | sed -e 's/[^a-zA-Z0-9._-]/-/g');
curl -v --progress-bar --upload-file $argv[1] "https://transfer.sh/$basefile" 2>&1 | grep -i 'https://transfer.sh' >> $tmpfile;
else
@stefan-matic
stefan-matic / unifi_cert_replacement.sh
Created October 18, 2023 20:39
Unifi certificate keystore replacement
#!/bin/bash
#
# This script copies our domain cert over to the gateway. We use a wildcard cert so we can have
# different names for the guest portal and main admin page if we want.
#
# Our pub ssh key is in /root/.ssh/authorized_keys on the gateway so we
# don't need a password to run it.
#
# Call this from cron once in a while to make sure your cert stays updated.
# Not too often though as it restarts the whole network container which isn't very desireable.
@stefan-matic
stefan-matic / unraid-traefik-labels.sh
Last active December 17, 2023 12:42
Automate adding Traefik labels to containers
#!/bin/bash
############################################################################################
# Run the script as ./unraid-traefik-labels.sh main_clicks <APP_NAME> <APP_PORT> #
# Example: ./unraid-traefik-labels.sh main_clicks my-app 5554 #
# #
# To get coordinates for click options place your mouse on the desired location and use: #
# eval $(xdotool getmouselocation --shell) #
# echo $X #
# echo $Y #