Skip to content

Instantly share code, notes, and snippets.

View StewartLynch's full-sized avatar

Stewart Lynch StewartLynch

View GitHub Profile
@StewartLynch
StewartLynch / loadStatus.txt
Created March 18, 2026 18:35
TUIKit Load Status Function
func loadStatus() {
projectName = shell("basename \"\(launchDir)\"")
branch = shell("git -C \"\(launchDir)\" rev-parse --abbrev-ref HEAD 2>/dev/null || echo '(not a git repo)'")
lastCommit = shell("git -C \"\(launchDir)\" log -1 --pretty=format:'%h %s' 2>/dev/null")
let raw = shell("git -C \"\(launchDir)\" status --porcelain 2>/dev/null | wc -l | tr -d ' '")
changedFiles = raw.isEmpty ? "–" : raw
}
@StewartLynch
StewartLynch / tuiKitShell.text
Last active March 18, 2026 18:31
TUIKit Shell Function
func shell(_ command: String) -> String {
let task = Process()
let pipe = Pipe()
task.standardOutput = pipe
task.standardError = Pipe()
task.launchPath = "/bin/bash"
task.arguments = ["-c", command]
task.environment = ProcessInfo.processInfo.environment
try? task.run()
task.waitUntilExit()
@StewartLynch
StewartLynch / AppSceneDelegate.txt
Created February 27, 2026 23:20
AppDelegate and SceneDelegate for SQLiteData Record Sharing - Gift Register app.
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_ application: UIApplication,
configurationForConnecting connectingSceneSession: UISceneSession,
options: UIScene.ConnectionOptions
) -> UISceneConfiguration {
let configuration = UISceneConfiguration(
name: "Default Configuration",
sessionRole: connectingSceneSession.role
)
@StewartLynch
StewartLynch / OccasionsList.swift
Last active February 23, 2026 21:22
OccasionsList view for Gift Registry app
//
//----------------------------------------------
// Original project: GiftRegistry
//
// Follow me on Mastodon: https://iosdev.space/@StewartLynch
// Follow me on Threads: https://www.threads.net/@stewartlynch
// Follow me on Bluesky: https://bsky.app/profile/stewartlynch.bsky.social
// Follow me on X: https://x.com/StewartLynch
// Follow me on LinkedIn: https://linkedin.com/in/StewartLynch
// Email: slynch@createchsol.com
@StewartLynch
StewartLynch / Occasion_OccasionGift.txt
Last active February 21, 2026 05:15
Seed data for Occasions and Join Table for Gift Registry App
// Occasions
Occasion(id: UUID(0), name: "Christmas", hexColor: "C0392B")
Occasion(id: UUID(1), name: "Birthday", hexColor: "8E44AD")
Occasion(id: UUID(2), name: "Valentines Day", hexColor: "E91E8C")
Occasion(id: UUID(3), name: "Wedding", hexColor: "D4AF37")
// OccasionGifts (Many-to-Many join records)
OccasionGift(id: UUID(0), occasionID: UUID(0), giftID: UUID(0))
OccasionGift(id: UUID(1), occasionID: UUID(0), giftID: UUID(1))
OccasionGift(id: UUID(2), occasionID: UUID(1), giftID: UUID(1))
@StewartLynch
StewartLynch / UIColor+Extension.swift
Created February 21, 2026 05:11
UIColor Extension for GiftRegistry App.
//
//----------------------------------------------
// Original project: GiftRegistry
//
// Follow me on Mastodon: https://iosdev.space/@StewartLynch
// Follow me on Threads: https://www.threads.net/@stewartlynch
// Follow me on Bluesky: https://bsky.app/profile/stewartlynch.bsky.social
// Follow me on X: https://x.com/StewartLynch
// Follow me on LinkedIn: https://linkedin.com/in/StewartLynch
// Email: slynch@createchsol.com
@StewartLynch
StewartLynch / Color+Extension.swift
Created February 21, 2026 05:09
Color Extension for GiftRegistry App
//
//----------------------------------------------
// Original project: GiftRegistry
//
// Follow me on Mastodon: https://iosdev.space/@StewartLynch
// Follow me on Threads: https://www.threads.net/@stewartlynch
// Follow me on Bluesky: https://bsky.app/profile/stewartlynch.bsky.social
// Follow me on X: https://x.com/StewartLynch
// Follow me on LinkedIn: https://linkedin.com/in/StewartLynch
// Email: slynch@createchsol.com
@StewartLynch
StewartLynch / resizeOptimize.swift
Created February 16, 2026 20:05
Resize and Optimize Image
func resizedAndOptimizedImageData(from data: Data, maxWidth: CGFloat = 1000) -> Data? {
guard let image = UIImage(data: data) else { return nil }
let originalSize = image.size
let scaleFactor = min(1, maxWidth / originalSize.width)
let newSize = CGSize(
width: originalSize.width * scaleFactor,
height: originalSize.height * scaleFactor
)
@StewartLynch
StewartLynch / GiftForm.swift
Last active February 14, 2026 20:08
Gift Form View for Gift Registry SQLiteData series
import SwiftUI
struct GiftForm: View {
@State private var name = ""
@State private var price: Double?
@State private var isPurchased = false
@Environment(\.dismiss) var dismiss
var body: some View {
NavigationStack {
@StewartLynch
StewartLynch / GiftListSection.txt
Created February 12, 2026 22:19
Gift List Section for Gift Registry
Section {
List {
ForEach(model.gifts) { gift in
HStack {
Button {
// purchaseButtonTapped
} label: {
Image(systemName: gift.isPurchased ? "checkmark.circle.fill" : "circle")
.foregroundStyle(gift.isPurchased ? .green : .secondary)