Skip to content

Instantly share code, notes, and snippets.

View Jon-dog's full-sized avatar

Jono Jon-dog

View GitHub Profile
@Jon-dog
Jon-dog / month_vs_year_calc.py
Created November 29, 2024 04:48
Annual vs monthly cost calculator
def calc_rate_offset(monthly_cost, annual_cost, tolerance=1e-8):
"""
Find the monthly interest rate needed to offset the cost difference
between monthly and annual plans.
"""
total_monthly = 12 * monthly_cost
diff = total_monthly - annual_cost # Extra cost to offset
# If there's no meaningful difference, no interest rate is needed
if diff <= 0:
@Jon-dog
Jon-dog / python.json
Created November 6, 2024 00:56
VS Code snippets for colour pickers in Python
// Just some quick snippets for creating colour pickers quickly, mainly for VS Code
// Put this in your python code snippet file, accessed through ctrl + shift + p > Snippets: Configure Snippets
// Creates a colour picker with the #000000 hex format
"Colour Picker": {
"prefix": "col",
"body": [
"\"#000000\""
],
"description": "color picker!"
},
@Jon-dog
Jon-dog / QuickPNGinfo.py
Created December 24, 2022 03:51
Reads Metadata from PNG files
import sys
import os
import exifread
from PyQt5 import QtWidgets, QtGui, QtCore
from PyQt5.QtWidgets import QMainWindow, QLabel, QFileDialog, QWidget, QTextEdit, QVBoxLayout, QScrollArea, QPushButton
from PIL.PngImagePlugin import PngImageFile
class MainWindow(QMainWindow):
def __init__(self):
super().__init__()
@Jon-dog
Jon-dog / IMGsort.py
Last active December 20, 2022 14:45
Sorts PNG and JPG files into two folders based on metadata tag info
import os
import exifread
import PIL.PngImagePlugin
def extract_metadata_from_png(png_file):
"""Extract metadata from a PNG file object"""
png = PIL.PngImagePlugin.PngImageFile(png_file)
return png.info
def has_prompt_in_metadata(metadata):