Skip to content

Instantly share code, notes, and snippets.

View DivineDominion's full-sized avatar

Christian Tietze DivineDominion

View GitHub Profile
@steipete
steipete / swift-testing-playbook.md
Last active July 27, 2025 19:31
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

@tonsky
tonsky / youtube.css
Last active April 10, 2025 14:22
Youtube Userstyle
:root {
--grey50: #A0A0A0;
--grey75: #C0C0C0;
--grey90: #E0E0E0;
--opacity: 1;
}
.ytp-gradient-bottom { display: none; }
.ytp-cairo-refresh-signature-moments .ytp-play-progress { background: #F00; }
.ytp-button[data-tooltip-target-id=ytp-autonav-toggle-button],
@martinhoeller
martinhoeller / NSColor+Values.swift
Last active April 29, 2025 16:51
NSColor Catalog Colors
import Cocoa
import Foundation
var colors: [NSColor] = [.labelColor, .secondaryLabelColor, .tertiaryLabelColor, .quaternaryLabelColor, .textColor, .placeholderTextColor, .selectedTextColor, .textBackgroundColor, .selectedTextBackgroundColor, .keyboardFocusIndicatorColor, .unemphasizedSelectedTextColor, .unemphasizedSelectedTextBackgroundColor, .linkColor, .separatorColor, .selectedContentBackgroundColor, .unemphasizedSelectedContentBackgroundColor, .selectedMenuItemTextColor, .gridColor, .headerTextColor, .controlAccentColor, .controlColor, .controlBackgroundColor, .controlTextColor, .disabledControlTextColor, .selectedControlColor, .selectedControlTextColor, .alternateSelectedControlTextColor, .windowBackgroundColor, .windowFrameTextColor, .underPageBackgroundColor, .findHighlightColor, .highlightColor, .shadowColor
]
for color in colors {
var red: CGFloat = 0
var green: CGFloat = 0
var blue: CGFloat = 0
@DivineDominion
DivineDominion / URL+resolvedAgainstBase.swift
Last active January 31, 2022 10:37
Given two file path URLs, determine the shortest relative path to get from one to the other, e.g. `../../folder/file.txt`
// Copyright © 2021 Christian Tietze. All rights reserved. Distributed under the MIT License.
import Foundation
extension URL {
/// Produces a relative path to get from `baseURL` to the receiver for use in e.g. labels.
///
/// When there's no common ancestor, e.g. `/tmp/` and `/var/`, then this returns an absolute path. The only exception to this rule is when `baseURL` itself is the root `/`, since tor that base _all_ paths are relative.
///
/// - Returns: Shortest relative path to get from `baseURL` to receiver, e.g. `"../../subdirectory/file.txt"`, and `"."` if both are identical. Absolute path (or absolute URL for non-`file://` URLs) if there's nothing in common.

How to install GNU Stow on Unraid

Unraid OS ≥6.11.0

  1. Install the User Scripts (Andrew Zawadzki) plugin from CA
  2. cat /etc/slackware-version and check which Slackware version the current Unraid OS is based on
    • 6.11.0 ⇒ Slackware 15
  3. Head to packages.slackware.com, filter Release to Slackware64 + that version, and search for the following packages:
    • gc
  • guile
@saf-dmitry
saf-dmitry / apa-reference.txt
Created December 9, 2020 15:43
APA-style reference template for BibDesk
<$publications>
<$pubType=article?>
<$authors.name.@componentsJoinedByCommaAndAnd/>. <$fields.Title.stringByConvertingHyphensToDashes/>. <$fields.Journal.stringByRemovingTeX/>, <$fields.Volume.stringByConvertingHyphensToDashes/><$fields.Number.stringByConvertingHyphensToDashes.parenthesizedStringIfNotEmpty/><$fields.Pages?><$fields.Volume?>:<?$fields.Volume?><$fields.Number?>:<?$fields.Number?>page </$fields.Number?></$fields.Volume?><$fields.Pages.stringByConvertingHyphensToDashes/>, <?$fields.Pages?><$fields.Volume?>, <?$fields.Volume?><$fields.Number?>, </$fields.Number?></$fields.Pages?><$fields.Month.stringByConvertingHyphensToDashes.stringByAppendingSpaceIfNotEmpty/><$fields.Year/><$fields.Note.stringByPrependingFullStopAndSpace/>.
<?$pubType=book?>
<$authors?><$authors.name.@componentsJoinedByCommaAndAnd/><?$authors?><$editors.name.@componentsJoinedByCommaAndAnd/>, <$editors.@count=0?><?$editors.@count=1?>editor<?$editors.@count?>editors</$editors.@count?></$authors?>. <$fields.Title.stringByConvertin
@pilky
pilky / SourceListTableCellView.swift
Created July 6, 2020 19:06
A source list cell that correct colours the label text of a drag image when selected
class SourceListTableCellView: NSTableCellView {
override var draggingImageComponents: [NSDraggingImageComponent] {
let components = super.draggingImageComponents
guard
self.backgroundStyle == .emphasized, //emphasized = selected
let textField = self.textField,
let newStyle = textField.attributedStringValue.mutableCopy() as? NSMutableAttributedString,
let labelIndex = components.firstIndex(where: { $0.key == .label })
else {
return components
@vedang
vedang / hey_notmuch!
Last active August 5, 2025 06:48
Notmuch configuration for Hey.com Style workflows.
- Specific Notmuch filters (and saved-searches) for:
+ The Feed (newsletters, blogs)
+ The Paper trail (receipts, ledger)
+ Screened Inbox (mail from folks you actually want to read)
+ Previously Seen (important mail that you've already read)
+ Unscreened Inbox (potential spam / stuff you don't want)
- Elisp Functions to move / categorize emails from a particular sender.
+ Adds tags needed by filters defined above to all email sent by a particular sender
+ Creates an entry in a DB file, which is used by the Notmuch post-new script when indexing new email, to auto-add the relevant tags.
////===--- EitherSequence.swift - A sequence type-erasing two sequences -----===//
////
//// This source file is part of the Swift.org open source project
////
//// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
//// Licensed under Apache License v2.0 with Runtime Library Exception
////
//// See https://swift.org/LICENSE.txt for license information
//// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
////
@TomFaulkner
TomFaulkner / Yabai_Configs.md
Last active February 25, 2025 06:26
Yabai configs

This is my current (as of 4/30/2020) Yabai and skhdrc config as well as the Ubersicht (http://tracesof.net/uebersicht/) widget I use rather than the Yabai status bar. I went this route rather than the built-in status bar because I didn't like how Yabai as of 2.0.1 handled multiple monitors in the status bar.

Nothing is too far from defaults here, and the spaces.coffee was something I found linked in an issue on Yabai's github page.