Skip to content

Commit

Permalink
2025-02-25 17:15:58.274830 new snippets
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardocerqueira committed Feb 25, 2025
1 parent 76666fe commit 7bb1560
Show file tree
Hide file tree
Showing 14 changed files with 1,587 additions and 2 deletions.
28 changes: 28 additions & 0 deletions seeker/report.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,31 @@
--------------------------------------------------------------------------------
2025-02-25 17:15:58.274830
--------------------------------------------------------------------------------
On branch main
Your branch is up to date with 'origin/main'.

Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: snippet/kv_cache.py

Untracked files:
(use "git add <file>..." to include in what will be committed)
snippet/BusyboxDocker.sh
snippet/Dockerfile
snippet/FileTidy.py
snippet/automatic_theorem_proving_1.py
snippet/automatic_theorem_proving_test_abelian_group.py
snippet/estudiante.java
snippet/find_insert_page_breaks.py
snippet/gistfile1.txt
snippet/hopnet_dynamics.py
snippet/main.go
snippet/run_sim_py.bash
snippet/sql_and_code_interpreter.py

no changes added to commit (use "git add" and/or "git commit -a")

--------------------------------------------------------------------------------
2025-02-24 17:12:51.711805
--------------------------------------------------------------------------------
Expand Down
32 changes: 32 additions & 0 deletions seeker/snippet/BusyboxDocker.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#date: 2025-02-25T16:52:12Z
#url: https://api.github.com/gists/e4cf54c52f31af4171c479d6cad153df
#owner: https://api.github.com/users/yodamaster

#!/usr/bin/env sh

if [ -d rootfs ]
then
rm -rf rootfs/
fi

mkdir rootfs
mkdir rootfs/bin
mkdir rootfs/etc
mkdir rootfs/root

if [ ! -f busybox ]
then
wget https://busybox.net/downloads/binaries/1.35.0-x86_64-linux-musl/busybox
fi

chmod +x busybox

echo "root:x:0:0:root:/root:/bin/sh" > rootfs/etc/passwd
echo "root:x:0:" > rootfs/etc/group

docker build . -t simplebusybox

rm -rf rootfs/
rm busybox

docker run -it simplebusybox
9 changes: 9 additions & 0 deletions seeker/snippet/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#date: 2025-02-25T16:52:12Z
#url: https://api.github.com/gists/e4cf54c52f31af4171c479d6cad153df
#owner: https://api.github.com/users/yodamaster

FROM scratch
COPY rootfs/ /
COPY busybox /bin
RUN ["./bin/busybox", "--install", "-s", "/bin"]
CMD ["/bin/sh"]
92 changes: 92 additions & 0 deletions seeker/snippet/FileTidy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#date: 2025-02-25T16:48:28Z
#url: https://api.github.com/gists/d99c0d51a22a5ce40dfa4973a3046776
#owner: https://api.github.com/users/dduyg

import os
import shutil
import logging

# Define the file categories and their associated extensions
categories = {
'Images': ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.tiff'],
'Documents': ['.pdf', '.doc', '.docx', '.txt', '.ppt', '.pptx', '.xls', '.xlsx'],
'Audio': ['.mp3', '.wav', '.aac', '.flac'],
'Videos': ['.mp4', '.avi', '.mkv', '.mov', '.wmv'],
'Archives': ['.zip', '.tar', '.gz', '.rar'],
'Code': ['.py', '.html', '.css', '.js', '.java', '.cpp', '.php'],
'Others': []
}

# Set up logging configuration
logging.basicConfig(filename='file_organizer.log', level=logging.INFO,
format='%(asctime)s - %(levelname)s - %(message)s')

def organize_files(directory):
# Check if the provided directory exists
if not os.path.exists(directory):
logging.error(f"Error: The directory {directory} does not exist.")
print(f"Error: The directory {directory} does not exist.")
return

# Loop through the categories and create subfolders if they don't exist
for category in categories:
category_path = os.path.join(directory, category)
if not os.path.exists(category_path):
os.makedirs(category_path)
logging.info(f"Created folder: {category_path}")

# Walk through all files and subdirectories in the given directory
for root, dirs, files in os.walk(directory):
# Skip the base directory since it's already being handled
if root == directory:
continue

# Move files into the correct folders
for filename in files:
filepath = os.path.join(root, filename)

# Determine the file's extension
file_extension = os.path.splitext(filename)[1].lower()

# Find the corresponding category for the file
moved = False
for category, extensions in categories.items():
if file_extension in extensions:
category_path = os.path.join(directory, category)
shutil.move(filepath, os.path.join(category_path, filename))
logging.info(f"Moved {filename} from {root} to {category} folder.")
moved = True
break

# If no category matched, move it to 'Others'
if not moved:
others_path = os.path.join(directory, 'Others')
shutil.move(filepath, os.path.join(others_path, filename))
logging.info(f"Moved {filename} from {root} to Others folder.")

# Handle the base directory files as well
for filename in os.listdir(directory):
filepath = os.path.join(directory, filename)
if os.path.isfile(filepath):
file_extension = os.path.splitext(filename)[1].lower()
moved = False
for category, extensions in categories.items():
if file_extension in extensions:
category_path = os.path.join(directory, category)
shutil.move(filepath, os.path.join(category_path, filename))
logging.info(f"Moved {filename} from {directory} to {category} folder.")
moved = True
break

if not moved:
others_path = os.path.join(directory, 'Others')
shutil.move(filepath, os.path.join(others_path, filename))
logging.info(f"Moved {filename} from {directory} to Others folder.")

if __name__ == "__main__":
# Input directory to organize
directory = input("Enter the path of the directory you want to organize: ").strip()

organize_files(directory)
print("File organization complete!")
logging.info("File organization complete!")
Loading

0 comments on commit 7bb1560

Please sign in to comment.