Changed the worktree to one directory back (i.e. $HOME) and simplified the setup
This commit is contained in:
107
dotfiles/bin/antimalware-service-disable.bat
Normal file
107
dotfiles/bin/antimalware-service-disable.bat
Normal file
@@ -0,0 +1,107 @@
|
||||
@setlocal enableextensions enabledelayedexpansion
|
||||
@echo off
|
||||
|
||||
rem Make sure we're running as admin. Got this garbage from https://stackoverflow.com/a/40388766
|
||||
if not "%1"=="am_admin" (
|
||||
powershell -Command "Start-Process -Verb RunAs -FilePath '%0' -ArgumentList 'am_admin'"
|
||||
exit /b
|
||||
)
|
||||
|
||||
rem USE AT OWN RISK AS IS WITHOUT WARRANTY OF ANY KIND !!!!!
|
||||
rem NOTE: Defender may see this file as malware, so you will likely need to exclude this before things can be disabled.
|
||||
rem
|
||||
rem Modified version of
|
||||
rem https://raw.githubusercontent.com/mattreecebentley/win10_disable_defender/main/win10_enable_defender.bat
|
||||
rem https://gist.github.com/xezrunner/a7a42dbc1096a40b0c78f09488fe5a2b
|
||||
|
||||
reg query HKLM\SYSTEM\Setup /v DisabledDefenderServices | find "0x1"
|
||||
if %errorlevel% == 0 goto already_patched
|
||||
|
||||
echo.
|
||||
echo Please note that Defender can only be disabled in Win10 v2004 and upwards if Tamper Protection is disabled.
|
||||
echo This setting can be found in Window settings (hint: search for 'tamper'). Please do this now and then,
|
||||
pause
|
||||
|
||||
echo.
|
||||
echo Disabling Windows Defender
|
||||
rem from: https://pastebin.com/kYCVzZPz
|
||||
rem Disable Tamper Protection First - on WIn10 vers which allow for this (not from 2004 onwards)
|
||||
reg add "HKLM\Software\Microsoft\Windows Defender\Features" /v "TamperProtection" /t REG_DWORD /d "0" /f
|
||||
|
||||
rem To disable System Guard Runtime Monitor Broker
|
||||
rem reg add "HKLM\System\CurrentControlSet\Services\SgrmBroker" /v "Start" /t REG_DWORD /d "4" /f
|
||||
|
||||
rem To disable Windows Defender Security Center include this
|
||||
rem reg add "HKLM\System\CurrentControlSet\Services\SecurityHealthService" /v "Start" /t REG_DWORD /d "4" /f
|
||||
|
||||
echo.
|
||||
echo Disable Real-time protection
|
||||
reg delete "HKLM\Software\Policies\Microsoft\Windows Defender" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender" /v "DisableAntiSpyware" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender" /v "DisableAntiVirus" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\MpEngine" /v "MpEnablePus" /t REG_DWORD /d "0" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" /v "DisableBehaviorMonitoring" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" /v "DisableIOAVProtection" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" /v "DisableOnAccessProtection" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" /v "DisableRealtimeMonitoring" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" /v "DisableRoutinelyTakingAction" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\Real-Time Protection" /v "DisableScanOnRealtimeEnable" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\Reporting" /v "DisableEnhancedNotifications" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\SpyNet" /v "DisableBlockAtFirstSeen" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\SpyNet" /v "SpynetReporting" /t REG_DWORD /d "0" /f
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\SpyNet" /v "SubmitSamplesConsent" /t REG_DWORD /d "2" /f
|
||||
|
||||
echo.
|
||||
echo Disable Logging
|
||||
reg add "HKLM\System\CurrentControlSet\Control\WMI\Autologger\DefenderApiLogger" /v "Start" /t REG_DWORD /d "0" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Control\WMI\Autologger\DefenderAuditLogger" /v "Start" /t REG_DWORD /d "0" /f
|
||||
|
||||
echo.
|
||||
echo Disable WD Tasks
|
||||
schtasks /Change /TN "Microsoft\Windows\ExploitGuard\ExploitGuard MDM policy Refresh" /Disable
|
||||
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Cache Maintenance" /Disable
|
||||
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Cleanup" /Disable
|
||||
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Scheduled Scan" /Disable
|
||||
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Verification" /Disable
|
||||
|
||||
echo.
|
||||
echo Disable WD systray icon
|
||||
reg delete "HKLM\Software\Microsoft\Windows\CurrentVersion\Explorer\StartupApproved\Run" /v "SecurityHealth" /f
|
||||
reg delete "HKLM\Software\Microsoft\Windows\CurrentVersion\Run" /v "SecurityHealth" /f
|
||||
|
||||
echo.
|
||||
echo Remove WD context menu
|
||||
reg delete "HKCR\*\shellex\ContextMenuHandlers\EPP" /f
|
||||
reg delete "HKCR\Directory\shellex\ContextMenuHandlers\EPP" /f
|
||||
reg delete "HKCR\Drive\shellex\ContextMenuHandlers\EPP" /f
|
||||
|
||||
echo.
|
||||
echo Disable WD services
|
||||
reg add HKLM\SYSTEM\CurrentControlSet\Services\wscsvc /v "Start" /t REG_DWORD /d "4" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\WdBoot" /v "Start" /t REG_DWORD /d "4" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\wdFilter" /v "Start" /t REG_DWORD /d "4" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\WdNisDrv" /v "Start" /t REG_DWORD /d "4" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\WdNisSvc" /v "Start" /t REG_DWORD /d "4" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\WinDefend" /v "Start" /t REG_DWORD /d "4" /f
|
||||
|
||||
echo.
|
||||
echo Disable Security system tray icon
|
||||
reg add "HKLM\SOFTWARE\Policies\Microsoft\Windows Defender Security Center\Systray" /v "HideSystray" /t REG_DWORD /d "1" /f
|
||||
|
||||
echo.
|
||||
echo Finishing up...
|
||||
reg add HKLM\SYSTEM\Setup /v DisabledDefenderServices /t REG_DWORD /d 1 /f
|
||||
|
||||
echo.
|
||||
echo Windows Defender has (hopefully) been disabled.
|
||||
echo You should still be able to scan files going forward. Also, the Antimalware Service Executable should immediately stop using CPU cycles.
|
||||
echo Please restart your computer to see all changes.
|
||||
|
||||
goto eof
|
||||
|
||||
:already_patched
|
||||
echo Defender has already been disabled by this script.
|
||||
|
||||
:eof
|
||||
echo.
|
||||
pause
|
||||
108
dotfiles/bin/antimalware-service-enable.bat
Normal file
108
dotfiles/bin/antimalware-service-enable.bat
Normal file
@@ -0,0 +1,108 @@
|
||||
@setlocal enableextensions enabledelayedexpansion
|
||||
@echo off
|
||||
|
||||
rem Make sure we're running as admin. Got this garbage from https://stackoverflow.com/a/40388766
|
||||
if not "%1"=="am_admin" (
|
||||
powershell -Command "Start-Process -Verb RunAs -FilePath '%0' -ArgumentList 'am_admin'"
|
||||
exit /b
|
||||
)
|
||||
|
||||
rem USE AT OWN RISK AS IS WITHOUT WARRANTY OF ANY KIND !!!!!
|
||||
rem
|
||||
rem Modified version of
|
||||
rem https://raw.githubusercontent.com/mattreecebentley/win10_disable_defender/main/win10_enable_defender.bat
|
||||
rem https://gist.github.com/xezrunner/a7a42dbc1096a40b0c78f09488fe5a2b
|
||||
rem
|
||||
rem Resources:
|
||||
rem https://docs.microsoft.com/en-us/powershell/module/defender/set-mppreference?view=win10-ps
|
||||
rem https://docs.microsoft.com/en-us/windows/threat-protection/windows-defender-exploit-guard/customize-exploit-protection
|
||||
rem https://github.com/AndyFul/ConfigureDefender
|
||||
rem https://github.com/AndyFul/Hard_Configurator
|
||||
|
||||
echo.
|
||||
echo Enabling Windows Defender
|
||||
reg query HKLM\SYSTEM\Setup /v DisabledDefenderServices | find "0x0"
|
||||
if %errorlevel% == 0 goto already_patched
|
||||
|
||||
reg delete "HKLM\Software\Policies\Microsoft\Windows Defender" /f
|
||||
reg add "HKLM\Software\Microsoft\Windows\CurrentVersion\Run" /v "SecurityHealth" /t REG_EXPAND_SZ /d "\"%windir%\system32\SecurityHealthSystray.exe\"" /f
|
||||
|
||||
echo.
|
||||
echo Restore WD shell
|
||||
reg add "HKLM\Software\Classes\*\shellex\ContextMenuHandlers\EPP" /ve /t REG_SZ /d "{09A47860-11B0-4DA5-AFA5-26D86198A780}" /f
|
||||
reg add "HKLM\Software\Classes\Drive\shellex\ContextMenuHandlers\EPP" /ve /t REG_SZ /d "{09A47860-11B0-4DA5-AFA5-26D86198A780}" /f
|
||||
reg add "HKLM\Software\Classes\Directory\shellex\ContextMenuHandlers\EPP" /ve /t REG_SZ /d "{09A47860-11B0-4DA5-AFA5-26D86198A780}" /f
|
||||
|
||||
echo.
|
||||
echo Enable WD services
|
||||
reg add "HKLM\System\CurrentControlSet\Services\BFE" /v "Start" /t REG_DWORD /d "2" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\MpsSvc" /v "Start" /t REG_DWORD /d "2" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\SecurityHealthService" /v "Start" /t REG_DWORD /d "2" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\SgrmBroker" /v "Start" /t REG_DWORD /d "2" /f
|
||||
|
||||
reg add "HKLM\System\CurrentControlSet\Services\wscsvc" /v "Start" /t REG_DWORD /d "2" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\WdBoot" /v "Start" /t REG_DWORD /d "2" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\wdFilter" /v "Start" /t REG_DWORD /d "2" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\WdNisDrv" /v "Start" /t REG_DWORD /d "2" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\WdNisSvc" /v "Start" /t REG_DWORD /d "2" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Services\WinDefend" /v "Start" /t REG_DWORD /d "2" /f
|
||||
|
||||
echo.
|
||||
echo 1 - Enable Logging
|
||||
reg add "HKLM\System\CurrentControlSet\Control\WMI\Autologger\DefenderApiLogger" /v "Start" /t REG_DWORD /d "1" /f
|
||||
reg add "HKLM\System\CurrentControlSet\Control\WMI\Autologger\DefenderAuditLogger" /v "Start" /t REG_DWORD /d "1" /f
|
||||
|
||||
echo.
|
||||
echo Enable WD Tasks
|
||||
schtasks /Change /TN "Microsoft\Windows\ExploitGuard\ExploitGuard MDM policy Refresh" /Enable
|
||||
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Cache Maintenance" /Enable
|
||||
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Cleanup" /Enable
|
||||
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Scheduled Scan" /Enable
|
||||
schtasks /Change /TN "Microsoft\Windows\Windows Defender\Windows Defender Verification" /Enable
|
||||
|
||||
echo.
|
||||
echo Setting various preferences
|
||||
rem CloudExtendedTimeout / 1 - 50 / block a suspicious file for up to 60 seconds (Default is 10)
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\MpEngine" /v "MpBafsExtendedTimeout" /t REG_DWORD /d "0" /f
|
||||
|
||||
rem CloudBlockLevel / 0 - Default / 2 - High / 4 - High+ / 6 - Zero tolerance (block all unknown executables)
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\MpEngine" /v "MpCloudBlockLevel" /t REG_DWORD /d "0" /f
|
||||
|
||||
rem 1 - Potentially Unwanted Application protection (PUP) is enabled, the applications with unwanted behavior will be blocked at download and install-time
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\MpEngine" /v "MpEnablePus" /t REG_DWORD /d "1" /f
|
||||
|
||||
rem Block at First Sight / 0 - Enable / 1 - Disable
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\SpyNet" /v "DisableBlockAtFirstSeen" /t REG_DWORD /d "0" /f
|
||||
|
||||
rem Cloud-based Protection / 0 - Disable / 1 - Basic / 2 - Advanced
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\SpyNet" /v "SpynetReporting" /t REG_DWORD /d "1" /f
|
||||
|
||||
rem Send file samples when further analysis is required / 0 - Always prompt / 1 - Send safe samples automatically / 2 - Never send / 3 - Send all samples automatically
|
||||
reg add "HKLM\Software\Policies\Microsoft\Windows Defender\SpyNet" /v "SubmitSamplesConsent" /t REG_DWORD /d "0" /f
|
||||
|
||||
echo.
|
||||
echo Attempting to enable Tamper Protection. If this fails then you need to do it manually.
|
||||
reg add "HKLM\Software\Microsoft\Windows Defender\Features" /v "TamperProtection" /t REG_DWORD /d "1" /f
|
||||
|
||||
rem To prevent WD using too much CPU, add this file to the exclusion list:
|
||||
rem C:\Program Files\Windows Defender\MsMpEng.exe
|
||||
echo.
|
||||
echo Attempting to exclude MsMpEng.exe to reduce CPU usage
|
||||
reg add "HKLM\Software\Microsoft\Windows Defender\Exclusions\Paths" /v "C:\Program Files\Windows Defender\MsMpEng.exe" /t REG_DWORD /d "0" /f
|
||||
|
||||
echo.
|
||||
echo Finishing up...
|
||||
reg add HKLM\SYSTEM\Setup /v DisabledDefenderServices /t REG_DWORD /d 0 /f
|
||||
|
||||
echo Windows Defender has (hopefully) been enabled.
|
||||
echo The Antimalware Service Executable should be active again.
|
||||
echo Restart your computer to see all changes.
|
||||
|
||||
goto eof
|
||||
|
||||
:already_patched
|
||||
echo Defender has already been enabled by this script.
|
||||
|
||||
:eof
|
||||
echo.
|
||||
pause
|
||||
46
dotfiles/bin/aws-list-deep-glacier-files
Normal file
46
dotfiles/bin/aws-list-deep-glacier-files
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
error() {
|
||||
printf "${BOLD}${RED}$1${NORMAL}\n"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error "\nAborting...\n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
bucket="$1"
|
||||
path="$2"
|
||||
output_file="$3"
|
||||
|
||||
if [[ $bucket == "" || $path == "" || $output_file == "" ]]; then
|
||||
error "Usage: aws-list-deep-glacier-files <bucket-name> <path-in-bucket> <output-file>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
aws s3api list-objects-v2 --bucket $bucket --prefix $path --query "Contents[?StorageClass=='DEEP_ARCHIVE']" --output text | LC_ALL=C awk '{print substr($0, index($0, $2))}' | awk '{NF-=3};3' > "$output_file"
|
||||
69
dotfiles/bin/aws-restore-deep-glacier-folder
Normal file
69
dotfiles/bin/aws-restore-deep-glacier-folder
Normal file
@@ -0,0 +1,69 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# Restores all files/folders inside a particular bucket path,
|
||||
# e.g. aws-restore-deep-glacier-folder mcampagnaro-deep-glacier images restored_images
|
||||
# will restore all files inside the images folder of the mcampagnaro-deep-glacier bucket, saving
|
||||
# temp restoration data in the local "restored_images" directory.
|
||||
#
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
error() {
|
||||
printf "${BOLD}${RED}$1${NORMAL}\n"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error "\nAborting...\n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
bucket="$1"
|
||||
path="$2"
|
||||
temp_dir="$3"
|
||||
number_of_objects_per_file=100
|
||||
days_available=7
|
||||
restore_tier="Bulk" # Can also be "Standard"
|
||||
|
||||
if [[ $bucket == "" || $path == "" || $temp_dir == "" ]]; then
|
||||
error "Usage: aws-restore-deep-glacier-folder <bucket-name> <path-in-bucket> <local-temp-dir>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf "${BOLD}Restoring ${GREEN}$bucket:$path${NORMAL}${BOLD} with local temp folder ${GREEN}$temp_dir${NORMAL}\n"
|
||||
|
||||
mkdir -p "$temp_dir"
|
||||
pushd "$temp_dir" &>/dev/null
|
||||
|
||||
aws s3api list-objects-v2 --bucket $bucket --prefix $path --query "Contents[?StorageClass=='DEEP_ARCHIVE']" --output text | LC_ALL=C awk '{print substr($0, index($0, $2))}' | awk '{NF-=3};3' > all_objects_list.txt
|
||||
|
||||
# Generate the main script that will kick off the restoration.
|
||||
printf "while read x; do\n printf \"aws s3api restore-object --restore-request '{\\\\\"Days\\\\\":$days_available,\\\\\"GlacierJobParameters\\\\\":{\\\\\"Tier\\\\\":\\\\\"$restore_tier\\\\\"}}' --bucket $bucket --key \\\\\"\$x\\\\\"\\\\n\"\n aws s3api restore-object --restore-request \"{\\\\\"Days\\\\\":$days_available,\\\\\"GlacierJobParameters\\\\\":{\\\\\"Tier\\\\\":\\\\\"$restore_tier\\\\\"}}\" --bucket $bucket --key \"\$x\"\ndone < all_objects_list.txt\nprintf \"\\\\nDone! You can now delete this folder.\\\\n\"\n" > run.sh
|
||||
chmod +x run.sh
|
||||
|
||||
printf "${BOLD}You can now run ${GREEN}$temp_dir/run.sh${NORMAL}${BOLD} to start the restoration process.\n"
|
||||
|
||||
popd &>/dev/null
|
||||
59
dotfiles/bin/backup-svn-repo
Normal file
59
dotfiles/bin/backup-svn-repo
Normal file
@@ -0,0 +1,59 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
error() {
|
||||
printf "${BOLD}${RED}$1${NORMAL}\n"
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
repo_path="$1"
|
||||
output_path="$2"
|
||||
|
||||
if [[ $repo_path == "" || $output_path == "" ]]; then
|
||||
error "Missing args: <svn repo path> <output path>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d "$repo_path" ]]; then
|
||||
error "Repo directory '$repo_path' doesn't exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
output_path="$output_path/svn"
|
||||
mkdir -p "$output_path"
|
||||
|
||||
now=$(echo $(date '+%Y-%m-%d-%H-%M-%S'))
|
||||
backup_path="$output_path/${now}_jellypixel_repos.dump.gz"
|
||||
|
||||
printf "${BOLD}${YELLOW}Backing up '$repo_path' to '$backup_path'\n"
|
||||
printf "Proceed? (1|y)\n> ${NORMAL}"
|
||||
|
||||
read -e proceed
|
||||
if [[ ! ($proceed == "1" || $proceed == "y") ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
svnadmin.exe dump "$repo_path" | gzip -9 > "$backup_path"
|
||||
47
dotfiles/bin/compress-video
Normal file
47
dotfiles/bin/compress-video
Normal file
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
use_gpu=0
|
||||
|
||||
if [[ $# < 2 || $# > 3 ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <filename> <output name> <optional: use-gpu (1|0), defaults to $use_gpu> ${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
output_name="$2"
|
||||
|
||||
if [[ $# > 2 ]]; then
|
||||
use_gpu=$3
|
||||
fi
|
||||
|
||||
# Found the following to work best with vids containing text (e.g. programming vid): 25 for CPU encoding and 27 for GPU.
|
||||
use_crf=21
|
||||
if [[ $use_gpu -eq 1 ]]; then
|
||||
use_crf=25
|
||||
fi
|
||||
|
||||
compress-video-with-crf $use_crf "$filename" "$output_name" $use_gpu
|
||||
|
||||
91
dotfiles/bin/compress-video-with-crf
Normal file
91
dotfiles/bin/compress-video-with-crf
Normal file
@@ -0,0 +1,91 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
use_gpu=0
|
||||
|
||||
if [[ "$#" < 3 || "$#" > 6 ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <crf value> <filename> <output name> <optional: use-gpu (1|0), defaults to $use_gpu> <optional: start time HH:MM:SS> <optional: end time HH:MM:SS>\n\nIf you want to encode a range of CRF values then use -1 as the crf value.${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
use_crf=$1
|
||||
|
||||
filename=$(basename -- "$2")
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
|
||||
output_name="$3"
|
||||
|
||||
if [[ "$#" > 3 ]]; then
|
||||
use_gpu=$4
|
||||
if [[ "$#" > 4 ]]; then
|
||||
start_time="$5"
|
||||
if [[ "$#" > 5 ]]; then
|
||||
end_time="$6"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ $use_gpu -ne 0 && $use_gpu -ne 1 ]]; then
|
||||
printf "${BOLD}${RED}Invalid use_gpu value. Got $use_gpu, but expected either 0 or 1${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
function encode() {
|
||||
crf=$1
|
||||
output="${output_name}.$extension"
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Encoding '$filename.$extension' | GPU: $use_gpu | CRF $crf | output: $output | start: $start_time | end: $end_time${NORMAL}\n"
|
||||
|
||||
timing_args=""
|
||||
if [[ $start_time != "" ]]; then
|
||||
timing_args+="-ss $start_time -to $end_time"
|
||||
fi
|
||||
|
||||
if [[ $use_gpu -eq 1 ]]; then
|
||||
# File will be slightly larger than CPU encoding, but it's much faster to transcode and doesn't max out the CPU cores.
|
||||
|
||||
# RTX 3080
|
||||
ffmpeg -y -stats -loglevel level+error $timing_args -vsync 0 -hwaccel cuda -hwaccel_output_format cuda -i "$filename.$extension" -c:a copy -c:v h264_nvenc -profile:v high -rc:v vbr_hq -cq:v $crf -b:v 5M -maxrate 5M -max_muxing_queue_size 9999 "$output"
|
||||
|
||||
# GTX 1070
|
||||
#ffmpeg -y -stats -loglevel level+error $timing_args -vsync 0 -hwaccel cuvid -c:v h264_cuvid -i "$filename.$extension" -c:a copy -c:v h264_nvenc -profile:v high -rc:v vbr_hq -cq:v $crf -b:v 5M -maxrate 5M -max_muxing_queue_size 9999 "$output"
|
||||
else
|
||||
ffmpeg -y -stats -loglevel level+error $timing_args -i "$filename.$extension" -c:v libx264 -crf $crf -preset veryfast -profile:v high -level 3.0 -strict -2 "$output"
|
||||
fi
|
||||
printf "\n${GREEN}${BOLD}Finished encoding '$filename.$extension' (CRF $crf) | output name '$output'${NORMAL}\n\n"
|
||||
}
|
||||
|
||||
if [[ $use_crf -ne -1 ]]; then
|
||||
encode $use_crf
|
||||
else
|
||||
printf "\n${YELLOW}${BOLD}Encoding using a range of CRF values.${NORMAL}\n"
|
||||
|
||||
# Bigger crf values == bigger compression.
|
||||
for crf in {25..28}
|
||||
do
|
||||
encode $crf
|
||||
done
|
||||
fi
|
||||
51
dotfiles/bin/convert-video-avi-to-mp4
Normal file
51
dotfiles/bin/convert-video-avi-to-mp4
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This is for reencoding an AVI video. I wasn't able to play the encoded videos
|
||||
# on my phone when using libx264 and libx265 encoders, but mpeg4 works. Also
|
||||
# I'm using the aac codec because some old avi's were using a codec that's not
|
||||
# supported in the mp4 container.
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
if [[ $1 == "" || $2 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <filename> <bitrate, e.g. \"4000k\"> <optional output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
|
||||
bitrate="$2"
|
||||
|
||||
output_name="$3"
|
||||
if [[ $output_name == "" ]]; then
|
||||
output="${filename}_CONVERTED-${bitrate}.mp4"
|
||||
else
|
||||
output="${output_name}.mp4"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Encoding '$filename.$extension' with target bitrate $bitrate | output: $output${NORMAL}\n"
|
||||
ffmpeg -i "$filename.$extension" -c:a aac -c:v mpeg4 -b:v $bitrate "$output"
|
||||
printf "\n${GREEN}${BOLD}Done encoding '$filename.$extension' to '$output'${NORMAL}\n\n"
|
||||
64
dotfiles/bin/convert-video-flv-to-mp4
Normal file
64
dotfiles/bin/convert-video-flv-to-mp4
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This is for reencoding an FLV video to mp4 using an mpeg4 encoder.
|
||||
# Can optionally compress the video.
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
if [[ $1 == "" || $2 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <compress 1|0> <filename> <optional output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
compress="$1"
|
||||
|
||||
filename=$(basename -- "$2")
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
|
||||
output="$3"
|
||||
if [[ $output == "" ]]; then
|
||||
output="${filename}_CONVERTED"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Encoding '$filename.$extension' | compress: $compress | output: $output.mp4${NORMAL}\n"
|
||||
|
||||
if [[ $compress -eq 1 ]]; then
|
||||
temp_output="temp_$output.mp4"
|
||||
else
|
||||
temp_output="$output.mp4"
|
||||
fi
|
||||
|
||||
# convert first.
|
||||
# we convert then compress instead of compressing on first pass because this results in a slightly higher bitrate.
|
||||
ffmpeg -y -stats -loglevel level+error -vsync 0 -hwaccel cuvid -c:v h264_cuvid -i "$filename.$extension" -c:a aac -c:v h264_nvenc -b:v 5M "$temp_output"
|
||||
|
||||
if [[ $compress -eq 1 ]]; then
|
||||
compress-video 1 "$temp_output" "$output"
|
||||
rm "$temp_output"
|
||||
else
|
||||
printf "\n"
|
||||
fi
|
||||
|
||||
printf "${GREEN}${BOLD}Done encoding '$filename.$extension' to '$output.mp4'${NORMAL}\n\n"
|
||||
64
dotfiles/bin/convert-video-mkv-to-mp4
Normal file
64
dotfiles/bin/convert-video-mkv-to-mp4
Normal file
@@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# This is for reencoding an mkv video to mp4 using an mpeg4 encoder.
|
||||
# Can optionally compress the video.
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
if [[ $1 == "" || $2 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <compress 1|0> <filename> <optional output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
compress="$1"
|
||||
|
||||
filename=$(basename -- "$2")
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
|
||||
output="$3"
|
||||
if [[ $output == "" ]]; then
|
||||
output="${filename}_CONVERTED"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Encoding '$filename.$extension' | compress: $compress | output: $output.mp4${NORMAL}\n"
|
||||
|
||||
if [[ $compress -eq 1 ]]; then
|
||||
temp_output="temp_$output.mp4"
|
||||
else
|
||||
temp_output="$output.mp4"
|
||||
fi
|
||||
|
||||
# convert first.
|
||||
# we convert then compress instead of compressing on first pass because this results in a slightly higher bitrate.
|
||||
ffmpeg -y -stats -loglevel level+error -i "$filename.$extension" -vcodec copy -acodec copy "$temp_output"
|
||||
|
||||
if [[ $compress -eq 1 ]]; then
|
||||
compress-video 1 "$temp_output" "$output"
|
||||
rm "$temp_output"
|
||||
else
|
||||
printf "\n"
|
||||
fi
|
||||
|
||||
printf "${GREEN}${BOLD}Done encoding '$filename.$extension' to '$output.mp4'${NORMAL}\n\n"
|
||||
50
dotfiles/bin/extract-16bit-wav-from-video
Normal file
50
dotfiles/bin/extract-16bit-wav-from-video
Normal file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
input="$1"
|
||||
output_name="$2"
|
||||
|
||||
if [[ $input == "" || $output_name == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <input video> <wav output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$input" ]]; then
|
||||
printf "${RED}${BOLD}Error: failed to extract audio. Video file \"$input\" doesn't exist.\n${NORMAL}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Add extension if not provided.
|
||||
output_basename=$(basename -- "$output_name")
|
||||
output_extension="${output_basename##*.}"
|
||||
if [[ $output_extension != "wav" ]]; then
|
||||
output_name="${output_name}.wav"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Extracting 16-bit WAV from $input | output: $output_name${NORMAL}\n"
|
||||
|
||||
ffmpeg -i "$input" -ar 16000 -ac 1 -c:a pcm_s16le "$output_name"
|
||||
|
||||
printf "${GREEN}${BOLD}Done extracting 16-bit WAV from $input | output: $output_name${NORMAL}\n"
|
||||
55
dotfiles/bin/extract-audio-from-video
Normal file
55
dotfiles/bin/extract-audio-from-video
Normal file
@@ -0,0 +1,55 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
transcode="$1"
|
||||
filename=$(basename -- "$2")
|
||||
format="$3"
|
||||
bitrate="$4"
|
||||
|
||||
if [[ $1 == "" || $2 == "" || $3 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <transcode? 0|1 (needed when container doesn't contain format)> <filename> <format (mp3, m4a, aac, etc)> <optional: bitrate. Uses 64k when not specified, 0 = variable (e.g. 0, 64, 128, etc)>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
output_name="$filename.$format"
|
||||
|
||||
if [[ $bitrate == "" ]]; then
|
||||
bitrate="64"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Extracting audio from $filename.$extension | bitrate: ${bitrate}k | output: $output_name${NORMAL}\n"
|
||||
|
||||
if [[ $transcode == "1" ]]; then
|
||||
# Transcode audio
|
||||
ffmpeg -i "$filename.$extension" -b:a ${bitrate}k -ac 2 -ar 44100 -map a "$output_name"
|
||||
else
|
||||
# Grab the audio stream from the video.
|
||||
ffmpeg -i "$filename.$extension" -vn -acodec copy "$output_name"
|
||||
fi
|
||||
|
||||
printf "\n${GREEN}${BOLD}Done extracting audio from $filename.$extension | output name '$output_name'${NORMAL}\n\n"
|
||||
|
||||
21
dotfiles/bin/file-portex-analyzer.bat
Normal file
21
dotfiles/bin/file-portex-analyzer.bat
Normal file
@@ -0,0 +1,21 @@
|
||||
@echo off
|
||||
|
||||
if exist %1\* (
|
||||
echo directory
|
||||
for /F "delims=" %%f in ('dir /b /s %1') do (
|
||||
:: skip folders
|
||||
if not exist "%%~f\" (
|
||||
java -jar %DEV_TOOLS%\PortexAnalyzer.jar -p "%%~f_PortexAnalyzer_Report.png" -o "%%~f_PortexAnalyzer_Report.txt" "%%~f" | more
|
||||
)
|
||||
)
|
||||
) else (
|
||||
if exist "%~1_PortexAnalyzer_Report.txt" (
|
||||
del "%~1_PortexAnalyzer_Report.txt"
|
||||
)
|
||||
if exist "%~1_PortexAnalyzer_Report.png" (
|
||||
del "%~1_PortexAnalyzer_Report.png"
|
||||
)
|
||||
java -jar %DEV_TOOLS%\PortexAnalyzer.jar -p "%~1_PortexAnalyzer_Report.png" -o "%~1_PortexAnalyzer_Report.txt" "%~1" | more
|
||||
start notepad "%~1_PortexAnalyzer_Report.txt"
|
||||
start rundll32 "C:\Program Files (x86)\Windows Photo Viewer\PhotoViewer.dll", ImageView_Fullscreen %~1_PortexAnalyzer_Report.png
|
||||
)
|
||||
3
dotfiles/bin/file-resource-hacker.bat
Normal file
3
dotfiles/bin/file-resource-hacker.bat
Normal file
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
|
||||
start %DEV_TOOLS%\ResourceHacker.exe "%~1"
|
||||
12
dotfiles/bin/file-sigcheck.bat
Normal file
12
dotfiles/bin/file-sigcheck.bat
Normal file
@@ -0,0 +1,12 @@
|
||||
@echo off
|
||||
|
||||
cd %DEV_TOOLS%\SysinternalsSuite
|
||||
if exist %1\* (
|
||||
echo Run on a file
|
||||
) else (
|
||||
if exist "%~1_Report.txt" (
|
||||
del "%~1_Report.txt"
|
||||
)
|
||||
sigcheck.exe /a "%~1" > "%~1_sigcheck_report.txt"
|
||||
start notepad "%~1_sigcheck_report.txt"
|
||||
)
|
||||
3
dotfiles/bin/file-x32dbg.bat
Normal file
3
dotfiles/bin/file-x32dbg.bat
Normal file
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
|
||||
start %DEV_TOOLS%\x64dbg\release\x32\x32dbg.exe "%~1"
|
||||
3
dotfiles/bin/file-x64dbg.bat
Normal file
3
dotfiles/bin/file-x64dbg.bat
Normal file
@@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
|
||||
start %DEV_TOOLS%\x64dbg\release\x64\x64dbg.exe "%~1"
|
||||
13
dotfiles/bin/files-arm.bat
Normal file
13
dotfiles/bin/files-arm.bat
Normal file
@@ -0,0 +1,13 @@
|
||||
@echo off
|
||||
:: arm directory args1
|
||||
for /F "delims=" %%f in ('dir /b /s %1') do (
|
||||
:: skip folders
|
||||
if not exist "%%~f\" (
|
||||
:: skip files without .disarmed extension
|
||||
if ".disarmed" == "%%~xf" (
|
||||
move "%%~f" "%%~dpnf"
|
||||
echo "%%~f" renamed to "%%~dpnf"
|
||||
)
|
||||
)
|
||||
)
|
||||
@pause
|
||||
13
dotfiles/bin/files-disarm.bat
Normal file
13
dotfiles/bin/files-disarm.bat
Normal file
@@ -0,0 +1,13 @@
|
||||
@echo off
|
||||
:: disarm directory args1
|
||||
for /F "delims=" %%f in ('dir /b /s %1') do (
|
||||
:: skip folders
|
||||
if not exist "%%~f\" (
|
||||
:: skip .disarmed extension
|
||||
if not ".disarmed" == "%%~xf" (
|
||||
move "%%~f" "%%~f.disarmed"
|
||||
echo "%%~f" renamed to "%%~f.disarmed"
|
||||
)
|
||||
)
|
||||
)
|
||||
@pause
|
||||
51
dotfiles/bin/fix-audio-in-one-channel
Normal file
51
dotfiles/bin/fix-audio-in-one-channel
Normal file
@@ -0,0 +1,51 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Use this to fix the audio of a video that has audio in only the left or right
|
||||
# channel. This does not re-encode the video.
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
if [[ $1 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <filename> <optional output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
|
||||
output_name="$2"
|
||||
|
||||
if [[ $output_name == "" ]]; then
|
||||
output="${filename}_repaired_audio.$extension"
|
||||
else
|
||||
output="${output_name}.$extension"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Repairing audio in $filename.$extension | output: $output${NORMAL}\n"
|
||||
|
||||
ffmpeg -i "$filename.$extension" -c:v copy -ac 1 "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Done repairing audio in $filename.$extension | output: $output${NORMAL}\n\n"
|
||||
|
||||
41
dotfiles/bin/join-video
Normal file
41
dotfiles/bin/join-video
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
output_name="$2"
|
||||
|
||||
if [[ $filename == "" || $output_name == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: create a text file that lists the input video paths on separate lines using the format: file '/path/to/video'. Then call:\n\n$0 <list name> <output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
output="${output_name}.mp4"
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Joining contents of '$filename'| output: $output${NORMAL}\n"
|
||||
|
||||
ffmpeg -f concat -safe 0 -i "$filename" -c copy "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Finished joining${NORMAL}\n\n"
|
||||
|
||||
70
dotfiles/bin/normalize-video-volume
Normal file
70
dotfiles/bin/normalize-video-volume
Normal file
@@ -0,0 +1,70 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Use this to normalize the audio of a video using the average loudness, or RMS-based normalization.
|
||||
# This does not re-encode the video.
|
||||
#
|
||||
# Inspired by https://superuser.com/a/323127 and https://superuser.com/a/1312885
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
if [[ $1 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <filename> <optional output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
|
||||
output_name="$2"
|
||||
|
||||
if [[ $output_name == "" ]]; then
|
||||
output="${filename}_normalized_audio.$extension"
|
||||
else
|
||||
output="${output_name}.$extension"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Normalizing audio in $filename.$extension | output: $output${NORMAL}\n"
|
||||
|
||||
# This is done in two passes. The first pass will compute the mean loudness and
|
||||
# the second pass will normalize the audio using the mean as the target.
|
||||
|
||||
# -vn, -sn, and -dn tells ffmpeg to ignore non-audio streams during the analysis. This speeds things up.
|
||||
ffmpeg -i "$filename.$extension" -af "volumedetect" -vn -sn -dn -f null /dev/null
|
||||
|
||||
#ffmpeg -i "$filename.$extension" -c:v copy -ac 1 "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Done normalizing audio in $filename.$extension | output: $output${NORMAL}\n\n"
|
||||
|
||||
|
||||
|
||||
#---------------------------------------
|
||||
# This seems better. 2 pass using loudnorm filter.
|
||||
|
||||
# 1st pass: ffmpeg -i "$filename.$extension" -pass 1 -filter:a loudnorm=print_format=json -vn -sn -dn -f null /dev/null
|
||||
# 2nd pass: ffmpeg -i "$filename.$extension" -c:v copy -pass 2 -filter:a loudnorm=linear=true:measured_I=$input_i:measured_LRA=$input_lra:measured_tp=$input_tp:measured_thresh=$input_thresh "$output"
|
||||
|
||||
# TODO: extract the $input_i, input_lra, etc from the 1st pass output so that this can be automated.
|
||||
# TODO: stackoverflow said if there are subtitles or multiple vid streams then add "-map 0" before the output name. Test this.
|
||||
# TODO: disable the log file or just delete it after normalizing.
|
||||
49
dotfiles/bin/remove-audio-from-video
Normal file
49
dotfiles/bin/remove-audio-from-video
Normal file
@@ -0,0 +1,49 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
if [[ $1 == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <filename> <optional output name>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
|
||||
output_name="$2"
|
||||
|
||||
if [[ $output_name == "" ]]; then
|
||||
output="${filename}_no_audio.$extension"
|
||||
else
|
||||
output="${output_name}.$extension"
|
||||
fi
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Removing audio from '$filename.$extension' | output: '$output'${NORMAL}\n"
|
||||
|
||||
# -an removes the audio.
|
||||
ffmpeg -i "$filename.$extension" -c:v copy -an "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Done removing audio from '$filename.$extension' | output: '$output'${NORMAL}\n\n"
|
||||
|
||||
73
dotfiles/bin/restore-svn-backup
Normal file
73
dotfiles/bin/restore-svn-backup
Normal file
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#
|
||||
# Loads an SVN snapshot into a new repository.
|
||||
#
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
error() {
|
||||
printf "${BOLD}${RED}$1${NORMAL}\n"
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
backup_path="$1"
|
||||
repo_path="$2"
|
||||
|
||||
if [[ ($backup_path == "") || ($repo_path == "") ]]; then
|
||||
error "Missing args: <backup file path> <svn repo path>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$backup_path" ]]; then
|
||||
error "Backup file '$backup_path' doesn't exist.\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d "$repo_path" ]]; then
|
||||
error "SVN repo '$repo_path' doesn't exist.\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
printf "${BOLD}${YELLOW}Loading backup '$backup_path' to '$repo_path'\n"
|
||||
printf "The destination repo should be a new repo with no commits.\n"
|
||||
printf "Proceed? (1|y)\n> ${NORMAL}"
|
||||
|
||||
read -e proceed
|
||||
if [[ ! ($proceed == "1" || $proceed == "y") ]]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Was having trouble getting this to work on svnadmin 1.14.1 on Windows:
|
||||
# gunzip -c "$backup_path" | svnadmin load "$repo_path"
|
||||
# It was very slow and the output would freeze.
|
||||
# So now we unzip and then import.
|
||||
source_dir=$(dirname "$backup_path")
|
||||
dump_file="$source_dir/$RANDOM.dump"
|
||||
printf "${BOLD}Unzipping to '$dump_file'\n"
|
||||
gunzip -cf "$backup_path" >> "$dump_file"
|
||||
printf "${BOLD}Loading into SVN repo\n"
|
||||
svnadmin load -F "$dump_file" "$repo_path"
|
||||
rm "$dump_file"
|
||||
206
dotfiles/bin/scmindent.vim.rkt
Normal file
206
dotfiles/bin/scmindent.vim.rkt
Normal file
@@ -0,0 +1,206 @@
|
||||
#! /usr/bin/env racket
|
||||
|
||||
#lang racket
|
||||
|
||||
;Dorai Sitaram
|
||||
;Oct 8, 1999
|
||||
;last change 2016-12-28
|
||||
|
||||
;This script takes lines of Scheme or Lisp code from its
|
||||
;stdin and produces an indented version thereof on its
|
||||
;stdout.
|
||||
|
||||
(define *lisp-keywords* '())
|
||||
|
||||
(define (set-lisp-indent-number sym num-of-subforms-to-be-indented-wide)
|
||||
(let* ((x (symbol->string sym))
|
||||
(c (assf (lambda (a) (string-ci=? x a)) *lisp-keywords*)))
|
||||
(unless c
|
||||
(set! c (cons x (box 0)))
|
||||
(set! *lisp-keywords* (cons c *lisp-keywords*)))
|
||||
(set-box! (cdr c) num-of-subforms-to-be-indented-wide)))
|
||||
|
||||
(for-each (lambda (s) (set-lisp-indent-number s 0))
|
||||
'(block
|
||||
handler-bind
|
||||
loop))
|
||||
|
||||
(for-each (lambda (s) (set-lisp-indent-number s 1))
|
||||
'(case
|
||||
defpackage dolist dotimes
|
||||
ecase etypecase eval-when
|
||||
flet
|
||||
labels lambda let let* let-values
|
||||
prog1
|
||||
typecase
|
||||
unless unwind-protect
|
||||
when with-input-from-string with-open-file with-open-socket
|
||||
with-open-stream with-output-to-string))
|
||||
|
||||
(for-each (lambda (s) (set-lisp-indent-number s 2))
|
||||
'(defun destructuring-bind do do*
|
||||
if
|
||||
multiple-value-bind
|
||||
with-slots))
|
||||
|
||||
(define (read-home-lispwords)
|
||||
(let ((init-file (build-path (find-system-path 'home-dir) ".lispwords")))
|
||||
(when (file-exists? init-file)
|
||||
(call-with-input-file init-file
|
||||
(lambda (i)
|
||||
(let loop ()
|
||||
(let ((w (read i)))
|
||||
(unless (eof-object? w)
|
||||
(let ((n (car w)))
|
||||
(for-each (lambda (x) (set-lisp-indent-number x n))
|
||||
(cdr w)))
|
||||
(loop)))))))))
|
||||
|
||||
(define (past-next-token s i n)
|
||||
(let loop ((i i) (escape? #f))
|
||||
(if (>= i n) i
|
||||
(let ((c (string-ref s i)))
|
||||
(cond (escape? (loop (+ i 1) #f))
|
||||
((char=? c #\\) (loop (+ i 1) #t))
|
||||
((char=? c #\#)
|
||||
(let ((j (+ i 1)))
|
||||
(if (>= j n) i
|
||||
(let ((c (string-ref s j)))
|
||||
(cond ((char=? c #\\) (loop (+ j 1) #t))
|
||||
(else i))))))
|
||||
((memv c '(#\space #\tab #\( #\) #\[ #\] #\" #\' #\` #\, #\;))
|
||||
i)
|
||||
(else (loop (+ i 1) #f)))))))
|
||||
|
||||
(define (lisp-indent-number s)
|
||||
(let ((c (assf (lambda (a) (string-ci=? s a)) *lisp-keywords*)))
|
||||
(cond (c (unbox (cdr c)))
|
||||
((and (>= (string-length s) 3)
|
||||
(string-ci=? (substring s 0 3) "def")) 0)
|
||||
(else -1))))
|
||||
|
||||
(define (literal-token? s)
|
||||
(let ((x (let ((i (open-input-string s)))
|
||||
(begin0 (read i) (close-input-port i)))))
|
||||
(or (char? x) (number? x) (string? x))))
|
||||
|
||||
(define (calc-subindent s i n)
|
||||
(let* ((j (past-next-token s i n))
|
||||
(num-aligned-subforms 0)
|
||||
(left-indent
|
||||
(if (= j i) 1
|
||||
(let ((w (substring s i j)))
|
||||
(if (and (>= i 2)
|
||||
(memv (string-ref s (- i 2)) '(#\' #\`)))
|
||||
1
|
||||
(let ((nas (lisp-indent-number w)))
|
||||
(cond ((>= nas 0) (set! num-aligned-subforms nas)
|
||||
2)
|
||||
((literal-token? w) 1)
|
||||
((= j n) 1)
|
||||
(else (+ (- j i) 2)))))))))
|
||||
(values left-indent num-aligned-subforms (- j 1))))
|
||||
|
||||
(define (num-leading-spaces s)
|
||||
(let ((n (string-length s)))
|
||||
(let loop ((i 0) (j 0))
|
||||
(if (>= i n) 0
|
||||
(case (string-ref s i)
|
||||
((#\space) (loop (+ i 1) (+ j 1)))
|
||||
((#\tab) (loop (+ i 1) (+ j 8)))
|
||||
(else j))))))
|
||||
|
||||
(define (string-trim-blanks s)
|
||||
(let ((n (string-length s)))
|
||||
(let ((j (let loop ((j 0))
|
||||
(if (or (>= j n)
|
||||
(not (char-whitespace? (string-ref s j))))
|
||||
j
|
||||
(loop (+ j 1))))))
|
||||
(if (>= j n) ""
|
||||
(let ((k (let loop ((k (- n 1)))
|
||||
(if (or (< k 0)
|
||||
(not (char-whitespace? (string-ref s k))))
|
||||
(+ k 1)
|
||||
(loop (- k 1))))))
|
||||
(substring s j k))))))
|
||||
|
||||
(define-struct lparen
|
||||
(spaces-before num-aligned-subforms (num-finished-subforms #:auto))
|
||||
#:mutable #:auto-value 0)
|
||||
|
||||
(define (indent-lines)
|
||||
(let ((left-i 0) (paren-stack '()) (stringp #f))
|
||||
(let line-loop ()
|
||||
(let ((curr-line (read-line)))
|
||||
(unless (eof-object? curr-line)
|
||||
(let* ((leading-spaces (num-leading-spaces curr-line))
|
||||
(curr-left-i
|
||||
(cond (stringp leading-spaces)
|
||||
((null? paren-stack)
|
||||
(when (= left-i 0) (set! left-i leading-spaces))
|
||||
left-i)
|
||||
(else (let* ((lp (car paren-stack))
|
||||
(nas (lparen-num-aligned-subforms lp))
|
||||
(nfs (lparen-num-finished-subforms lp))
|
||||
(extra-w 0))
|
||||
(when (< nfs nas)
|
||||
(set-lparen-num-finished-subforms! lp
|
||||
(+ nfs 1))
|
||||
(set! extra-w 2))
|
||||
(+ (lparen-spaces-before lp) extra-w))))))
|
||||
(set! curr-line (string-trim-blanks curr-line))
|
||||
(do ((i 0 (+ i 1)))
|
||||
((= i curr-left-i))
|
||||
(write-char #\space))
|
||||
(display curr-line) (newline)
|
||||
;
|
||||
(let ((n (string-length curr-line))
|
||||
(escapep #f)
|
||||
(inter-word-space-p #f))
|
||||
(let loop ((i 0))
|
||||
(unless (>= i n)
|
||||
(let ((c (string-ref curr-line i)))
|
||||
(cond (escapep (set! escapep #f) (loop (+ i 1)))
|
||||
((char=? c #\\) (set! escapep #t) (loop (+ i 1)))
|
||||
(stringp
|
||||
(when (char=? c #\") (set! stringp #f))
|
||||
(loop (+ i 1)))
|
||||
((char=? c #\;) 'break-loop)
|
||||
((char=? c #\") (set! stringp #t)
|
||||
(loop (+ i 1)))
|
||||
((memv c '(#\space #\tab))
|
||||
(unless inter-word-space-p
|
||||
(set! inter-word-space-p #t)
|
||||
(cond ((and (pair? paren-stack)
|
||||
(car paren-stack)) =>
|
||||
(lambda (lp)
|
||||
(let ((nfs (lparen-num-finished-subforms lp)))
|
||||
(set-lparen-num-finished-subforms! lp (+ nfs 1)))))))
|
||||
(loop (+ i 1)))
|
||||
((memv c '(#\( #\[))
|
||||
(set! inter-word-space-p #f)
|
||||
(let-values (((left-indent
|
||||
num-aligned-subforms
|
||||
j)
|
||||
(calc-subindent curr-line (+ i 1) n)))
|
||||
(set! paren-stack
|
||||
(cons (make-lparen (+ i curr-left-i left-indent)
|
||||
num-aligned-subforms)
|
||||
paren-stack))
|
||||
(loop (+ j 1))))
|
||||
((memv c '(#\) #\]))
|
||||
(set! inter-word-space-p #f)
|
||||
(cond (paren-stack
|
||||
(set! paren-stack (cdr paren-stack)))
|
||||
(else (set! left-i 0)))
|
||||
(loop (+ i 1)))
|
||||
(else (set! inter-word-space-p #f)
|
||||
(loop (+ i 1)))))))))
|
||||
(line-loop))))))
|
||||
|
||||
(read-home-lispwords)
|
||||
|
||||
(indent-lines)
|
||||
|
||||
;eof
|
||||
29
dotfiles/bin/symbolic-link
Normal file
29
dotfiles/bin/symbolic-link
Normal file
@@ -0,0 +1,29 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
source "$HOME/dotfiles/script_helpers/all.sh"
|
||||
|
||||
cwd=$PWD
|
||||
source_path=""
|
||||
dest_path=""
|
||||
|
||||
#echo "got $1 and $2 and $3"
|
||||
|
||||
if [[ $1 ]]; then
|
||||
source_path=$1
|
||||
else
|
||||
printf "${BOLD}${YELLOW}Enter full path to source file/dir:\n${NORMAL}"
|
||||
read -e source_path
|
||||
fi
|
||||
|
||||
if [[ $2 ]]; then
|
||||
dest_path=$2
|
||||
else
|
||||
printf "${BOLD}${YELLOW}Enter full path to symlink destination:\n${NORMAL}"
|
||||
read -e dest_path
|
||||
fi
|
||||
|
||||
if [[ $3 ]]; then expand_symlinks=$3; else expand_symlinks=0; fi
|
||||
|
||||
overwrite_existing=0
|
||||
confirm_link=0
|
||||
make_link "$source_path" "$dest_path" $expand_symlinks $overwrite_existing $confirm_link
|
||||
54
dotfiles/bin/sync-android-chrome-tabs
Normal file
54
dotfiles/bin/sync-android-chrome-tabs
Normal file
@@ -0,0 +1,54 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
error() {
|
||||
printf "${BOLD}${RED}$1${NORMAL}"
|
||||
}
|
||||
|
||||
abort() {
|
||||
error "\nAborting...\n"
|
||||
exit 1
|
||||
}
|
||||
|
||||
set -e
|
||||
|
||||
cwd=$PWD
|
||||
|
||||
printf "${BOLD}Attempting to connect to device via adb...\nMake sure 'file transfer' mode is set on device. You may have to accept the connection and then re-run this script.\n${NORMAL}"
|
||||
|
||||
adb forward tcp:9222 localabstract:chrome_devtools_remote
|
||||
|
||||
src=_tabs.json
|
||||
if wget -qO $src http://localhost:9222/json/list; then
|
||||
ts=`date +"%Y-%m-%d_%H-%M-%S"`
|
||||
dest="${cwd}/${ts}_android-chrome-tabs.md"
|
||||
sed -n "/\"url\"/p" $src | sed -e "s/^[ \t]*.\{8\}//" -e "s/.\{2\}$//" > $dest
|
||||
printf "${BOLD}Saved tabs to: ${YELLOW}$dest${NORMAL}\n"
|
||||
else
|
||||
error "Unable to download tabs from device!\n"
|
||||
fi
|
||||
|
||||
rm $src
|
||||
|
||||
94
dotfiles/bin/transcribe-audio
Normal file
94
dotfiles/bin/transcribe-audio
Normal file
@@ -0,0 +1,94 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# The base model is pretty good overall. It has good punctuation inserting and catches most words.
|
||||
# Tiny is fast and often has correct grammar, but it misses a lot of words, especially when the
|
||||
# source isn't loud or is muffled.
|
||||
#
|
||||
# Small and medium models can do better word detection at times, but suffer from a lack of punctuation.
|
||||
# Medium is particularly bad and often excludes periods and commas.
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
# Will return a symlink path in its expanded form. If the path's root is the
|
||||
# home directory symbol "~" then it'll be replaced by the full home path.
|
||||
expand_path() {
|
||||
local ret="$1"
|
||||
|
||||
IFS="/" read -ra parts <<< "$ret"
|
||||
if [[ "${parts[0]}" == "~" ]]; then
|
||||
ret="$HOME"
|
||||
for ((i=1; i < ${#parts[@]}; i++))
|
||||
do
|
||||
ret="$ret/${parts[$i]}"
|
||||
done
|
||||
fi
|
||||
ret=$(readlink -m "$ret")
|
||||
echo $ret
|
||||
}
|
||||
|
||||
input_wav="$1"
|
||||
output_name_without_ext="$2"
|
||||
model="$3"
|
||||
threads=$4
|
||||
|
||||
# 4 seems to be the sweet spot for most models, except medium might be faster with 8.
|
||||
default_thread_count=4
|
||||
|
||||
if [[ $input_wav == "" || $output_name_without_ext == "" || $model == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <input.wav> <output name without extension> <model name> <optional: thread count>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -f "$input_wav" ]]; then
|
||||
printf "${RED}${BOLD}Input file \"$input_wav\" doesn't exist!\n${NORMAL}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $threads == "" ]]; then
|
||||
threads=$default_thread_count
|
||||
fi
|
||||
|
||||
output_name="$output_name_without_ext.${model}"
|
||||
|
||||
|
||||
# 1 core 31 threads has very fast pcm_to_mel conversion and then just one core doing most of the work. You get more accurate results this way.
|
||||
# 2 core 16 is about half the time but it can have errors where the two pieces come together. This only gets more likely as the core count is increased.
|
||||
# 8 threads, 4 cores is good too for tiny,small and 2 threads, 4 cores for medium.
|
||||
|
||||
threads=31 #keep a thread for me
|
||||
cores=1
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Transcribing $input_wav | model: $model | cores: $cores | threads: $threads | output: $output_name ${NORMAL}\n"
|
||||
|
||||
whisper_fullname="$(expand_path $(which whisper.exe))"
|
||||
whisper_path="$(dirname $whisper_fullname)"
|
||||
models_path="$whisper_path/models"
|
||||
|
||||
whisper.exe --processors ${cores} --threads ${threads} -m "$models_path/ggml-${model}.en.bin" -otxt -osrt -f "$input_wav" -of "$output_name" --print-colors --print-progress
|
||||
error=$?
|
||||
if [[ error -eq 0 ]]; then
|
||||
printf "${GREEN}${BOLD}Done transcribing $input_wav | model: $model | cores: $cores | threads: $threads | output: $output_name${NORMAL}\n"
|
||||
else
|
||||
printf "${GREEN}${BOLD}Error while transcribing $input_wav | model: $model | cores: $cores | threads: $threads | output: $output_name${NORMAL}\n"
|
||||
fi
|
||||
65
dotfiles/bin/transcribe-video
Normal file
65
dotfiles/bin/transcribe-video
Normal file
@@ -0,0 +1,65 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
input_video="$1"
|
||||
output_name_without_ext="$2"
|
||||
shift 2
|
||||
models=("$@")
|
||||
|
||||
if [[ $input_video == "" || $output_name_without_ext == "" || ${#models[@]} -eq 0 ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <input.mp4> <output name without extension> <list of model names to use>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
model_csv=$(IFS=_ ; echo "${models[*]}")
|
||||
wav_name="${output_name_without_ext}_${model_csv}_${RANDOM}"
|
||||
|
||||
# Add extension if not provided.
|
||||
input_basename=$(basename -- "$wav_name")
|
||||
input_extension="${input_basename##*.}"
|
||||
if [[ input_extension != "wav" ]]; then
|
||||
wav_name="${wav_name}.wav"
|
||||
fi
|
||||
|
||||
extract-16bit-wav-from-video "$input_video" "$wav_name"
|
||||
if [[ $? == 1 ]]; then exit 1; fi
|
||||
|
||||
for model in "$@"; do
|
||||
# Tweak thread count based on model size.
|
||||
thread_count=4
|
||||
if [[ $model == "medium" ]]; then
|
||||
thread_count=8
|
||||
fi
|
||||
|
||||
transcribe-audio "$wav_name" "$output_name_without_ext" "${model}" $thread_count
|
||||
|
||||
if [[ $? == 1 ]]; then
|
||||
printf "${RED}${BOLD}Saving the audio file \"$wav_name\" in case you want to reuse it for debugging.\n${NORMAL}"
|
||||
exit 1
|
||||
fi
|
||||
done
|
||||
|
||||
rm "$wav_name"
|
||||
|
||||
2
dotfiles/bin/transcribe-video-base
Normal file
2
dotfiles/bin/transcribe-video-base
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
transcribe-video "$1" "$2" "base"
|
||||
2
dotfiles/bin/transcribe-video-medium
Normal file
2
dotfiles/bin/transcribe-video-medium
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
transcribe-video "$1" "$2" "medium"
|
||||
2
dotfiles/bin/transcribe-video-small
Normal file
2
dotfiles/bin/transcribe-video-small
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
transcribe-video "$1" "$2" "small"
|
||||
2
dotfiles/bin/transcribe-video-tiny
Normal file
2
dotfiles/bin/transcribe-video-tiny
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/usr/bin/env bash
|
||||
transcribe-video "$1" "$2" "tiny"
|
||||
48
dotfiles/bin/trim-accurate-video
Normal file
48
dotfiles/bin/trim-accurate-video
Normal file
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Reencodes the video with a more accurate length.
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
output_name="$2"
|
||||
start_time="$3"
|
||||
end_time="$4"
|
||||
|
||||
if [[ $filename == "" || $output_name == "" || $start_time == "" || $end_time == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <filename> <output name> <start time HH:MM:SS> <end time HH:MM:SS>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
output="${output_name}.$extension"
|
||||
timing_args="-ss $start_time -to $end_time"
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Trimming '$filename.$extension' | output: $output | start: $start_time | end: $end_time${NORMAL}\n"
|
||||
|
||||
ffmpeg -y -stats -loglevel level+error $timing_args -accurate_seek -i "$filename.$extension" -c:v libx264 -c:a copy "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
|
||||
|
||||
46
dotfiles/bin/trim-video
Normal file
46
dotfiles/bin/trim-video
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if which tput >/dev/null 2>&1; then
|
||||
ncolors=$(tput colors)
|
||||
fi
|
||||
if [ -t 1 ] && [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
|
||||
RED="$(tput setaf 1)"
|
||||
GREEN="$(tput setaf 2)"
|
||||
YELLOW="$(tput setaf 3)"
|
||||
BLUE="$(tput setaf 4)"
|
||||
MAGENTA="$(tput setaf 5)"
|
||||
CYAN="$(tput setaf 6)"
|
||||
BOLD="$(tput bold)"
|
||||
NORMAL="$(tput sgr0)"
|
||||
else
|
||||
RED=""
|
||||
GREEN=""
|
||||
YELLOW=""
|
||||
BLUE=""
|
||||
MAGENTA=""
|
||||
CYAN=""
|
||||
BOLD=""
|
||||
NORMAL=""
|
||||
fi
|
||||
|
||||
filename=$(basename -- "$1")
|
||||
output_name="$2"
|
||||
start_time="$3"
|
||||
end_time="$4"
|
||||
|
||||
if [[ $filename == "" || $output_name == "" || $start_time == "" || $end_time == "" ]]; then
|
||||
printf "${BOLD}${RED}Usage: $0 <filename> <output name> <start time HH:MM:SS> <end time HH:MM:SS>${NORMAL}\n"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
extension="${filename##*.}"
|
||||
filename="${filename%.*}"
|
||||
output="${output_name}.$extension"
|
||||
timing_args="-ss $start_time -to $end_time"
|
||||
|
||||
printf "\n${YELLOW}${BOLD}Trimming '$filename.$extension' | output: $output | start: $start_time | end: $end_time${NORMAL}\n"
|
||||
|
||||
ffmpeg -y -stats -loglevel level+error $timing_args -i "$filename.$extension" -c copy "$output"
|
||||
|
||||
printf "\n${GREEN}${BOLD}Finished trimming${NORMAL}\n\n"
|
||||
|
||||
24
dotfiles/bin/update-msys-shell
Normal file
24
dotfiles/bin/update-msys-shell
Normal file
@@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# If you're getting signature errors, check out https://www.msys2.org/news/#2020-06-29-new-packagers and/or other news posts.
|
||||
|
||||
source "$HOME/dotfiles/script_helpers/printing.sh"
|
||||
source "$HOME/dotfiles/script_helpers/platform.sh"
|
||||
|
||||
set -e
|
||||
|
||||
if [[ -d "/c/msys64" ]]; then
|
||||
shell_is_mingw is_mingw
|
||||
if [[ $is_mingw -eq 1 ]]; then
|
||||
printf "${BOLD}${YELLOW}Updating MinGW Shell${NORMAL}\n"
|
||||
pacman -Syu
|
||||
printf "${BOLD}${GREEN}Done!${NORMAL}\n"
|
||||
printf "\n${BOLD}Re-run this in a new shell if the updater requires the shells to be closed.\n"
|
||||
else
|
||||
error "Re-run this in an MinGW shell.\n"
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
error "Unable to find C:\msys64 - make sure the shell is installed and then re-run this in a MinGW shell.\n"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user