From 2f4467362d8eaabe357fdc5225221e6cae7670f1 Mon Sep 17 00:00:00 2001 From: sanj <67624670+iodrift@users.noreply.github.com> Date: Tue, 30 Jul 2024 19:30:24 -0700 Subject: [PATCH] Auto-update: Tue Jul 30 19:30:24 PDT 2024 --- 15 | 12 ++++ 2fa | 2 + Summarizer | 36 +++++++++++ VBoxAudioTest | 2 + VBoxAutostart | 2 + VBoxBalloonCtrl | 2 + VBoxBugReport | 2 + VBoxHeadless | 2 + VBoxManage | 2 + VBoxVRDP | 2 + all | 29 +++++++++ asf | 37 +++++++++++ asr copy | 22 +++++++ ccd | 3 + chat | 1 + checknode | 55 ++++++++++++++++ comfy | 26 ++++++++ emoji-flag | 14 ++++ fixname | 47 ++++++++++++++ fuzzy_match | 27 ++++++++ getreq | 37 +++++++++++ httpclient | 27 ++++++++ i | 46 +++++++++++++ import-finder | 144 +++++++++++++++++++++++++++++++++++++++++ ison | 29 +++++++++ llm | 12 ++++ lsd | 19 ++++++ mamba-exporter | 15 +++++ mamba-importer | 26 ++++++++ master | 3 + murder | 24 +++++++ nukenode | 68 +++++++++++++++++++ nv_mount | 7 ++ o | 8 +++ scrape | 79 ++++++++++++++++++++++ sij | 40 ++++++++++++ ssh-scrape | 23 +++++++ st | 5 ++ summarize | 39 +++++++++++ temp.txt | 33 ++++++++++ ts-info | 19 ++++++ ts-new-node-minimalist | 24 +++++++ tts copy | 85 ++++++++++++++++++++++++ txtsort | 16 +++++ update_calendar | 86 ++++++++++++++++++++++++ vbox-img | 2 + vboximg-mount | 2 + vm | 13 ++++ vpn | 126 ++++++++++++++++++++++++++++++------ xtts | 78 ++++++++++++++++++++++ z | 3 + 51 files changed, 1443 insertions(+), 20 deletions(-) create mode 100755 15 create mode 100755 2fa create mode 100755 Summarizer create mode 100755 VBoxAudioTest create mode 100755 VBoxAutostart create mode 100755 VBoxBalloonCtrl create mode 100755 VBoxBugReport create mode 100755 VBoxHeadless create mode 100755 VBoxManage create mode 100755 VBoxVRDP create mode 100755 all create mode 100755 asf create mode 100755 asr copy create mode 100755 ccd create mode 100755 chat create mode 100755 checknode create mode 100755 comfy create mode 100755 emoji-flag create mode 100755 fixname create mode 100755 fuzzy_match create mode 100755 getreq create mode 100755 httpclient create mode 100755 i create mode 100755 import-finder create mode 100755 ison create mode 100755 llm create mode 100755 lsd create mode 100755 mamba-exporter create mode 100755 mamba-importer create mode 100755 master create mode 100755 murder create mode 100755 nukenode create mode 100755 nv_mount create mode 100755 o create mode 100755 scrape create mode 100755 sij create mode 100755 ssh-scrape create mode 100755 st create mode 100755 summarize create mode 100644 temp.txt create mode 100755 ts-info create mode 100755 ts-new-node-minimalist create mode 100755 tts copy create mode 100755 txtsort create mode 100755 update_calendar create mode 100755 vbox-img create mode 100755 vboximg-mount create mode 100755 vm create mode 100755 xtts create mode 100755 z diff --git a/15 b/15 new file mode 100755 index 0000000..ea1e1ea --- /dev/null +++ b/15 @@ -0,0 +1,12 @@ +#!/bin/bash + +tailscale="/Applications/Tailscale.app/Contents/MacOS/Tailscale" + +if $tailscale status | grep -q "100."; then + echo "Connected to Tailscale, SSH'ing to 100.64.64.30..." + ssh sangye@100.64.64.30 +else + echo "Not connected to Tailscale, SSH'ing to 10.13.37.30..." + ssh sangye@10.13.37.30 +fi + diff --git a/2fa b/2fa new file mode 100755 index 0000000..22db023 --- /dev/null +++ b/2fa @@ -0,0 +1,2 @@ +source ~/.zshrc +python ~/.2fa.py diff --git a/Summarizer b/Summarizer new file mode 100755 index 0000000..cfa88d0 --- /dev/null +++ b/Summarizer @@ -0,0 +1,36 @@ +#!/bin/bash + +# Endpoint URL +endpoint="http://localhost:3456/summarize" + +# Function to check if port 3456 is open +is_port_open() { + nc -z localhost 3456 + return $? +} + +# Check if the FastAPI server is running (port 3456) +if ! is_port_open; then + echo "Starting BananaPhone.py..." + # Start the FastAPI server + /Users/sij/AI/banana-phone/BananaPhone.sh & + + # Wait for the server to start + echo "Waiting for server to start..." + until is_port_open; do + sleep 1 + done + echo "Server started." +fi + +# Loop through each file dropped onto the droplet +for f in "$@" +do + # POST request using curl + curl -X POST -H "Content-Type: multipart/form-data" \ + -H "Authorization: Bearer sk-NhrtQwCHNdK5sRZC" \ + -F "file=@$f" \ + -F "podcast=true" \ + -F "speed=1.2" \ + "$endpoint" +done diff --git a/VBoxAudioTest b/VBoxAudioTest new file mode 100755 index 0000000..dc27d4b --- /dev/null +++ b/VBoxAudioTest @@ -0,0 +1,2 @@ +#!/bin/bash +exec /Applications/VirtualBox.app/Contents/MacOS/VBoxAudioTest "$@" diff --git a/VBoxAutostart b/VBoxAutostart new file mode 100755 index 0000000..3d7c8f5 --- /dev/null +++ b/VBoxAutostart @@ -0,0 +1,2 @@ +#!/bin/bash +exec /Applications/VirtualBox.app/Contents/MacOS/VBoxAutostart "$@" diff --git a/VBoxBalloonCtrl b/VBoxBalloonCtrl new file mode 100755 index 0000000..b434e9f --- /dev/null +++ b/VBoxBalloonCtrl @@ -0,0 +1,2 @@ +#!/bin/bash +exec /Applications/VirtualBox.app/Contents/MacOS/VBoxBalloonCtrl "$@" diff --git a/VBoxBugReport b/VBoxBugReport new file mode 100755 index 0000000..1bc4613 --- /dev/null +++ b/VBoxBugReport @@ -0,0 +1,2 @@ +#!/bin/bash +exec /Applications/VirtualBox.app/Contents/MacOS/VBoxBugReport "$@" diff --git a/VBoxHeadless b/VBoxHeadless new file mode 100755 index 0000000..15dbd02 --- /dev/null +++ b/VBoxHeadless @@ -0,0 +1,2 @@ +#!/bin/bash +exec /Applications/VirtualBox.app/Contents/MacOS/VBoxHeadless "$@" diff --git a/VBoxManage b/VBoxManage new file mode 100755 index 0000000..c4087d6 --- /dev/null +++ b/VBoxManage @@ -0,0 +1,2 @@ +#!/bin/bash +exec /Applications/VirtualBox.app/Contents/MacOS/VBoxManage "$@" diff --git a/VBoxVRDP b/VBoxVRDP new file mode 100755 index 0000000..15dbd02 --- /dev/null +++ b/VBoxVRDP @@ -0,0 +1,2 @@ +#!/bin/bash +exec /Applications/VirtualBox.app/Contents/MacOS/VBoxHeadless "$@" diff --git a/all b/all new file mode 100755 index 0000000..0a84c7d --- /dev/null +++ b/all @@ -0,0 +1,29 @@ +#!/bin/bash + +# Create a new tmux session +tmux new-session -d -s servers -n 'ssh' + +# Split the first window horizontally +tmux split-window -h + +# Split the first and second panes vertically +tmux select-pane -t 0 +tmux split-window -v + +tmux select-pane -t 2 +tmux split-window -v + +# Function to connect to servers with retry +connect_to_server_with_retry() { + tmux send-keys -t "$1" "while true; do ssh $2; sleep 30; done" C-m +} + +# Connect to servers with retry +connect_to_server_with_retry 0 "100.64.64.11" +connect_to_server_with_retry 1 "100.64.64.30" +connect_to_server_with_retry 2 "100.64.64.15" +connect_to_server_with_retry 3 "root@10.13.37.10" + +# Attach to the tmux session +tmux attach -t servers + diff --git a/asf b/asf new file mode 100755 index 0000000..ee9baf4 --- /dev/null +++ b/asf @@ -0,0 +1,37 @@ +-- Mail Rule - Add messages to DEVONthink +-- Created by Christian Grunenberg on Mon Apr 19 2004. +-- Copyright (c) 2004-2020. All rights reserved. + +-- this string is used when the message subject is empty +property pNoSubjectString : "(no subject)" + +using terms from application "Mail" + on perform mail action with messages theMessages for rule theRule + tell application "Mail" + repeat with theMessage in theMessages + try + tell theMessage + set {theDateReceived, theDateSent, theSender, theSubject, theSource, theReadFlag} to {the date received, the date sent, the sender, subject, the source, the read status} + set theMessageURL to "message://%3c" & theMessage's message id & "%3e" + end tell + if theSubject is equal to "" then set theSubject to pNoSubjectString + tell application id "DNtp" + set username to do shell script "id -un" -- this will get the current username dynamically + set theDatabase to open database ("/Users/" & username & "/Databases/Professional.dtbase2") + set theYear to year of theDateReceived + set theMonth to texts -2 thru -1 of ("0" & (month of theDateReceived as integer)) + set theMonthName to month of theDateReceived as string + set theDay to texts -2 thru -1 of ("0" & (day of theDateReceived)) + set theWeekday to weekday of theDateReceived + set theGroup to create location ("/Notes/Journal/" & theYear & "/" & theYear & "-" & theMonth & " " & theMonthName & "/" & theYear & "-" & theMonth & "-" & theDay & " " & theWeekday & "/" & "Emails") in theDatabase + set theRecord to create record with {name:theSubject & ".eml", type:unknown, creation date:theDateSent, modification date:theDateReceived, URL:theSender, source:(theSource as string), unread:(not theReadFlag)} in theGroup + set theConvertedRecord to convert record theRecord to markdown + delete record theRecord + set URL of theConvertedRecord to theMessageURL + perform smart rule trigger import event record theConvertedRecord + end tell + end try + end repeat + end tell + end perform mail action with messages +end using terms from \ No newline at end of file diff --git a/asr copy b/asr copy new file mode 100755 index 0000000..3d922d7 --- /dev/null +++ b/asr copy @@ -0,0 +1,22 @@ +#!/bin/bash + +# Check if a filename is provided +if [ "$#" -ne 1 ]; then + echo "Usage: $0 filename" + exit 1 +fi + +# Assign the first argument to FILENAME +FILENAME="$1" + +# Check if the file exists +if [ ! -f "$FILENAME" ]; then + echo "Error: File not found - $FILENAME" + exit 1 +fi + +# Perform the curl POST request with the file +curl -X POST http://127.0.0.1:3456/v1/asr \ +-H 'Authorization: bearer sk-NhrtQwCHNdK5sRZC' \ +-F "file=@$FILENAME" + diff --git a/ccd b/ccd new file mode 100755 index 0000000..1c3fc22 --- /dev/null +++ b/ccd @@ -0,0 +1,3 @@ +#!/bin/bash +cd $1 +ls -lsa diff --git a/chat b/chat new file mode 100755 index 0000000..3f82620 --- /dev/null +++ b/chat @@ -0,0 +1 @@ +python /usr/local/bin/chat.py diff --git a/checknode b/checknode new file mode 100755 index 0000000..327a6e6 --- /dev/null +++ b/checknode @@ -0,0 +1,55 @@ +#!/bin/bash + +echo "Checking for remnants of Node.js, npm, and nvm..." + +# Check PATH +echo "Checking PATH..." +echo $PATH | grep -q 'node\|npm' && echo "Found Node.js or npm in PATH" + +# Check Homebrew +echo "Checking Homebrew..." +brew list | grep -q 'node\|npm' && echo "Found Node.js or npm installed with Homebrew" + +# Check Yarn +echo "Checking Yarn..." +command -v yarn >/dev/null 2>&1 && echo "Found Yarn" + +# Check Node.js and npm directories +echo "Checking Node.js and npm directories..." +ls ~/.npm >/dev/null 2>&1 && echo "Found ~/.npm directory" +ls ~/.node-gyp >/dev/null 2>&1 && echo "Found ~/.node-gyp directory" + +# Check open files and sockets +echo "Checking open files and sockets..." +lsof | grep -q 'node' && echo "Found open files or sockets related to Node.js" + +# Check other version managers +echo "Checking other version managers..." +command -v n >/dev/null 2>&1 && echo "Found 'n' version manager" + +# Check temporary directories +echo "Checking temporary directories..." +ls /tmp | grep -q 'node\|npm' && echo "Found Node.js or npm related files in /tmp" + +# Check Browserify and Webpack cache +echo "Checking Browserify and Webpack cache..." +ls ~/.config/browserify >/dev/null 2>&1 && echo "Found Browserify cache" +ls ~/.config/webpack >/dev/null 2>&1 && echo "Found Webpack cache" + +# Check Electron cache +echo "Checking Electron cache..." +ls ~/.electron >/dev/null 2>&1 && echo "Found Electron cache" + +# Check logs +echo "Checking logs..." +ls ~/.npm/_logs >/dev/null 2>&1 && echo "Found npm logs" +ls ~/.node-gyp/*.log >/dev/null 2>&1 && echo "Found Node.js logs" + +# Check miscellaneous directories +echo "Checking miscellaneous directories..." +ls ~/.node_repl_history >/dev/null 2>&1 && echo "Found ~/.node_repl_history" +ls ~/.v8flags* >/dev/null 2>&1 && echo "Found ~/.v8flags*" +ls ~/.npm-global >/dev/null 2>&1 && echo "Found ~/.npm-global" +ls ~/.nvm-global >/dev/null 2>&1 && echo "Found ~/.nvm-global" + +echo "Check completed." diff --git a/comfy b/comfy new file mode 100755 index 0000000..3093b61 --- /dev/null +++ b/comfy @@ -0,0 +1,26 @@ +#!/bin/bash + +# Create a new tmux session named "comfy" detached (-d) and start the first command in the left pane +tmux new-session -d -s comfy -n comfypane + +# Split the window into two panes. By default, this creates a vertical split. +tmux split-window -h -t comfy + +# Select the first pane to setup comfy environment +tmux select-pane -t 0 +COMFY_MAMBA=$(mamba env list | grep "^comfy" | awk '{print $2}') +tmux send-keys -t 0 "cd ~/workshop/sd/ComfyUI" C-m +tmux send-keys -t 0 "export PATH=\"$COMFY_MAMBA/bin:\$PATH\"" C-m +tmux send-keys -t 0 "source ~/.zshrc" C-m +tmux send-keys -t 0 "mamba activate comfy; sleep 1; while true; do PYTORCH_MPS_HIGH_WATERMARK_RATIO=0.0 PYTORCH_ENABLE_MPS_FALLBACK=1 python main.py --preview-method auto --force-fp16 --enable-cors-header; exit_status=\$?; if [ \$exit_status -ne 0 ]; then osascript -e 'display notification \"ComfyUI script exited unexpectedly\" with title \"Error in ComfyUI\"'; fi; sleep 1; done" C-m + +# Select the second pane to setup extracomfy environment +tmux select-pane -t 1 +IG_MAMBA=$(mamba env list | grep "^insta" | awk '{print $2}') +tmux send-keys -t 1 "export PATH=\"$IG_MAMBA/bin:\$PATH\"" C-m +tmux send-keys -t 1 "source ~/.zshrc" C-m +tmux send-keys -t 1 "mamba activate instabot; cd workshop/igbot" C-m + +# Attach to the tmux session +# tmux attach -t comfy + diff --git a/emoji-flag b/emoji-flag new file mode 100755 index 0000000..eba028f --- /dev/null +++ b/emoji-flag @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +import sys + +def flag_emoji(country_code): + offset = 127397 + flag = ''.join(chr(ord(char) + offset) for char in country_code.upper()) + return flag + +if __name__ == "__main__": + if len(sys.argv) > 1: + country_code = sys.argv[1] + print(flag_emoji(country_code)) + else: + print("No country code provided") \ No newline at end of file diff --git a/fixname b/fixname new file mode 100755 index 0000000..602a9a5 --- /dev/null +++ b/fixname @@ -0,0 +1,47 @@ +#!/bin/bash + +# Check if enough arguments are passed +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +# Function to truncate filename to a maximum length, preserving the extension +truncate_filename() { + local filename="$1" + local max_length="$2" + local extension="${filename##*.}" + local base_name="${filename%.*}" + + if [ ${#filename} -gt $max_length ]; then + local truncated_base="${base_name:0:($max_length - ${#extension} - 1)}" + echo "${truncated_base}.${extension}" + else + echo "$filename" + fi +} + +# Read the file paths from the input file +while IFS= read -r file_path; do + # Extract the directory and filename + dir_path=$(dirname "$file_path") + file_name=$(basename "$file_path") + + # Define the new filename by replacing or removing illegal characters + new_file_name=$(echo "$file_name" | tr -d '<>:"/\\|?*' | tr '[:cntrl:]' '_' | sed 's/[—·]/-/g' | sed 's/"/_/g' | sed "s/'/_/g") + + # Ensure filename does not end with an underscore + new_file_name=$(echo "$new_file_name" | sed 's/_$//') + + # Truncate the filename if it is longer than 200 characters, preserving the extension + new_file_name=$(truncate_filename "$new_file_name" 200) + + # Construct the new path + new_path="$dir_path/$new_file_name" + + # Rename the file if necessary + if [ "$new_file_name" != "$file_name" ]; then + echo "Renaming '$file_path' to '$new_path'" + mv "$file_path" "$new_path" + fi +done <"$1" diff --git a/fuzzy_match b/fuzzy_match new file mode 100755 index 0000000..2372492 --- /dev/null +++ b/fuzzy_match @@ -0,0 +1,27 @@ +#!/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby +# +# This file was generated by RubyGems. +# +# The application 'fuzzy_match' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'rubygems' + +version = ">= 0.a" + +str = ARGV.first +if str + str = str.b[/\A_(.*)_\z/, 1] + if str and Gem::Version.correct?(str) + version = str + ARGV.shift + end +end + +if Gem.respond_to?(:activate_bin_path) +load Gem.activate_bin_path('fuzzy_match', 'fuzzy_match', version) +else +gem "fuzzy_match", version +load Gem.bin_path("fuzzy_match", "fuzzy_match", version) +end diff --git a/getreq b/getreq new file mode 100755 index 0000000..3ee156d --- /dev/null +++ b/getreq @@ -0,0 +1,37 @@ +#!/bin/bash + +# Script to find Python imports and install them if necessary + +# Check for input argument +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +PYTHON_FILE="$1" + +# Extract import statements +IMPORTS=$(grep -E "^import |^from " "$PYTHON_FILE" | \ + awk '{print $2}' | cut -d. -f1 | sort | uniq) + +# Function to check and install packages +check_and_install() { + PACKAGE=$1 + # Check if the package is installed via pip + if pip list | grep -q "^$PACKAGE "; then + echo "$PACKAGE is already installed via pip." + # Check if the package is installed via conda + elif conda list | grep -q "^$PACKAGE "; then + echo "$PACKAGE is already installed via conda." + else + # Install the package using kip + echo "Installing $PACKAGE using kip..." + kip install "$PACKAGE" + fi +} + +# Iterate over imports and check/install them +for pkg in $IMPORTS; do + check_and_install $pkg +done + diff --git a/httpclient b/httpclient new file mode 100755 index 0000000..1f8481d --- /dev/null +++ b/httpclient @@ -0,0 +1,27 @@ +#!/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby +# +# This file was generated by RubyGems. +# +# The application 'httpclient' is installed as part of a gem, and +# this file is here to facilitate running it. +# + +require 'rubygems' + +version = ">= 0.a" + +str = ARGV.first +if str + str = str.b[/\A_(.*)_\z/, 1] + if str and Gem::Version.correct?(str) + version = str + ARGV.shift + end +end + +if Gem.respond_to?(:activate_bin_path) +load Gem.activate_bin_path('httpclient', 'httpclient', version) +else +gem "httpclient", version +load Gem.bin_path("httpclient", "httpclient", version) +end diff --git a/i b/i new file mode 100755 index 0000000..44a17dd --- /dev/null +++ b/i @@ -0,0 +1,46 @@ +#!/Users/sij/miniforge3/envs/minicpm/bin/python +import os +import torch +from transformers import AutoModel, AutoTokenizer +from PIL import Image +import argparse + +# Set environment variable to enable CPU fallback +os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = "1" + +# Parse command line arguments +parser = argparse.ArgumentParser(description='Process image for model.') +parser.add_argument('image_path', type=str, help='Path to the image file') +args = parser.parse_args() + +# Check if MPS is available +if torch.backends.mps.is_available(): + device = torch.device("mps") +else: + device = torch.device("cpu") + +# Load the model with appropriate torch dtype +model = AutoModel.from_pretrained('openbmb/MiniCPM-Llama3-V-2_5', trust_remote_code=True, torch_dtype=torch.float32 if device == torch.device("cpu") else torch.float16) +model = model.to(device) + +tokenizer = AutoTokenizer.from_pretrained('openbmb/MiniCPM-Llama3-V-2_5', trust_remote_code=True) +model.eval() + +# Load and prepare the image +image_path = "/Users/sij/adorablenakedskinny.jpeg" # args.image_path +image = Image.open(image_path).convert('RGB') +question = 'Using modern English and adult slang words like cock, cum, pussy, fuck, etc., describe the scene pictured in the image.' +msgs = [{'role': 'user', 'content': question}] + +# Perform inference +with torch.no_grad(): + res = model.chat( + image=image, + msgs=msgs, + tokenizer=tokenizer, + sampling=True, + temperature=0.7 + ) + +print(res) + diff --git a/import-finder b/import-finder new file mode 100755 index 0000000..41cbf6b --- /dev/null +++ b/import-finder @@ -0,0 +1,144 @@ +#!/usr/bin/env python3 + +import os +import re +import requests +import time +import pkg_resources + +# List of Python built-in modules +BUILTIN_MODULES = { + 'abc', 'aifc', 'argparse', 'array', 'ast', 'asynchat', 'asyncio', 'asyncore', 'atexit', + 'audioop', 'base64', 'bdb', 'binascii', 'binhex', 'bisect', 'builtins', 'bz2', 'calendar', + 'cgi', 'cgitb', 'chunk', 'cmath', 'cmd', 'code', 'codecs', 'codeop', 'collections', 'colorsys', + 'compileall', 'concurrent', 'configparser', 'contextlib', 'copy', 'copyreg', 'crypt', 'csv', + 'ctypes', 'curses', 'dataclasses', 'datetime', 'dbm', 'decimal', 'difflib', 'dis', 'distutils', + 'doctest', 'dummy_threading', 'email', 'encodings', 'ensurepip', 'enum', 'errno', 'faulthandler', + 'fcntl', 'filecmp', 'fileinput', 'fnmatch', 'formatter', 'fractions', 'ftplib', 'functools', + 'gc', 'getopt', 'getpass', 'gettext', 'glob', 'gzip', 'hashlib', 'heapq', 'hmac', 'html', 'http', + 'imaplib', 'imghdr', 'imp', 'importlib', 'inspect', 'io', 'ipaddress', 'itertools', 'json', + 'keyword', 'lib2to3', 'linecache', 'locale', 'logging', 'lzma', 'mailbox', 'mailcap', 'marshal', + 'math', 'mimetypes', 'modulefinder', 'multiprocessing', 'netrc', 'nntplib', 'numbers', 'operator', + 'optparse', 'os', 'ossaudiodev', 'parser', 'pathlib', 'pdb', 'pickle', 'pickletools', 'pipes', + 'pkgutil', 'platform', 'plistlib', 'poplib', 'posix', 'pprint', 'profile', 'pstats', 'pty', + 'pwd', 'py_compile', 'pyclbr', 'pydoc', 'queue', 'quopri', 'random', 're', 'readline', + 'reprlib', 'resource', 'rlcompleter', 'runpy', 'sched', 'secrets', 'select', 'selectors', 'shelve', + 'shlex', 'shutil', 'signal', 'site', 'smtpd', 'smtplib', 'sndhdr', 'socket', 'socketserver', + 'spwd', 'sqlite3', 'ssl', 'stat', 'statistics', 'string', 'stringprep', 'struct', 'subprocess', + 'sunau', 'symtable', 'sys', 'sysconfig', 'syslog', 'tabnanny', 'tarfile', 'telnetlib', 'tempfile', + 'termios', 'test', 'textwrap', 'threading', 'time', 'timeit', 'token', 'tokenize', 'trace', + 'traceback', 'tracemalloc', 'tty', 'turtle', 'types', 'typing', 'unicodedata', 'unittest', + 'urllib', 'uu', 'uuid', 'venv', 'warnings', 'wave', 'weakref', 'webbrowser', 'xdrlib', 'xml', + 'xmlrpc', 'zipapp', 'zipfile', 'zipimport', 'zlib' +} + +# Known corrections for PyPI package names +KNOWN_CORRECTIONS = { + 'dateutil': 'python-dateutil', + 'dotenv': 'python-dotenv', + 'docx': 'python-docx', + 'tesseract': 'pytesseract', + 'magic': 'python-magic', + 'multipart': 'python-multipart', + 'newspaper': 'newspaper3k', + 'srtm': 'elevation', + 'yaml': 'pyyaml', + 'zoneinfo': 'backports.zoneinfo' +} + +# List of generic names to exclude +EXCLUDED_NAMES = {'models', 'data', 'convert', 'example', 'tests'} + +def find_imports(root_dir): + imports_by_file = {} + for dirpath, _, filenames in os.walk(root_dir): + for filename in filenames: + if filename.endswith('.py'): + filepath = os.path.join(dirpath, filename) + with open(filepath, 'r') as file: + import_lines = [] + for line in file: + line = line.strip() + if line.startswith(('import ', 'from ')) and not line.startswith('#'): + import_lines.append(line) + imports_by_file[filepath] = import_lines + return imports_by_file + +def process_import_lines(import_lines): + processed_lines = set() # Use a set to remove duplicates + for line in import_lines: + # Handle 'import xyz' and 'import abc, def, geh' + if line.startswith('import '): + modules = line.replace('import ', '').split(',') + for mod in modules: + mod = re.sub(r'\s+as\s+\w+', '', mod).split('.')[0].strip() + if mod and not mod.isupper() and mod not in EXCLUDED_NAMES: + processed_lines.add(mod) + # Handle 'from abc import def, geh' + elif line.startswith('from '): + mod = line.split(' ')[1].split('.')[0].strip() + if mod and not mod.isupper() and mod not in EXCLUDED_NAMES: + processed_lines.add(mod) + return processed_lines + +def check_pypi_availability(libraries): + available = set() + unavailable = set() + for lib in libraries: + if lib in BUILTIN_MODULES: # Skip built-in modules + continue + corrected_lib = KNOWN_CORRECTIONS.get(lib, lib) + try: + if check_library_on_pypi(corrected_lib): + available.add(corrected_lib) + else: + unavailable.add(corrected_lib) + except requests.exceptions.RequestException: + print(f"Warning: Unable to check {corrected_lib} on PyPI due to network error.") + unavailable.add(corrected_lib) + return available, unavailable + +def check_library_on_pypi(library): + max_retries = 3 + for attempt in range(max_retries): + try: + response = requests.get(f"https://pypi.org/pypi/{library}/json", timeout=5) + return response.status_code == 200 + except requests.exceptions.RequestException: + if attempt < max_retries - 1: + time.sleep(1) # Wait for 1 second before retrying + else: + raise + +def save_to_requirements_file(available, output_file='requirements.txt'): + existing_requirements = set() + if os.path.isfile(output_file): + with open(output_file, 'r') as file: + existing_requirements = set(line.strip() for line in file) + with open(output_file, 'a') as file: + for pkg in sorted(available - existing_requirements): + print(f"Adding to requirements.txt: {pkg}") + file.write(pkg + '\n') + +def save_to_missing_file(unavailable, output_file='missing-packages.txt'): + existing_missing = set() + if os.path.isfile(output_file): + with open(output_file, 'r') as file: + existing_missing = set(line.strip() for line in file) + with open(output_file, 'a') as file: + for pkg in sorted(unavailable - existing_missing): + print(f"Adding to missing-packages.txt: {pkg}") + file.write(pkg + '\n') + +if __name__ == "__main__": + root_dir = os.getcwd() # Get the current working directory + + imports_by_file = find_imports(root_dir) + for filepath, import_lines in imports_by_file.items(): + print(f"# Processing {filepath}") + processed_lines = process_import_lines(import_lines) + available, unavailable = check_pypi_availability(processed_lines) + save_to_requirements_file(available) + save_to_missing_file(unavailable) + + print(f"Processed import statements have been saved to requirements.txt and missing-packages.txt") diff --git a/ison b/ison new file mode 100755 index 0000000..323a7f9 --- /dev/null +++ b/ison @@ -0,0 +1,29 @@ +#!/Users/sij/miniforge3/envs/sijapi/bin/python + +import requests + +def check_health(url): + try: + response = requests.get(url) + if response.status_code == 200: + return f"{url} is up" + else: + return f"{url} returned status code {response.status_code}" + except requests.exceptions.RequestException: + return f"{url} is down" + +def main(): + addresses = [ + "http://localhost:4444/health", + "http://100.64.64.20:4444/health", + "http://100.64.64.30:4444/health", + "http://100.64.64.11:4444/health", + "http://100.64.64.15:4444/health" + ] + + for address in addresses: + print(check_health(address)) + +if __name__ == "__main__": + main() + diff --git a/llm b/llm new file mode 100755 index 0000000..0bf58bf --- /dev/null +++ b/llm @@ -0,0 +1,12 @@ +#!/bin/bash +murder ollama +tmux new-session -d -s ollama -n ollamapane + +tmux split-window -h -t ollama +tmux select-pane -t 0 +tmux send-keys -t 0 "source ~/.zshrc" C-m +tmux send-keys -t 0 "ollama serve; sleep 1" C-m + +tmux select-pane -t 1 +tmux send-keys -t 1 "source ~/.zshrc" C-m + diff --git a/lsd b/lsd new file mode 100755 index 0000000..963f539 --- /dev/null +++ b/lsd @@ -0,0 +1,19 @@ +#!/bin/bash + +# Default options for lsd +default_options="--color=always -F --long --size=short --permission=octal --group-dirs=first -X" + +# Check if the first argument is a directory or an option +if [[ $# -gt 0 && ! $1 =~ ^- ]]; then + # First argument is a directory, store it and remove from arguments list + directory=$1 + shift +else + # No directory specified, default to the current directory + directory="." +fi + +# Execute lsd with the default options, directory, and any additional arguments provided +/opt/homebrew/bin/lsd $default_options "$directory" "$@" + + diff --git a/mamba-exporter b/mamba-exporter new file mode 100755 index 0000000..176e713 --- /dev/null +++ b/mamba-exporter @@ -0,0 +1,15 @@ +#!/bin/bash + +# List all conda environments and cut the output to get just the names +envs=$(mamba env list | awk '{print $1}' | grep -v '^#' | grep -v 'base') + +# Loop through each environment name +for env in $envs; do + # Use conda (or mamba, but conda is preferred for compatibility reasons) to export the environment to a YAML file + # No need to activate the environment; conda can export directly by specifying the name + echo "Exporting $env..." + mamba env export --name $env > "${env}.yml" +done + +echo "All environments have been exported." + diff --git a/mamba-importer b/mamba-importer new file mode 100755 index 0000000..79886e1 --- /dev/null +++ b/mamba-importer @@ -0,0 +1,26 @@ +#!/bin/bash + +# Function to process a single .yml file +process_file() { + file="$1" + if [[ -f "$file" ]]; then + env_name=$(echo "$file" | sed 's/.yml$//') + echo "Creating environment from $file..." + conda env create -f "$file" || echo "Failed to create environment from $file" + else + echo "File $file does not exist." + fi +} + +# Check if a .yml file was provided as an argument +if [[ $# -eq 1 && $1 == *.yml ]]; then + # Process the provided .yml file + process_file "$1" +else + # No argument provided, process all .yml files in the current directory + for file in *.yml; do + process_file "$file" + done + echo "Environment creation process completed." +fi + diff --git a/master b/master new file mode 100755 index 0000000..f84353a --- /dev/null +++ b/master @@ -0,0 +1,3 @@ +st +api +comfy diff --git a/murder b/murder new file mode 100755 index 0000000..3c76f1b --- /dev/null +++ b/murder @@ -0,0 +1,24 @@ +#!/bin/bash + +# Check if an argument is given +if [ $# -eq 0 ]; then + echo "Usage: murder [process name or port]" + exit 1 +fi + +# Get the input parameter +ARGUMENT=$1 + +# Check if the argument is numeric +if [[ $ARGUMENT =~ ^[0-9]+$ ]]; then + echo "Killing processes listening on port $ARGUMENT" + lsof -t -i:$ARGUMENT | xargs kill +else + # Process name was given instead of a port number + echo "Killing processes with name $ARGUMENT" + for PID in $(ps aux | grep $ARGUMENT | grep -v grep | awk '{print $2}'); do + echo "Killing process $PID" + sudo kill -9 $PID + done +fi + diff --git a/nukenode b/nukenode new file mode 100755 index 0000000..d3ca83d --- /dev/null +++ b/nukenode @@ -0,0 +1,68 @@ +#!/bin/bash + +# Uninstall global npm packages +npm ls -gp --depth=0 | awk -F/ '/node_modules/ && !/\/npm$/ {print $NF}' | xargs npm -g rm + +# Uninstall Node.js and npm +brew uninstall node +brew uninstall npm + +# Remove npm, Node.js, and nvm directories +sudo rm -rf /usr/local/lib/node_modules +sudo rm -rf ~/.npm +sudo rm -rf /usr/local/bin/npm +sudo rm -rf /usr/local/share/man/man1/node* +sudo rm -rf /usr/local/bin/node +sudo rm -rf /usr/local/lib/node_modules/ +sudo rm -rf /usr/local/include/node/ +rm -rf ~/.nvm + +# Clean up Node.js and npm related files +sudo rm -rf ~/.node* +sudo rm -rf ~/.npm* + +# Remove Yarn +brew uninstall yarn +rm -rf ~/.yarn + +# Clean up Homebrew +brew cleanup + +# Remove package manager cache +rm -rf ~/.yarn-cache +rm -rf ~/.pnpm-store + +# Remove other version managers +brew uninstall n +rm -rf /usr/local/n +rm -rf /usr/local/bin/n + +# Remove temporary directories +rm -rf /tmp/npm-* +rm -rf /tmp/node-* +rm -rf ~/Library/Caches/com.apple.DiagnosticReporting.nettopologyd/node_modules/ + +# Remove Browserify and Webpack cache +rm -rf ~/.config/browserify +rm -rf ~/.config/webpack +rm -rf ~/.cache/webpack + +# Remove Electron cache +rm -rf ~/.electron + +# Remove npm and Node.js logs +rm -rf ~/.npm/_logs +rm -rf ~/.node-gyp/*.log + +# Remove miscellaneous directories +rm -rf ~/.node_repl_history +rm -rf ~/.v8flags* +rm -rf ~/.npm-global +rm -rf ~/.nvm-global + +# Remove any references to Node.js or npm from shell profile files +sed -i '' '/# Node.js/d' ~/.bashrc ~/.bash_profile ~/.zshrc +sed -i '' '/export PATH=.*node.*/d' ~/.bashrc ~/.bash_profile ~/.zshrc +sed -i '' '/export PATH=.*npm.*/d' ~/.bashrc ~/.bash_profile ~/.zshrc + +echo "Node.js, npm, and nvm have been removed." diff --git a/nv_mount b/nv_mount new file mode 100755 index 0000000..c0d9959 --- /dev/null +++ b/nv_mount @@ -0,0 +1,7 @@ +#!/bin/bash + +SESSION_NAME="$1" +# Attach to tmux session and activate Conda environment +tmux send-keys -t "$SESSION_NAME" "conda activate $SESSION_NAME" C-m +tmux attach -t "$SESSION_NAME" + diff --git a/o b/o new file mode 100755 index 0000000..d763e15 --- /dev/null +++ b/o @@ -0,0 +1,8 @@ +#! /bin/bash + +if [[ -z $(pidof ollama) ]]; then + ollama serve &>/dev/null & + disown +fi + +/usr/bin/env python3 /Users/sij/AI/osh/osh.py $@ diff --git a/scrape b/scrape new file mode 100755 index 0000000..09255ff --- /dev/null +++ b/scrape @@ -0,0 +1,79 @@ +#!/bin/bash + +# Network share URL +NETWORK_SHARE="smb://10.13.37.10/Media" + +# Attempt to open the network share using Finder +# echo "Attempting to mount the network share..." +# open "${NETWORK_SHARE}" || { echo "Failed to access network share."; exit 1; } + +# Optionally, add a sleep command to allow some time for the share to mount before proceeding. +# sleep 5 + +# First input argument, could be a URL or a variant +FIRST_ARG="$1" + +# Function to detect if the input is a URL +is_url() { + if [[ "$1" =~ ^https?:// ]]; then + echo "true" + else + echo "false" + fi +} + +# Function to determine the variant based on the URL's domain +detect_variant_from_url() { + local domain=$(echo "$FIRST_ARG" | awk -F/ '{print $3}' | sed -e 's/^www\.//') + + case "$domain" in + *incestflix.com) + echo "if" + ;; + *xvideos.com) + echo "xv" + ;; + *familyporn.tv) + echo "fptv" + ;; + *pornhub.com) + echo "ph" + ;; + *motherless.com) + echo "ml" + ;; + *xnxx.com) + echo "xnxx" + ;; + *9vids.com) + echo "9v" + ;; + *) + echo "unrecognized" + ;; + esac +} + +# Determine if the first argument is a URL +if [[ $(is_url "$FIRST_ARG") == "true" ]]; then + VARIANT=$(detect_variant_from_url) + if [ "$VARIANT" = "unrecognized" ]; then + echo "Domain not recognized. Exiting." + exit 1 + fi + # For URLs, pass the entire set of arguments to the scraper script + ARGS="$@" +else + # For direct variant inputs, the variant is the first argument, and the rest are additional parameters + VARIANT="$1" + # Shift the first argument off, leaving the rest as $@ + shift + ARGS="$@" +fi + +# Activate the Conda environment +source /home/sij/miniforge3/bin/activate scrape + +# Run the Python script, adjusting for either URL or direct variant input +/home/sij/miniforge3/envs/scrape/bin/python "/home/sij/workshop/.private/videoscraper/videoscraper-$VARIANT.py" $ARGS + diff --git a/sij b/sij new file mode 100755 index 0000000..9efd0bf --- /dev/null +++ b/sij @@ -0,0 +1,40 @@ +#!/bin/zsh +# #!/bin/bash +source /Users/sij/.zshrc + +# Kill the existing tmux server +tmux kill-server +sleep 2 + +# Create the main session and windows +tmux new-session -d -s sijapi -n 'Main' + +# Split the main window into three vertical panes +tmux split-window -v -t sijapi:Main +#tmux split-window -v -t sijapi:Main +tmux select-layout even-vertical + +# Configure API pane (top pane) +tmux select-pane -t 0 +tmux send-keys "cd ~/workshop" C-m +tmux send-keys "source ~/.zshrc; sleep 1" C-m +tmux send-keys "mamba activate sijapi; while true; do python -m sijapi; sleep 1; done" C-m + +# Configure Khoj (middle pane) +tmux select-pane -t 1 +tmux send-keys "source ~/.zshrc" C-m +tmux send-keys "mamba activate khoj; export KHOJ_DOMAIN=ai.sij.ai && export KHOJ_ADMIN_EMAIL=sij@env.esq && export KHOJ_ADMIN_PASSWORD='Synchr0!-K' && export KHOJ_DEBUG=True && export DEBUG=true && while true; do khoj --anonymous-mode; sleep 1; done" C-m + +# Configure Ollama (bottom pane) +tmux select-pane -t 1 +tmux send-keys "cd ~/sync/sijapi/api" C-m +tmux send-keys "source ~/.zshrc; sleep 1" C-m +tmux send-keys "while true; do export OLLAMA_HOST='0.0.0.0:11434' && export OLLAMA_ORIGINS='*' && ollama serve; sleep 1; done" C-m + +# Create separate session for Syncthing +# tmux new-session -d -s syncthing -n 'Syncthing' +# tmux send-keys "source ~/.zshrc" C-m +# tmux send-keys "while true; do /opt/homebrew/bin/syncthing; done" C-m + +# Attach to the main tmux session +tmux attach-session -t sijapi diff --git a/ssh-scrape b/ssh-scrape new file mode 100755 index 0000000..4ef35c7 --- /dev/null +++ b/ssh-scrape @@ -0,0 +1,23 @@ +#!/bin/bash + +if [ "$#" -lt 2 ]; then + echo "Error: No command provided." + exit 1 +fi + +variant=$1 +shift # Remove the first argument, which is now stored in 'variant' +additional_params="$@" # Remaining arguments + +quoted_params="" +for param in "$@"; do + quoted_params+="\"$param\" " +done + +session_name="scrape-$(date +%Y%m%d%H%M%S)" +tailscale up +tmux new-session -d -s "$session_name" +ssh_command="ssh -t sij@vm 'tmux new-session -d -s \"$session_name\" \"/usr/local/bin/scrape ${variant} ${quoted_params}\"; tmux attach-session -t \"$session_name\"'" +tmux send-keys -t "$session_name" "$ssh_command" C-m +tmux attach-session -t "$session_name" + diff --git a/st b/st new file mode 100755 index 0000000..212dbf7 --- /dev/null +++ b/st @@ -0,0 +1,5 @@ +#!/bin/bash + +tmux new-session -d -s syncthing -n syncthingpane +tmux select-pane -t 0 +tmux send-keys -t 0 "/opt/homebrew/bin/syncthing" C-m diff --git a/summarize b/summarize new file mode 100755 index 0000000..483de30 --- /dev/null +++ b/summarize @@ -0,0 +1,39 @@ +#!/bin/bash + +# Check if a filename has been provided +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +filename="$1" + +# Check if the file exists +if [ ! -f "$filename" ]; then + echo "Error: File does not exist." + exit 1 +fi + +# Assuming GLOBAL_API_KEY is exported in your environment +if [ -z "$GLOBAL_API_KEY" ]; then + echo "Error: GLOBAL_API_KEY is not set." + exit 1 +fi + +# Endpoint +endpoint="https://api.sij.ai/speaksummary" + +# Make the request +curl -X POST "$endpoint" \ + -H "Authorization: Bearer $GLOBAL_API_KEY" \ + -H "Content-Type: multipart/form-data" \ + -F "file=@$filename" \ + -o "response.wav" + +# Check if the output was saved successfully +if [ -f "response.wav" ]; then + echo "The summary has been processed and saved as 'response.wav'" +else + echo "Failed to save the summary." +fi + diff --git a/temp.txt b/temp.txt new file mode 100644 index 0000000..d0ef244 --- /dev/null +++ b/temp.txt @@ -0,0 +1,33 @@ +List of files in /Users/sij/Nextcloud/notes with nonconforming names: + +/Users/sij/Nextcloud/notes/clippings/Personal — Mac (Metal) support- · Issue #114 · yl4579-StyleTTS2-58274.md +/Users/sij/Nextcloud/notes/clippings/Dependencies missing for Insightface · Issue #162 · cubiq-ComfyUI_IPAdapter_plus · GitHub-12313.md +/Users/sij/Nextcloud/notes/clippings/Personal — Enable opening from Finder · Issue #102 · warpdotdev-Warp-50868.md +/Users/sij/Nextcloud/notes/clippings/Personal — TTS example on colab not working · Issue #113 · mozilla-TTS-32446.md +/Users/sij/Nextcloud/notes/unsorted/<% tp.date.now("YYYY-MM-DD dddd", 1, tp.file.title, "YYYY-MM-DD dddd") %>.md +/Users/sij/Nextcloud/notes/unsorted/Awareness > Thought.md +/Users/sij/Nextcloud/notes/unsorted/Debate on DGR about "colonial veganism".md +/Users/sij/Nextcloud/notes/unsorted/Nov 22, 2022 at 11-51 AM— "Transcription Editing Instructions".md +/Users/sij/Nextcloud/notes/unsorted/Happy Mother’s Day, .md +/Users/sij/Nextcloud/notes/unsorted/May 19, 2023 at 7-05 PM— "The Best Text-to-Speech Tools".md +/Users/sij/Nextcloud/notes/unsorted/2023-05-24 — "Job Change Check-in with Sanjay".md +/Users/sij/Nextcloud/notes/unsorted/Sangye & Casetext | Zoom Meeting - [[2023-05-31-Wednesday]].md +/Users/sij/Nextcloud/notes/unsorted/2023-05-24 — "Bureau authorizes timber sales impacting owls".md +/Users/sij/Nextcloud/notes/unsorted/Jan 30, 2023 at 2-46 PM— "Transcribed Raw Voice Recording".md +/Users/sij/Nextcloud/notes/unsorted/What can be appealed?.md +/Users/sij/Nextcloud/notes/unsorted/I’ve discovered awe... but what was my name?.md +/Users/sij/Nextcloud/notes/unsorted/May 25, 2023 at 12-09— "Exciting Buyout News from Michigan".md +/Users/sij/Nextcloud/notes/unsorted/Nov 9, 2022 at 3-10 PM— Title suggestion- "North Project Threatens Spotted Owl".md +/Users/sij/Nextcloud/notes/unsorted/Call with .md +/Users/sij/Nextcloud/notes/unsorted/Nov 9, 2022 at 15-31— Title- "Habitat loss and endangered owls".md +/Users/sij/Nextcloud/notes/unsorted/“Hear Me" Trilogy.md +/Users/sij/Nextcloud/notes/unsorted/May 27, 2023 at 14-02— "Transcription Editing Tips".md +/Users/sij/Nextcloud/notes/unsorted/May 24, 2023 at 08-06— "Consider Avoiding Grocery Stores".md +/Users/sij/Nextcloud/notes/unsorted/Human Rights Watch | Defending Human Rights Worldwide.md +/Users/sij/Nextcloud/notes/unsorted/Sep 1, 2021 - Clinic Meeting #2.md +/Users/sij/Nextcloud/notes/unsorted/May 25, 2023 at 12-08— "Raw Voice Recording Transcript- Technical Issues".md +/Users/sij/Nextcloud/notes/unsorted/May 25, 2023 at 19-32— "Taystex Follow-Up on Co-Counsel Request".md +/Users/sij/Nextcloud/notes/unsorted/May 27, 2023 at 14-35— "Voice Recording Test with AI".md +/Users/sij/Nextcloud/notes/unsorted/May 27, 2023 at 15-11— "Transcript Editing Suggestions".md +/Users/sij/Nextcloud/notes/W\&W breakout.md +/Users/sij/Nextcloud/notes/obsidian/resources/awesome-selfhosted#note-taking--editors.webarchive diff --git a/ts-info b/ts-info new file mode 100755 index 0000000..7c7b942 --- /dev/null +++ b/ts-info @@ -0,0 +1,19 @@ +#!/bin/bash + +# Function to get exit node details +# get_exit_node_details() { +# echo $(/Applications/Tailscale.app/Contents/MacOS/Tailscale exit-node list | awk '/'"$1"'/ {print $4", "$3" ("$2")"}') +# } + +# Get the current exit node details and public IP +# CURRENT_NODE=$(get_exit_node_details 'selected') +# CURRENT_IP=$(curl -s ifconfig.me) +# DNS_SERVER=$(python3 ~/.dns-info.py) + +# echo "IP address: $CURRENT_IP" +# echo "DNS server: $DNS_SERVER" +# echo "Exit node: ${CURRENT_NODE:-None}" +# echo "" + +READOUT=$(python3 /Users/sij/Scripts/Raycast\ Scripts/vpn-dns-info.py) +echo "$READOUT" diff --git a/ts-new-node-minimalist b/ts-new-node-minimalist new file mode 100755 index 0000000..34f9caf --- /dev/null +++ b/ts-new-node-minimalist @@ -0,0 +1,24 @@ +#!/bin/bash + +# Define the path to your Tailscale binary +tailscale="/Applications/Tailscale.app/Contents/MacOS/Tailscale" + +# Check if Tailscale is running +if ! pgrep "Tailscale" > /dev/null; then + echo "Tailscale is not running. Starting Tailscale..." + open -a "/Applications/Tailscale.app" + # Wait for Tailscale to initialize + sleep 5 + $tailscale up +fi + +# Select a new exit node from the whitelist and set it +selected_exit_node=$($tailscale exit-node list | grep -f ~/.vpnwhitelist | awk '{print $2}' | shuf -n 1) +if [ -n "$selected_exit_node" ]; then + # Set the new exit node + $tailscale set --exit-node=$selected_exit_node +else + echo "No valid exit node found." + exit 1 +fi + diff --git a/tts copy b/tts copy new file mode 100755 index 0000000..4722b93 --- /dev/null +++ b/tts copy @@ -0,0 +1,85 @@ +#!/Users/sij/miniforge3/bin/python + +import sys +import os +import tempfile +from pathlib import Path +import uuid +import hashlib +from pydub import AudioSegment +import torch +from TTS.api import TTS # Adjust with actual import +from playsound import playsound + +from TTS.api import TTS + +device = torch.device('cpu') # keep trying 'mps' it will eventually be implemented +model_name = "tts_models/multilingual/multi-dataset/xtts_v2" +tts = TTS(model_name=model_name).to(device) +DEFAULT_VOICE = "kiel" + +def select_voice(voice_name: str) -> str: + voice_dir = Path('/Users/sij/AI/banana-phone/voices') + voice_file = voice_dir / f"{voice_name}.wav" + if voice_file.is_file(): + return str(voice_file) + else: + print(f"Voice file not found for {voice_name}, using default") + return str(voice_dir / f"{DEFAULT_VOICE}.wav") + +def generate_speech(text, speed, voice_file): + output_dir = Path(tempfile.gettempdir()) + output_dir.mkdir(exist_ok=True) + + short_uuid = str(uuid.uuid4())[:8] + output_file_name = f"{Path(voice_file).stem}-{short_uuid}.wav" + output_file = output_dir / output_file_name + + tts.tts_to_file( + text=text, + speed=speed, + file_path=output_file, + speaker_wav=[voice_file], + language="en" + ) + + return output_file + +def main(): + if len(sys.argv) < 2: + print("Usage: python script.py [voice] [speed]") + sys.exit(1) + + text_input = sys.argv[1] + if len(text_input) < 255 and os.path.isfile(text_input): + with open(text_input, 'r') as file: + text = file.read() + else: + text = text_input + + voice = sys.argv[2] if len(sys.argv) > 2 else DEFAULT_VOICE + speed = float(sys.argv[3]) if len(sys.argv) > 3 else 1.1 + + voice_file_path = select_voice(voice) + + print(f"Using voice file at {voice_file_path}") + + combined_audio = AudioSegment.silent(duration=0) + output_file = generate_speech(text, speed, voice_file_path) + combined_audio += AudioSegment.from_wav(str(output_file)) + + # Exporting combined audio + final_output_path = Path(tempfile.gettempdir()) / "output.wav" + combined_audio.export(str(final_output_path), format="wav") + + # Now playing the generated speech file + print(f"Playing generated speech from {final_output_path}") + playsound(str(final_output_path)) + + # Cleanup + os.remove(output_file) + os.remove(final_output_path) + +if __name__ == "__main__": + main() + diff --git a/txtsort b/txtsort new file mode 100755 index 0000000..a2235aa --- /dev/null +++ b/txtsort @@ -0,0 +1,16 @@ +#!/bin/bash + +# Checking if the user provided a file name +if [ $# -ne 1 ]; then + echo "Usage: $0 filename" + exit 1 +fi + +# Checking if the given file is readable +if ! [ -r "$1" ]; then + echo "The file '$1' is not readable or does not exist." + exit 1 +fi + +sort $1 + diff --git a/update_calendar b/update_calendar new file mode 100755 index 0000000..e517f85 --- /dev/null +++ b/update_calendar @@ -0,0 +1,86 @@ +#!/bin/bash + +# Check if a date parameter is passed +if [ -z "$1" ]; then + echo "Usage: $0 " + exit 1 +fi + +DATE=$1 + +# Convert the date to a format that AppleScript expects (MM/DD/YYYY) +formatted_date=$(date -j -f "%Y-%m-%d" "$DATE" +"%A, %B %e, %Y at 00:00:00") + +osascript < 3 and parts[2] in PRIVACY_FRIENDLY_COUNTRIES: + exit_nodes.append(parts[1]) + + if not exit_nodes: + raise Exception("No privacy-friendly exit nodes available") + + return random.choice(exit_nodes) + +def set_random_privacy_friendly_exit_node(): + exit_node = get_random_privacy_friendly_exit_node() + print(f"Selected random privacy-friendly exit node: {exit_node}") + + # Set the exit node + subprocess.run(['tailscale', 'set', f'--exit-node={exit_node}'], check=True) + + # Verify the exit node + response = requests.get('https://am.i.mullvad.net/json') + exit_node_info = response.json() + exit_node_hostname = exit_node_info.get('mullvad_exit_ip_hostname') + + print(f"Current exit node hostname: {exit_node_hostname}") + + # Get the part before the first '.' in the exit_node + exit_node_short = exit_node.split('.')[0] + + # Verify that the exit_node_short and exit_node_hostname are equal + if exit_node_short == exit_node_hostname: + print("Exit node set successfully!") + else: + print("Failed to set exit node!") + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description='Manage VPN exit nodes.') + parser.add_argument('action', choices=['start', 'stop', 'new', 'shh'], help='Action to perform: start, stop, new, or shh') + + args = parser.parse_args() + + if args.action == 'start': + start_exit_node() + elif args.action == 'stop': + unset_exit_node() + elif args.action == 'new': + set_exit_node() + elif args.action == 'shh': + set_random_privacy_friendly_exit_node() diff --git a/xtts b/xtts new file mode 100755 index 0000000..a8d7fbf --- /dev/null +++ b/xtts @@ -0,0 +1,78 @@ +#!/bin/bash + +# Default voice +VOICE="m_50_news" + +SERVER="https://api.sij.ai" + +# Initialize ARGUMENT as an empty string +ARGUMENT="" + +# Process arguments +while [[ $# -gt 0 ]]; do + key="$1" + case $key in + --voice) + VOICE="$2" + shift # past argument + shift # past value + ;; + --voice=*) + VOICE="${key#*=}" # Extracting value after '=' + shift # past argument + ;; + *) + if [ -z "$ARGUMENT" ]; then + ARGUMENT="$1" + else + ARGUMENT="$ARGUMENT $1" + fi + shift # past argument + ;; + esac +done + +# Check if text or file argument is provided +if [ -z "$ARGUMENT" ]; then + echo "Usage: $0 [--voice='voice_name']" + exit 1 +fi + +TIMESTAMP=$(date +"%Y%m%d%H%M%S") +OUTPUT_FILE="/Users/sij/AI/TTS/${TIMESTAMP}_output.wav" + +# Determine if the argument is a file or a string +if [[ "$ARGUMENT" == *".txt" ]]; then + # It's a file, use the text_file parameter + curl -s -X 'POST' \ + "$SERVER/tts/speak" \ + -H 'Authorization: Bearer sk-NhrtQwCHNdK5sRZC' \ + -H 'accept: application/json' \ + -H 'Content-Type: multipart/form-data' \ + -F "file=@$ARGUMENT" \ + -F "voice=$VOICE" \ + -F 'speed=0.9' > "$OUTPUT_FILE" +else + # It's a string, process and use the text parameter + SIMPLE_TEXT=$(echo "$ARGUMENT" | tr -d '\n' | tr -d '\r' | sed 's/[^a-zA-Z0-9 .,?!-]//g' | sed 's/ */ /g') + + curl -s -X 'POST' \ + "$SERVER/tts/speak" \ + -H 'Authorization: Bearer sk-NhrtQwCHNdK5sRZC' \ + -H 'accept: application/json' \ + -H 'Content-Type: multipart/form-data' \ + -F "text=$SIMPLE_TEXT" \ + -F "voice=$VOICE" \ + -F 'speed=0.9' > "$OUTPUT_FILE" +fi + +# Check if the output file was created +if [ ! -f "$OUTPUT_FILE" ]; then + echo "Failed to create audio file." + exit 1 +fi + +# Output the path and play the file +echo "Audio file saved: $OUTPUT_FILE" +afplay "$OUTPUT_FILE" + diff --git a/z b/z new file mode 100755 index 0000000..83030b7 --- /dev/null +++ b/z @@ -0,0 +1,3 @@ +source ~/.zprofile +source ~/.zshrc +source ~/.zshenv