Skip to content

Instantly share code, notes, and snippets.

View tkersey's full-sized avatar
:octocat:

Tim Kersey tkersey

:octocat:
View GitHub Profile
@steipete
steipete / swift-testing-playbook.md
Last active June 9, 2025 14:20
The Ultimate Swift Testing Playbook (feed it your agents for better tests!)

The Ultimate Swift Testing Playbook (2024 WWDC Edition, expanded with Apple docs from June 2025)

Updated with info from https://developer.apple.com/documentation/testing fetched via Firecrawl on June 7, 2025.

See also my blog: See also my blog post: https://steipete.me/posts/2025/migrating-700-tests-to-swift-testing

A hands-on, comprehensive guide for migrating from XCTest to Swift Testing and mastering the new framework. This playbook integrates the latest patterns and best practices from WWDC 2024 and official Apple documentation to make your tests more powerful, expressive, and maintainable.


1. Migration & Tooling Baseline

@tkersey
tkersey / cron-agent-effection.ts
Last active May 31, 2025 22:59
Agents with Algebraic Effects
import {
Operation,
Resource,
Context,
action,
resource,
spawn,
sleep,
main,
suspend as effectionSuspend,

MCP's client-server architecture: Technical design for AI integration

The Model Context Protocol (MCP) represents a fundamental shift in how AI applications connect to external systems. Introduced by Anthropic in November 2024, MCP chose a client-server architecture over alternatives like peer-to-peer or monolithic designs to solve the "M×N problem" - where M AI applications need to integrate with N data sources, traditionally requiring M×N custom integrations. The client-server model transforms this into an M+N solution through standardized, secure, and scalable connections.

This architectural decision reflects deep technical considerations: security isolation between components, modular extensibility for diverse integrations, and protocol standardization that enables any MCP client to work with any MCP server regardless of implementation language or platform. The design philosophy prioritizes developer simplicity while maintaining enterprise-grade security boundaries - what Anthropic calls "

// Deep Dive: Prompts as Delimited Continuations in TypeScript
// =============================================================================
// 1. PROMPTS AS INITIAL CONTINUATIONS
// =============================================================================
/**
* Prompts as Initial Continuations treats the prompt itself as the starting
* continuation that establishes the computational context. The prompt becomes
* a first-class continuation that can be captured, modified, and resumed.
@harlanhaskins
harlanhaskins / View+ParentViewController.swift
Last active March 26, 2025 12:01
A SwiftUI modifier for inserting the parent UIViewController in the environment
import Foundation
import SwiftUI
extension View {
/// Adds introspection to find the parent view controller in the view hierarchy and
/// makes that view controller available to downstream views in the view hierarchy.
public func addParentViewControllerIntrospection() -> some View {
modifier(ParentViewControllerEnvironmentModifier())
}
}
@tkersey
tkersey / FAQ.md
Created January 28, 2025 14:06 — forked from ngxson/FAQ.md
convert ARM NEON to WASM SIMD prompt

What is your setup?

Just chat.deepseek.com with prompts adapted from this gist.

Does it work in one-shot or I have to prompt it multiple times?

  • For the qX_0 variants, they are actually quite straight-forward so deepseek can come up with a correct result in 1 shot.
  • For the qX_K it's more complicated, I would say most of the time I need to re-prompt it 4 to 8 more times.
  • The most difficult was q6_K, the code never works until I ask it to only optimize one specific part, while leaving the rest intact (so it does not mess up everything)
@ngxson
ngxson / FAQ.md
Last active May 25, 2025 16:02
convert ARM NEON to WASM SIMD prompt

Why did you do this?

Relax, I only have one Sunday to work on idea, literally my weekend project. So I tried Deepseek to see if it can help. Surprisingly, it works and it saves me another weekend...

What is your setup?

Just chat.deepseek.com (cost = free) with prompts adapted from this gist.

Does it work in one-shot or I have to prompt it multiple times?

@rnapier
rnapier / AsyncFutureTests.swift
Last active January 11, 2025 19:54
AsyncFuture
import Testing
import Combine
// From https://stackoverflow.com/questions/78892734/getting-task-isolated-value-of-type-async-passed-as-a-strongly-trans/78899940#78899940
public final class AsyncFuture<Output, Failure: Error>: Publisher, Sendable {
public typealias Promise = @Sendable (Result<Output, Failure>) -> Void
private let work: @Sendable (@escaping Promise) async -> Void
public init(_ work: @Sendable @escaping (@escaping Promise) async -> Void) {
@IanKeen
IanKeen / ObservableAppStorage.swift
Created October 10, 2024 17:06
PropertyWrapper: ObservableAppStorage - Make UserDefaults work with @observable models (without all the boilerplate)
import Observation
public protocol _Observable: Observable {
nonisolated
func _access<Member>(keyPath: KeyPath<Self, Member>)
nonisolated
func _withMutation<Member, MutationResult>(
keyPath: KeyPath<Self, Member>,
_ mutation: () throws -> MutationResult
@eskfung
eskfung / snacklog.md
Created September 24, 2024 19:11
In Support of the “Snacklog”

Recently we’ve noticed a number of our clients maintain a backlog of small tasks that are handled separately from their main backlog. These are tasks that should be finished at some point, but will rarely take priority over business-critical features and bugfixes. Often they are bite-sized pieces of work that can be finished in a couple of hours or less: addressing engineering chores, paying off tech debt, and addressing minor bugs. Internally, this separate backlog has earned a catchy name: the snacklog.

When is it appropriate to work on a snacklog task instead of something in the prioritized backlog? After all, developers should be working on things that move the business forward (obviously). Inevitably, though, natural lulls come up in the course of development:

  1. I’ve just finished a big pull request and have some time before my team finishes leaving feedback.
  2. I’m temporarily blocked by a design or product decision.
  3. It’s near the end of the day, and I’d rather work on something small than sta