Skip to content

Instantly share code, notes, and snippets.

View glenn-jocher's full-sized avatar
😃
You Only Live Once

Glenn Jocher glenn-jocher

😃
You Only Live Once
View GitHub Profile
@glenn-jocher
glenn-jocher / find_broken_links.py
Last active March 27, 2023 01:11
Find Broken Links in Repo Issues/PRs
@glenn-jocher
glenn-jocher / analyze_python_files.py
Last active October 8, 2023 13:14
Analyze Python Files
"""
Python Files Analyzer
This script analyzes Python files in a given GitHub repo, excluding specified sub-directories.
It counts and reports the following for each file:
- Total number of characters
- Total number of words
- Total number of lines
- Total number of functions (based on the 'def' keyword)
- Total number of classes (based on the 'class' keyword)
"""
This script recursively scans Python files within a specified directory to identify functions and classes
that lack docstrings.
Features:
- Can navigate deeply nested directory structures to analyze all `.py` files.
- Allows for specific directories (like `venv` or `runs`) to be excluded from the scan.
- For each missing docstring, the script outputs the file path and the specific function or class declaration.
- Provides a summary count of total functions/classes analyzed, how many have docstrings, and how many are missing them.
- Offers an overview of the number of missing docstrings categorized by the top-level directory.
@glenn-jocher
glenn-jocher / ios_app_store_preview_image_resizer.py
Last active February 11, 2024 19:15
iOS App Store Preview Image Resizer
"""
iOS App Store Preview Image Resizer
This script provides functionality to resize images for iOS app store previews. It offers two modes for resizing:
- "pad": This mode will pad the image with white space to fit the target dimensions without cropping.
- "crop": This mode will crop the image to match the target aspect ratio, then resize it to the exact target dimensions.
Usage:
- Modify the `input_dir` variable to point to the directory containing the images you want to resize.
- The script will create output directories named with the target dimensions and the device name.
@glenn-jocher
glenn-jocher / thread_vs_process_benchmarks.py
Last active September 23, 2024 04:12
Threading vs Multiprocessing benchmarks for YOLOv8
# M3 Macbook Air results:
# Average Threading Time: 0.38 seconds
# Average Multiprocessing Time: 2.39 seconds
# Average Concurrent Futures (ThreadPool) Time: 0.34 seconds
# Average Concurrent Futures (ProcessPool) Time: 2.39 seconds
import time
import torch
from concurrent.futures import ThreadPoolExecutor, ProcessPoolExecutor