ome stuff
Browse filesSigned-off-by: Balazs Horvath <acsipont@gmail.com>
- .zshrc +41 -1
- utils/extract_description_flickr.py +25 -0
- utils/remove_extra_file_extension_txt.py +17 -0
- utils/rename_description_file.py +17 -0
.zshrc
CHANGED
@@ -10,6 +10,35 @@ alias 🐺='GGML_CUDA_NO_PINNED=1 ollama serve & conda activate openwebui && ope
|
|
10 |
alias ngrok-webui='ngrok http --url=hedgehog-lasting-mutually.ngrok-free.app 6969'
|
11 |
alias gsa='git submodule add'
|
12 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
function _up() {
|
14 |
local base_dir="$HOME/datasets/_"
|
15 |
|
@@ -35,6 +64,9 @@ function _up() {
|
|
35 |
cd "$current_dir"
|
36 |
}
|
37 |
|
|
|
|
|
|
|
38 |
deleteorphantags() {
|
39 |
# Loop through all .tags files
|
40 |
for tag_file in **/*.tags; do
|
@@ -47,6 +79,9 @@ deleteorphantags() {
|
|
47 |
done
|
48 |
}
|
49 |
|
|
|
|
|
|
|
50 |
deleteorphantxt() {
|
51 |
# Loop through all .txt files
|
52 |
for txt_file in **/*.txt; do
|
@@ -59,6 +94,9 @@ deleteorphantxt() {
|
|
59 |
done
|
60 |
}
|
61 |
|
|
|
|
|
|
|
62 |
look4orphantags() {
|
63 |
# Loop through all .tags files
|
64 |
for tag_file in **/*.tags; do
|
@@ -71,6 +109,9 @@ look4orphantags() {
|
|
71 |
done
|
72 |
}
|
73 |
|
|
|
|
|
|
|
74 |
look4orphantxt() {
|
75 |
# Loop through all .txt files
|
76 |
for txt_file in **/*.txt; do
|
@@ -709,7 +750,6 @@ replace_text_in_files() {
|
|
709 |
# The script checks if the specified directory exists and iterates over each text file in the directory.
|
710 |
# For each text file, it creates a temporary file with the modified content and then replaces the original file with the temporary file.
|
711 |
# If the directory does not exist, it prints an error message.
|
712 |
-
|
713 |
inject_to_txt() {
|
714 |
local dir="$1"
|
715 |
local prefix="$2"
|
|
|
10 |
alias ngrok-webui='ngrok http --url=hedgehog-lasting-mutually.ngrok-free.app 6969'
|
11 |
alias gsa='git submodule add'
|
12 |
|
13 |
+
# The cweb function compresses all .css, .html, .js, and .json files in the ./web directory
|
14 |
+
# using gzip and brotli.
|
15 |
+
#
|
16 |
+
# Then, it finds all matching files and compresses them with brotli.
|
17 |
+
#
|
18 |
+
# The function prints out the name of each file being processed.
|
19 |
+
cweb() {
|
20 |
+
# First find and compress with gzip
|
21 |
+
find ./web -type f \( -name "*.css" -o -name "*.html" -o -name "*.js" -o -name "*.json" \) \
|
22 |
+
! -name "*.gz" ! -name "*.br" ! -name "*.zst" \
|
23 |
+
-print0 | xargs -0 -P $(nproc) -I {} bash -c '
|
24 |
+
echo "Processing (gzip): {}"
|
25 |
+
gzip -k "{}"
|
26 |
+
'
|
27 |
+
|
28 |
+
# Then find and compress with brotli
|
29 |
+
find ./web -type f \( -name "*.css" -o -name "*.html" -o -name "*.js" -o -name "*.json" \) \
|
30 |
+
! -name "*.gz" ! -name "*.br" ! -name "*.zst" \
|
31 |
+
-print0 | xargs -0 -P $(nproc) -I {} bash -c '
|
32 |
+
echo "Processing (brotli): {}"
|
33 |
+
brotli --best "{}"
|
34 |
+
'
|
35 |
+
}
|
36 |
+
|
37 |
+
# Automatically commits and pushes changes in all git repositories found in ~/datasets/_
|
38 |
+
# Checks each immediate subdirectory, and if it's a git repo with changes:
|
39 |
+
# - Adds all changes
|
40 |
+
# - Creates a signed commit
|
41 |
+
# - Pushes to remote
|
42 |
function _up() {
|
43 |
local base_dir="$HOME/datasets/_"
|
44 |
|
|
|
64 |
cd "$current_dir"
|
65 |
}
|
66 |
|
67 |
+
# Finds and deletes .tags files that don't have a corresponding image file
|
68 |
+
# Checks for matching .png, .jpg, .jpeg, .jxl, or .webp files
|
69 |
+
# If no matching image is found, the .tags file is deleted with verbose output
|
70 |
deleteorphantags() {
|
71 |
# Loop through all .tags files
|
72 |
for tag_file in **/*.tags; do
|
|
|
79 |
done
|
80 |
}
|
81 |
|
82 |
+
# Finds and deletes .txt files that don't have a corresponding image file
|
83 |
+
# Checks for matching .png, .jpg, .jpeg, .jxl, or .webp files
|
84 |
+
# If no matching image is found, the .txt file is deleted with verbose output
|
85 |
deleteorphantxt() {
|
86 |
# Loop through all .txt files
|
87 |
for txt_file in **/*.txt; do
|
|
|
94 |
done
|
95 |
}
|
96 |
|
97 |
+
# Lists all .tags files that don't have a corresponding image file
|
98 |
+
# Checks for matching .png, .jpg, .jpeg, .jxl, or .webp files
|
99 |
+
# Prints the paths of orphaned .tags files without deleting them
|
100 |
look4orphantags() {
|
101 |
# Loop through all .tags files
|
102 |
for tag_file in **/*.tags; do
|
|
|
109 |
done
|
110 |
}
|
111 |
|
112 |
+
# Lists all .txt files that don't have a corresponding image file
|
113 |
+
# Checks for matching .png, .jpg, .jpeg, .jxl, or .webp files
|
114 |
+
# Prints the paths of orphaned .txt files without deleting them
|
115 |
look4orphantxt() {
|
116 |
# Loop through all .txt files
|
117 |
for txt_file in **/*.txt; do
|
|
|
750 |
# The script checks if the specified directory exists and iterates over each text file in the directory.
|
751 |
# For each text file, it creates a temporary file with the modified content and then replaces the original file with the temporary file.
|
752 |
# If the directory does not exist, it prints an error message.
|
|
|
753 |
inject_to_txt() {
|
754 |
local dir="$1"
|
755 |
local prefix="$2"
|
utils/extract_description_flickr.py
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import json
|
3 |
+
|
4 |
+
def extract_description(json_path):
|
5 |
+
with open(json_path, 'r', encoding='utf-8') as file:
|
6 |
+
data = json.load(file)
|
7 |
+
if 'description' in data:
|
8 |
+
base_filename = os.path.splitext(json_path)[0]
|
9 |
+
description_filename = f"{base_filename}.description"
|
10 |
+
with open(description_filename, 'w', encoding='utf-8') as desc_file:
|
11 |
+
desc_file.write(data['description'])
|
12 |
+
print(f"Created: {description_filename}")
|
13 |
+
else:
|
14 |
+
print(f"No description key in: {json_path}")
|
15 |
+
|
16 |
+
def process_directory(directory):
|
17 |
+
for root, _, files in os.walk(directory):
|
18 |
+
for file in files:
|
19 |
+
if file.lower().endswith('.json'):
|
20 |
+
extract_description(os.path.join(root, file))
|
21 |
+
|
22 |
+
if __name__ == "__main__":
|
23 |
+
current_directory = os.getcwd()
|
24 |
+
process_directory(current_directory)
|
25 |
+
|
utils/remove_extra_file_extension_txt.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
def rename_description_files(directory):
|
4 |
+
for root, _, files in os.walk(directory):
|
5 |
+
for file in files:
|
6 |
+
if file.endswith('.description'):
|
7 |
+
base_name = file.rsplit('.', 2)[0] # Split twice to remove the extra extension
|
8 |
+
new_name = f"{base_name}.txt"
|
9 |
+
old_path = os.path.join(root, file)
|
10 |
+
new_path = os.path.join(root, new_name)
|
11 |
+
os.rename(old_path, new_path)
|
12 |
+
print(f"Renamed: {old_path} to {new_path}")
|
13 |
+
|
14 |
+
if __name__ == "__main__":
|
15 |
+
current_directory = os.getcwd()
|
16 |
+
rename_description_files(current_directory)
|
17 |
+
|
utils/rename_description_file.py
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
|
3 |
+
def rename_description_files(directory):
|
4 |
+
for root, _, files in os.walk(directory):
|
5 |
+
for file in files:
|
6 |
+
if file.endswith('.description'):
|
7 |
+
base_name = file.rsplit('.', 2)[0] # Split twice to remove the extra extension
|
8 |
+
new_name = f"{base_name}.description"
|
9 |
+
old_path = os.path.join(root, file)
|
10 |
+
new_path = os.path.join(root, new_name)
|
11 |
+
os.rename(old_path, new_path)
|
12 |
+
print(f"Renamed: {old_path} to {new_path}")
|
13 |
+
|
14 |
+
if __name__ == "__main__":
|
15 |
+
current_directory = os.getcwd()
|
16 |
+
rename_description_files(current_directory)
|
17 |
+
|