Skip to content

Instantly share code, notes, and snippets.

View don1138's full-sized avatar
🐝

Don Schnitzius don1138

🐝
View GitHub Profile
@don1138
don1138 / font-stacks.css
Last active April 25, 2024 15:41
CSS Modern Font Stacks
/* Modern Font Stacks */
/* System */
font-family: system, -apple-system, ".SFNSText-Regular", "San Francisco", "Roboto", "Segoe UI", "Helvetica Neue", "Lucida Grande", sans-serif;
/* System (Bootstrap 5.2.0) */
font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
/* Times New Roman-based serif */
font-family: Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif;
@don1138
don1138 / phi_cascade.py
Last active November 7, 2023 01:46
Phi, Ascending, Descending, and Exponent; and the Chessboard Rice values
import bpy
from math import sqrt
phi = (1 + sqrt(5)) / 2
# phi = 5 ** .5 * .5 + .5
# ASCENDING
e1 = [round((x * phi),3) for x in range(1,17)]
print(f"\nAscending = {e1}")
@don1138
don1138 / rename_files.py
Last active November 7, 2023 01:40
Rename files in a directory based on a mappings file
# Rename Files v1.1.0
# Imports a mappings file in this format:
# current_name1,new_name1
# current_name2,new_name2
# ...
# and renames files in a MacOS directory.
import os
import shlex
# Ask for directory path and use shlex to sanitize the path
@don1138
don1138 / extract_metadata.py
Last active November 7, 2023 01:40
Extract metadata from image files
# Extract Metadata v1.3.0
# This script reads the images in a directory and all subdirectories, copies the EXIF metadata, and saves it to a text file with the same name as the source image.
import os
import shlex
from PIL import Image, ExifTags
# Ask the user for the parent directory path and strip trailing whitespace
PARENT_DIRECTORY_input = input("Enter the parent directory path: ").strip()
# Use shlex to sanitize the path
@don1138
don1138 / zip_file.py
Last active November 7, 2023 01:36
Compress file or folders using Python's zipfile
# Zip File v1.2.0
# Usage: python zip_file.py
import os
import shlex
import zipfile
# Ask the user for the file or directory path to compress
source_path_input = input("Enter the file or directory path to compress: ").strip()
# Use shlex to sanitize the path
@don1138
don1138 / phi.py
Created November 7, 2023 01:21
Print Phi (Φ) to 50 places
phi = 5**0.5*0.5+0.5
formatted_phi = f"{phi:.50f}"
print(formatted_phi)
# 1.61803398874989490252573887119069695472717285156250
@don1138
don1138 / read_file_path.py
Created November 7, 2023 01:02
Make Drag-and-Drop file paths readable by Python
# Read File Path v1.0
# Dreg-and-Dropping into terminal a file with spaces in its name (User/Folder/File\ Name.txt) can cause errors.
# This script makes sure file paths are readable by Python
import shlex
# Ask the user for a file path
file_path_input = input("Enter the path to the target file: ").strip()
file_path_components = shlex.split(file_path_input)
# Reconstruct the file path by joining the components
@don1138
don1138 / displaysizes.txt
Last active November 7, 2023 00:59 — forked from marcedwards/displaysizes.txt
iPhone, iPad, and Apple Watch display sizes
### Points and display type
PPI is points per inch below, not pixels per inch. Not all models are listed, just the first model with a new display size. Diamond, RGB Stripe and Pentile RGB refer to the subpixel patterns.
iPhone 1 = 320 × 480 @ 163PPI sRGB IPS LCD RGB Stripe
iPhone 4 = 320 × 480 @ 163PPI sRGB IPS LCD RGB Stripe
iPhone 5 = 320 × 568 @ 163PPI sRGB IPS LCD RGB Stripe
iPhone 6 = 375 × 667 @ 163PPI sRGB IPS LCD RGB Stripe
iPhone 6 Plus = 414 × 736 @ 153.5PPI sRGB IPS LCD RGB Stripe
iPhone 7 = 375 × 667 @ 163PPI P3 IPS LCD RGB Stripe
@don1138
don1138 / better-helvetica.css
Created June 11, 2013 21:59
CSS Better Helvetica Font Stack
body {
font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
font-weight: 300;
}
@don1138
don1138 / set-percentage-width.swift
Last active May 20, 2023 15:08
Use percentage widths on SwiftUI layout objects
// Get screen width and subtract Safe Area margins
var containerWidth:CGFloat = UIScreen.main.bounds.width - 32.0
// Set frame width of each column using (containerWidth * percentage)
HStack (spacing:0) {
HStack {
Text("Column 25% Width")
}
.frame(width: containerWidth * 0.25)
HStack {