Skip to content

Instantly share code, notes, and snippets.

View brennanMKE's full-sized avatar

Brennan Stehling brennanMKE

View GitHub Profile
@brennanMKE
brennanMKE / SwiftConcurrency.md
Last active July 28, 2025 21:19
Swift Exercises

Swift Concurrency Exercises

🟢 Beginner (1–5): Core Concepts & Basics

  1. Awaiting Simple Async Function

    • Write an async function that returns a greeting string.
    • Test that it returns the expected value using #expect.
  2. Async Throwing Function

@brennanMKE
brennanMKE / README.md
Last active July 28, 2025 20:15
Using @isolated(any) with non-async functions and closures

Any Isolation with Non-async Blocks of Code

This sample shows one use of using @isolated(any) with non-async functions and closures.

Validation

struct ValidationHelper {
    // Non-async function that preserves caller's isolation
    static func validateAndUpdate<T>(
@brennanMKE
brennanMKE / README.md
Created July 26, 2025 02:48
Server-Driven UI with SwiftUI

Server-Driven UI with SwiftUI

Yes, this is absolutely possible and is a pattern called Server-Driven UI (SDUI). It's becoming increasingly popular for mobile apps that need dynamic layouts, A/B testing, or frequent UI changes without app store updates.

Core Concept

The idea is to have your backend return JSON that describes the UI structure, components, and their properties, which your SwiftUI app then interprets and renders dynamically.

graph LR
@brennanMKE
brennanMKE / README.MD
Last active July 14, 2025 19:37
Proposal: Enhancing Social Media Interactions with Content Creators Through Contextual Linking and Open APIs

Proposal: Enhancing Social Media Interactions with Content Creators Through Contextual Linking and Open APIs

User Story Jane is scrolling through her favorite social media app when she sees a post from a trusted journalist discussing a breaking news story. Intrigued, she taps the link and lands on the journalist’s blog. At the bottom of the article, she notices a dynamic summary showing the volume and nature of the ongoing discussion across social media, with her platform—Bluesky—automatically highlighted. She's able to return to the original thread seamlessly, where she contributes to the discussion better informed than before. This flow not only enriches Jane’s understanding but also drives authentic engagement with both the article and the online community.

Overview This proposal outlines a standardized framework to improve the interactions between social media platforms and content creators, including news organizations and independent bloggers. By appending contextual metadata to shared lin

@brennanMKE
brennanMKE / README.md
Created June 11, 2025 04:49
Using UIWindowScene and UIWindow with SwiftUI to Create a Debugging Window

Using UIWindowScene and UIWindow with SwiftUI to Create a Debugging Window

This tutorial explains the relationship between UIWindowScene, UIWindow, and UIScene, and shows how to create a secondary debug window using SwiftUI inside a UIKit-hosted UIWindow. This is especially useful for developers working on internal tools or debugging overlays for iOS, iPadOS, or visionOS apps.


Overview

Apple's scene-based lifecycle (introduced in iOS 13) allows multiple UI scenes per app. Each scene is an instance of UIScene, and for UIKit-based apps, it takes the form of a UIWindowScene. Each UIWindowScene can own multiple UIWindow instances.

@brennanMKE
brennanMKE / README.md
Created May 30, 2025 21:44
Swift Errors vs Exceptions

🧠 Distinction: Thrown Errors (Swift) vs Exceptions (Other Languages)

✅ Swift: Thrown Errors

  • Swift’s throw/try/catch is designed for predictable, recoverable errors.

  • Swift requires explicit syntax:

    • func foo() throws
    • try foo()
  • do { try foo() } catch { ... }

@brennanMKE
brennanMKE / DebuggingLeaksWithLLDB.md
Last active May 27, 2025 18:25
Debugging with LLDB

✅ Debugging Memory Leaks with LLDB

🔍 1. Inspect What Is at a Given Memory Address

Yes — if you have a memory address from a leak report, LLDB can tell you what object it points to:

memory read --format x --size 8 --count 1 0xADDRESS
@brennanMKE
brennanMKE / AccessModel.md
Last active May 9, 2025 19:18
Sponsor Access Standard

🔧 Sponsor Access Protocol – Revised Access Model

✅ Overview

Each sponsor token grants access rights based on a defined access type, including:

Access Type Description
timed Fixed expiration (e.g., 7 days from claim)
day_pass Each use activates 24-hour access; multiple passes can be held
@brennanMKE
brennanMKE / README.md
Created April 5, 2025 08:13
Swift Study Notes

✅ Swift 6 Study Notes — any, some, Existentials, Boxing, Dispatch

(via ChatGPT)

🧱 any vs some — Existential vs Opaque Types

any Protocol

  • Existential type: Can hold a value of any type that conforms to the protocol.
  • Requires heap allocation (boxing).
  • Uses dynamic dispatch via a witness table.
@brennanMKE
brennanMKE / README.md
Created April 4, 2025 20:26
Tailscale and WireGuard

Tailscale and WireGuard

(via ChatGPT)

🔧 Overview: Platform Features Supporting WireGuard & Tailscale

Modern OSes like macOS, Linux, Windows, and iOS have built-in support for networking features that make tools like WireGuard and Tailscale work smoothly:

💡 Core Platform Features Used

| Feature | Description | Used By |