: bharatvaj/scripts

commit ae101794931cd321e838025df42db5d9992c7f37
parent dc65e62a24a64cf70eb6a4058e5ae6b36265dd82
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Thu, 12 Nov 2026 12:40:21 +0530

Add accumalated various windows laptop scripts
15 files changed, 294 insertions(+), 0 deletions(-)
A
APKBUILD
|
9
+++++++++
A
README
|
1
+
A
classify.sh
|
13
+++++++++++++
A
ffmpeg/ravisagar.sh
|
38
++++++++++++++++++++++++++++++++++++++
A
interesting/sha256sum.cmd
|
10
++++++++++
A
misc/move-codefiles.sh
|
7
+++++++
A
misc/update-dates-in-todotxt.sh
|
16
++++++++++++++++
A
ooo/min-httpd.sh
|
3
+++
M
os/wifi-connect.sh
|
1
+
A
server/linode2sshconfig.jq
|
21
+++++++++++++++++++++
A
server/vultr2sshconfig.jq
|
21
+++++++++++++++++++++
A
sh/exif-update-time.sh
|
13
+++++++++++++
A
sh/merge-repos.sh
|
121
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A
win32/disable-wd.reg
|
12
++++++++++++
A
win32/toggle-context-menu.cmd
|
8
++++++++
diff --git a/APKBUILD b/APKBUILD
@@ -0,0 +1,9 @@
+pkgname=scripts
+pkgver=0.1
+pkgrel=0
+pkgdesc="Common scripts I use, git.nply.org/scripts.git"
+url="https://git.nply.org/scripts"
+arch="all"
+license="CC-BY-4.0"
+depends="sh"
+source=""
diff --git a/README b/README
@@ -0,0 +1 @@
+ooo/ - out of ordinary
diff --git a/classify.sh b/classify.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Classify photos on year using exiftool
+
+for i in *.*; do
+    d="$(exiftool -T -createdate "$i")"
+    da="$(echo "${d}" | awk -F: '{print $1}')"
+    if [ -n "$da"  ] && [ "$da" != '-' ]; then
+        mkdir -p "$da"
+        mv "$i" "$da"
+    fi
+done
+
diff --git a/ffmpeg/ravisagar.sh b/ffmpeg/ravisagar.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+#Configurations
+VBR="1500k"
+FPS="24"
+BUFSIZE="3000k" #twice of bitrate
+QUAL="ultrafast"
+SIZE=1920x1080
+WEBCAMSIZE=320x240
+AUDIO_ENCODER="aac"
+CURRENT_DIRECTORY=${PWD}
+OUTPUT_EXTENSION=$1
+echo "Recording to path: $1 "
+TIMESTAMP=$(date "+%Y-%m-%d-%H-%M-%S")
+YOUTUBE_URL="rtmp://a.rtmp.youtube.com/live2"
+KEY="111-111-222"
+AUDIO_FILE="/home/ravisagar/projects/ffmpeg-livestreamer/songs/allsongs.mp3"
+# Use - pactl list sources, to check desktop audio source
+DESKTOP_AUDIO="usb-0000:02:00.0-2"
+#MIC=$(arecord -l | grep "Samson" | cut -d ':' -f 1 | cut -d ' ' -f 2)
+#command starts here
+ffmpeg \ #-video_size $SIZE \
+	-framerate $FPS -f x11grab -probesize 10M -thread_queue_size 8192 \
+	-f alsa -ac 2 -thread_queue_size 8192 -f pulse \
+	-ac 2 -thread_queue_size 8192 \
+	-filter_complex \
+	"[1:a]channelsplit=channel_layout=stereo:channels=FR, \
+	showfreqs=s=240x200:ascale=sqrt:cmode=combined:colors=#330000@0.5[right]; \
+	[1:a]channelsplit=channel_layout=stereo:channels=FL, \
+	showfreqs=s=240x200:ascale=sqrt:cmode=combined:colors=#330000@0.5,vflip[left]; \
+	[right][left]vstack[w]; \
+	[0:v][w]overlay=x=W-w-30-10:y=H-h-30+200-10[bg2]; \
+	[1:a]adelay=500|500,volume=2[a1]; \
+	[2:a]adelay=750|750[delayed]; \
+	[delayed][a1]amix=inputs=2[a]" \
+	-map "[v]" -map "[a]" \
+	-c:v libx264 -preset $QUAL -r $FPS -g $(($FPS *2)) -b:v $VBR -bufsize 3000k -maxrate $VBR \
+	-c:a $AUDIO_ENCODER -ar 44100 -b:a 128k -pix_fmt yuv420p \
+	~/$TIMESTAMP.$OUTPUT_EXTENSION
diff --git a/interesting/sha256sum.cmd b/interesting/sha256sum.cmd
@@ -0,0 +1,10 @@
+@echo off
+if [%1]==[] goto usage
+
+set STRING="%*"
+set TMPFILE="%TMP%\hash-%RANDOM%.tmp"
+echo | set /p=%STRING% > %TMPFILE%
+certutil -hashfile %TMPFILE% MD5 | findstr /v "hash"
+del %TMPFILE%
+goto :eof
+
diff --git a/misc/move-codefiles.sh b/misc/move-codefiles.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+
+for i in *.py *.md *.sh *.sql *.txt *.c *.png *.cmd *.css *.php *.js *.ico *.svg *.json; do
+    mv "$i" Gist/
+done
+
diff --git a/misc/update-dates-in-todotxt.sh b/misc/update-dates-in-todotxt.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+while read -r line; do
+    case "$line" in
+        x\ *) echo "$line" ;;
+        [0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\ *) echo "$line" ;;
+        *)
+            vdate="$(git log -S "$line" --reverse --format='%ad' --date=short | head -n1)"
+            if [ -n "$vdate" ]; then
+                echo "$vdate $line"
+            else
+                echo "$line"
+            fi
+            ;;
+    esac
+done < todo.txt
diff --git a/ooo/min-httpd.sh b/ooo/min-httpd.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+while true ; do (dd if=/dev/zero count=10000;echo -e "HTTP/1.1\n\n $(date)") | nc -l  1500  ; done
diff --git a/os/wifi-connect.sh b/os/wifi-connect.sh
@@ -1,5 +1,6 @@
 #!/bin/sh
 
+# TODO Use `pass` to get SSID and passwords
 WIFI_SSID=Home
 WIFI_PASS=Home
 
diff --git a/server/linode2sshconfig.jq b/server/linode2sshconfig.jq
@@ -0,0 +1,21 @@
+#!/usr/bin/env jq -rf
+
+"# vi: set ft=sshconfig\n",
+(.[] | 
+"# Created: \(.created)\n" +
+(if .tags and (.tags | length > 0) then
+    "# Tags: \(.tags | join(", "))\n"
+else "" end) +
+"Host \(.label)
+    Hostname \(.ipv4[0])
+    User root
+")
+# (if .region then
+#     "    # Region: \(.region)\n"
+# else "" end) +
+# (if .status then
+#     "    # Status: \(.status)\n"
+# else "" end)
+# (if .ipv4[1] then
+#     "    # Secondary IP: \(.ipv4[1])\n"
+# else "" end)
diff --git a/server/vultr2sshconfig.jq b/server/vultr2sshconfig.jq
@@ -0,0 +1,21 @@
+#!/usr/bin/env jq -rf
+
+"# vi: set ft=sshconfig\n",
+(.instances[] | 
+"# Created: \(.date_created)\n" +
+(if .tags and (.tags | length > 0) then
+    "# Tags: \(.tags | join(", "))\n"
+else "" end) +
+"Host \(.label)
+    Hostname \(.main_ip)
+    User root
+")
+# (if .region then
+#     "    # Region: \(.region)\n"
+# else "" end) +
+# (if .status then
+#     "    # Status: \(.status)\n"
+# else "" end)
+# (if .ipv4[1] then
+#     "    # Secondary IP: \(.ipv4[1])\n"
+# else "" end)
diff --git a/sh/exif-update-time.sh b/sh/exif-update-time.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+if [ $# -eq 0 ]; then
+    echo "Usage: exif-update-time.sh [YY:MM to update]"
+    exit 1
+fi
+
+date_to_update="$1"
+
+for i in *; do
+    component="$(exiftool.exe -d "%d %H:%M:%S" -DateTimeOriginal -s3 "$i")";
+    exiftool.exe "-AllDates=${date_to_update}:${component}" "$i";
+done
diff --git a/sh/merge-repos.sh b/sh/merge-repos.sh
@@ -0,0 +1,121 @@
+#!/bin/sh
+# merge-repos.sh - Merge multiple git repos, keep the latest, move others
+#
+# FIXME AI generated, human review not done yet, use with caution
+
+TARGET_BRANCH="main"  # Change to your branch name
+DELETE_FOLDER="deleted_repos"
+
+if [ $# -lt 2 ]; then
+    echo "Usage: $0 repo1 repo2 ..."
+    exit 1
+fi
+
+# Function to get the latest commit timestamp of a branch
+get_latest_commit_time() {
+    repo_path="$1"
+    branch="$2"
+    (cd "$repo_path" && git log -1 --format=%ct "$branch" 2>/dev/null || echo "0")
+}
+
+# Function to get directory mtime (fallback)
+get_dir_mtime() {
+    stat -c %Y "$1" 2>/dev/null || echo "0"
+}
+
+# Find the latest repository
+LATEST_REPO=""
+LATEST_TIME=0
+
+echo "Analyzing repositories to find the latest one..."
+
+for repo in "$@"; do
+    if [ ! -d "$repo/.git" ]; then
+        echo "Warning: $repo is not a git repository, skipping"
+        continue
+    fi
+    
+    # Try commit time first, fall back to mtime
+    commit_time=$(get_latest_commit_time "$repo" "$TARGET_BRANCH")
+    if [ "$commit_time" = "0" ]; then
+        echo "  $repo: No commits on $TARGET_BRANCH, using mtime"
+        current_time=$(get_dir_mtime "$repo")
+    else
+        echo "  $repo: Last commit $commit_time"
+        current_time=$commit_time
+    fi
+    
+    if [ $current_time -gt $LATEST_TIME ]; then
+        LATEST_TIME=$current_time
+        LATEST_REPO="$repo"
+    fi
+done
+
+if [ -z "$LATEST_REPO" ]; then
+    echo "Error: No valid repositories found"
+    exit 1
+fi
+
+echo "Latest repository: $LATEST_REPO (timestamp: $LATEST_TIME)"
+
+# Create delete folder
+mkdir -p "$DELETE_FOLDER"
+
+# Process each repository
+for repo in "$@"; do
+    if [ "$repo" = "$LATEST_REPO" ] || [ ! -d "$repo/.git" ]; then
+        continue
+    fi
+    
+    echo "Processing $repo..."
+    
+    # Add as remote to latest repo
+    repo_name=$(basename "$repo")
+    remote_name="temp_$repo_name"
+    
+    (cd "$LATEST_REPO" && 
+        git remote add "$remote_name" "../$repo" 2>/dev/null &&
+        git fetch "$remote_name" "$TARGET_BRANCH" 2>/dev/null)
+    
+    if [ $? -ne 0 ]; then
+        echo "  Failed to fetch from $repo, skipping"
+        continue
+    fi
+    
+    # Check if there are new commits
+    new_commits=$(cd "$LATEST_REPO" && git log "$TARGET_BRANCH..$remote_name/$TARGET_BRANCH" --oneline 2>/dev/null | wc -l)
+    
+    if [ "$new_commits" -gt 0 ]; then
+        echo "  Found $new_commits new commits"
+        
+        # Create patch files
+        patch_dir="patches_$repo_name"
+        mkdir -p "$patch_dir"
+        
+        (cd "$LATEST_REPO" && 
+            git format-patch -o "../$patch_dir" "$TARGET_BRANCH..$remote_name/$TARGET_BRANCH")
+        
+        echo "  Patches saved to $patch_dir"
+        
+        # Apply patches
+        (cd "$LATEST_REPO" && 
+            git checkout "$TARGET_BRANCH" &&
+            git am "../$patch_dir"/*.patch)
+        
+        if [ $? -eq 0 ]; then
+            echo "  Successfully merged commits from $repo"
+        else
+            echo "  Merge conflicts detected! Manual resolution needed"
+            echo "  Aborting patch application"
+            (cd "$LATEST_REPO" && git am --abort 2>/dev/null)
+        fi
+    else
+        echo "  No new commits found in $repo"
+    fi
+    
+    # Move processed repo to delete folder
+    mv "$repo" "$DELETE_FOLDER/"
+    echo "  Moved $repo to $DELETE_FOLDER/"
+done
+
+echo "Done! Latest repository: $LATEST_REPO"
diff --git a/win32/disable-wd.reg b/win32/disable-wd.reg
@@ -0,0 +1,12 @@
+Jvaqbjf Ertvfgel Rqvgbe Irefvba 5.00
+
+; Characters are rotated by 13 characters
+; Use g? if on the below characters if using vim
+
+[UXRL_YBPNY_ZNPUVAR\FBSGJNER\Cbyvpvrf\Zvpebfbsg\Jvaqbjf Qrsraqre]
+"QvfnoyrNagvFcljner"=qjbeq:00000001
+
+[UXRL_YBPNY_ZNPUVAR\FBSGJNER\Cbyvpvrf\Zvpebfbsg\Jvaqbjf Qrsraqre\Erny-Gvzr Cebgrpgvba]
+"QvfnoyrOrunivbheZbavgbevat"=qjbeq:00000001
+"QvfnoyrBaNpprffCebgrpgvba"=qjbeq:00000001
+"QvfnoyrFpnaBaErnygvzrRanoyr"=qjbeq:00000001
diff --git a/win32/toggle-context-menu.cmd b/win32/toggle-context-menu.cmd
@@ -0,0 +1,8 @@
+REM Reference: https://learn.microsoft.com/en-us/answers/questions/2287432/(article)-restore-old-right-click-context-menu-in
+
+REM Enable old menu
+reg.exe add "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}\InprocServer32" /f /ve
+
+REM Enable new menu
+reg.exe delete "HKCU\Software\Classes\CLSID\{86ca1aa0-34aa-4e8b-a509-50c905bae2a2}" /f
+