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 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)
}
@brennanMKE
brennanMKE / README.md
Created January 24, 2025 18:26
Open Source alternatives to Buffer

Open Source alternatives to Buffer

Open Source, self-hosted alternatives to Buffer that allow you to manage and schedule posts for multiple social media platforms. Here are some of the most popular options:


  • Description: An open-source social media management platform that supports scheduling, posting, and analytics for multiple social platforms.
  • Supported Platforms: Facebook, Twitter, LinkedIn, Instagram, and YouTube.
  • Features:
@brennanMKE
brennanMKE / README.md
Created January 23, 2025 00:16
Hosting a static website which is generated with Jekyll and managed with Netlify CMS

Step-by-Step Guide to Create a Jekyll Static Website with Self-Hosted Netlify CMS

1. Prerequisites

Ensure you have the following tools and accounts ready:

  • A GitHub account and a new repository created for your website.
  • Jekyll installed on your local machine.
  • Node.js and npm installed.
  • A server to host your static website and CMS (e.g., AWS, DigitalOcean, or another hosting provider).