Skip to content

Instantly share code, notes, and snippets.

View tapsandswipes's full-sized avatar

Antonio Cabezuelo Vivo tapsandswipes

View GitHub Profile
@macguru
macguru / ScopedTask.swift
Last active November 7, 2025 05:28
ScopedTask: A wrapper around Task that auto-cancels when going out of scope.
/// A task that is cancelled if goes out of scope, i.e. the last reference on it has been discarded.
public final class ScopedTask<Success: Sendable, Failure: Error>: Sendable {
/// The underlying task
let wrapped: Task<Success, Failure>
/// Wraps a task into a scoped task.
init(wrapping task: Task<Success, Failure>) {
wrapped = task
}
#!/bin/sh
# dfn: df normalized, or df not noisy, or df nicely, or df new
#
# Whatever you want to call it, this script makes df useful again.
# It removes read-only disks for Time Machine backups, system volumes
# that can't be modified, unbrowsable volumes, and other stuff you don't
# really care about.
#
# Instead, you get the same drives that you see on your Mac desktop in an
@stevdza-san
stevdza-san / DeviceType.kt
Created September 21, 2025 05:54
Adaptive layout in Compose Multiplatform.
import androidx.compose.material3.adaptive.HingeInfo
import androidx.compose.material3.adaptive.WindowAdaptiveInfo
import androidx.window.core.layout.WindowSizeClass
sealed class DeviceType : Comparable<DeviceType> {
abstract val minWidth: Int
abstract val minHeight: Int
abstract val rank: Int
override fun compareTo(other: DeviceType): Int = this.rank - other.rank
@twostraws
twostraws / SpriteKit-SwiftUI-Metaballs.swift
Created June 16, 2025 14:05
A 30-minute hack to recreate the "iBeer" effect using SpriteKit, SwiftUI, and metaballs.
//
// A 30-minute hack to recreate the "iBeer" effect using SpriteKit, SwiftUI, and metaballs.
// The effect is created by having hundreds of physics-enabled balls in a SpriteKit scene,
// all drawing nothing. These balls are then read back out by SwiftUI in a TimelineView, and
// drawn using blur and alpha threshold filters to make them appear to be a liquid.
// The SpriteKit scene then has its gravity changed dynamically using the accelerometer,
// meaning that the "liquid" splashes around as you tilt your phone.
//
// Created by Paul Hudson
// https://www.hackingwithswift.com/license
@steipete
steipete / swift-testing-playbook.md
Last active November 17, 2025 15:17
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

//
// ColorSchemeApp.swift
// ColorScheme
//
// Created by Craig Hockenberry on 9/11/24.
//
import SwiftUI
@main
@chockenberry
chockenberry / PrivacyInfo.xcprivacy
Last active April 19, 2024 18:39
PrivacyInfo.xcprivacy sample
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>NSPrivacyAccessedAPITypes</key>
<array>
<dict>
<key>NSPrivacyAccessedAPITypeReasons</key>
<array>
<string>CA92.1</string>
@realvjy
realvjy / ChoasLinesShader.metal
Last active November 21, 2025 23:35
Choas Lines - Metal Shader
// Lines
float hash( float n ) {
return fract(sin(n)*753.5453123);
}
// Slight modification of iq's noise function.
float noise(vector_float2 x )
{
vector_float2 p = floor(x);
vector_float2 f = fract(x);
@lukaskubanek
lukaskubanek / SwiftUIListRowHighlightFix.swift
Last active March 26, 2024 17:51
A workaround for fixing SwiftUI’s list row highlighting behavior by preventing unwanted delays
import InterposeKit
import SwiftUI
/// A workaround for an issue in SwiftUI related to delayed highlighting of list rows upon user
/// interaction, rendering it inconsistent with UIKit.
///
/// This fix implements the solution proposed by Léo Natan and utilizes `InterposeKit` by Peter
/// Steinberger to modify the behavior of `UICollectionViewCell` instances used internally
/// by SwiftUI.
///
@zhwayne
zhwayne / EditMenu.swift
Created September 21, 2023 09:44
EditMenu for SwiftUI
//
// EditMenu.swift
// CalcApp
//
// Created by iya on 2023/6/9.
// Copyright © 2023 wayne. All rights reserved.
//
import SwiftUI
import UIKit