Skip to content

Instantly share code, notes, and snippets.

View brennanMKE's full-sized avatar

Brennan Stehling brennanMKE

View GitHub Profile
@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 |

@brennanMKE
brennanMKE / README.md
Created March 28, 2025 22:47
Swift with sending parameter

What sending enforces

Using sending tells the compiler:

  • This value will be consumed by a concurrent context (e.g., a task).
  • It must not be accessed again from the current task.
  • If it is accessed again (e.g., reused or mutated), the compiler will raise an error.

In the code below, it enforces running the operation once. Using it in the 2nd Task causes a compiler error.

@brennanMKE
brennanMKE / README.md
Created March 26, 2025 16:51
Getting Started with Tailscale

🛠 Getting Started with Tailscale: A Practical Guide

(via ChatGPT)

✨ Overview

This guide will help you set up Tailscale to:

  • Connect multiple Macs at home
  • Remotely manage Raspberry Pis in other networks
@brennanMKE
brennanMKE / FizzBuzz.swift
Last active March 9, 2025 03:44
FizzBuzz with Swift
import Foundation
let fizzValue = "Fizz"
let buzzValue = "Buzz"
let fizzBuzzValue = "FizzBuzz"
let emptyValue = ""
enum FizzBuzz: String {
case fizz = "Fizz"
case buzz = "Buzz"
@brennanMKE
brennanMKE / README.md
Created March 8, 2025 06:53
Swift Arrays, Sequences, and Performance Optimizations

Swift Arrays, Sequences, and Performance Optimizations

(via ChatGPT)

Overview

Swift provides powerful collection types, with Array and Sequence being fundamental. This document explores their differences, best practices, and common pitfalls, including Copy-on-Write (CoW), stride, and Lazy Sequences.


Sequence vs. Collection vs. Array

@brennanMKE
brennanMKE / README.md
Last active March 16, 2025 03:23
Rotatary Encode KY-040 with ESP32-C3

Rotary Encoder KY-040 with ESP32-C3

(via ChatGPT)

Below is a step-by-step guide for wiring a KY-040 rotary encoder to an ESP32-C3-based board on a breadboard, along with a simple example sketch (Arduino-style) showing how to read both rotation and the built-in push button.


1. Rotary Encoder (KY-040) Overview

@brennanMKE
brennanMKE / README.md
Last active February 26, 2025 18:10
Essential Git Aliases

Essential Git Aliases

The following Git aliases are very helpful for my usual workflow.

[alias]
	cb = switch -c
	sw = switch
	wip = commit -m wip
	rr = pull --rebase origin
@brennanMKE
brennanMKE / QED.md
Created February 14, 2025 23:48
QED

The tradition of writing Q.E.D. ("quod erat demonstrandum") at the end of a mathematical proof is the culmination of a long intellectual lineage that began with Pythagoras, evolved through Plato, Aristotle, Euclid, and Archimedes, and ultimately shaped the foundations of logical demonstration in mathematics. Each thinker built upon the ideas of their predecessors, refining the principles of proof, logic, and rigor that remain central to mathematics today.

Pythagoras (c. 570–495 BCE) – Mathematics as Abstract Truth

Pythagoras and his followers were among the first to view mathematics as a philosophical pursuit, believing that numbers and geometric relationships governed the universe. They sought logical justification for mathematical truths, leading to the earliest systematic proofs in history. The Pythagorean Theorem exemplifies their approach, demonstrating how mathematical relationships could be established through reasoning rather than empirical observation. However

@brennanMKE
brennanMKE / README.md
Last active February 6, 2025 19:31
Actor isolation in unit tests

Actor isolation in unit tests

Automated tests with actors can result in using await across many lines which is a lot of lock/unlock cycles which can have some unwanted side effects. In the very least it can just make your unit tests run more slowly. I wanted to see how I could set up my tests to evaluation expectations within the isolated actor scope. I found I could use an isolated parameter with a block to do it. See the code snippet for the function below.

private func run(_ actorInstance: <#actor type#>,
                 block: @Sendable (isolated <#actor type#>) async -> Void) async {
    await block(actorInstance)
}