This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
enum NavDest: Hashable { | |
case a | |
case b | |
case c | |
case d(Int) | |
} | |
struct ContentView: View { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import SwiftUI | |
/// Mostly courtesy of ChatGPT but even with some coaching it couldn't get it to the finish line. Humans are still useful! It's still ugly though. | |
struct ZigzagBorder: Shape { | |
let lineWidth: CGFloat | |
let amplitude: CGFloat | |
func path(in rect: CGRect) -> Path { | |
var path = Path() | |
let startX = rect.minX |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Usage | |
import OSLog | |
private let log = Logger.forType(SheepFootPacker.self) // category is the package/module name | |
class SheepFootPacker { | |
func squishThings() { | |
log.debug("squishing") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@available(iOS 15.0, *) | |
struct TwinkleView:View { | |
private func position(in proxy: GeometryProxy, sparkle:Sparkle) -> CGPoint { | |
let radius = min(proxy.size.width, proxy.size.height) / 2.0 | |
let drawnRadius = (radius - 5) * sparkle.position.x | |
let angle = Double.pi * 2.0 * sparkle.position.y | |
let x = proxy.size.width * 0.5 + drawnRadius * cos(angle) | |
let y = proxy.size.height * 0.5 + drawnRadius * sin(angle) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Cocoa | |
public struct UIEdgeInsets { | |
public var top: CGFloat // specify amount to inset (positive) for each of the edges. values can be negative to 'outset' | |
public var left: CGFloat | |
public var bottom: CGFloat | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import OSLog | |
extension Logger { | |
static let subsystem = Bundle.main.bundleIdentifier! | |
static func `for`(category: String) -> Logger { | |
Logger(subsystem: subsystem, category: category) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Combine | |
import Foundation | |
public protocol BetterNotification {} | |
private extension BetterNotification { | |
static var notificationName: Notification.Name { | |
Notification.Name(rawValue: "BetterNotification:\(Self.self)") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Courtesy of https://paul-samuels.com/blog/2022/10/12/easy-simulator-data-access/ | |
#if targetEnvironment(simulator) | |
let environment = ProcessInfo.processInfo.environment | |
if | |
let hostHome = environment["SIMULATOR_HOST_HOME"].map(URL.init(fileURLWithPath:)), | |
let simulatorHome = environment["HOME"].map(URL.init(fileURLWithPath:)), | |
let simulatorVersion = environment["SIMULATOR_RUNTIME_VERSION"], | |
let simulatorName = environment["SIMULATOR_DEVICE_NAME"], | |
let productName = Bundle.main.infoDictionary?["CFBundleName"] | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
eval "$(/opt/homebrew/bin/brew shellenv)" | |
local_paths=( | |
/Library/Developer/Toolchains/swift-latest.xctoolchain/usr/bin | |
/opt/homebrew/Cellar/python@3.10/3.10.*/Frameworks/Python.framework/Versions/3.10/bin(N) | |
/opt/homebrew/opt/libpq/bin | |
) | |
for dir in $local_paths; do | |
if [[ -d "$dir" ]]; then | |
path=($dir $path) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
A simple PHP class to perform basic operations against Amazon S3 and compatible | |
services. Requires modern PHP (7+, probably) with curl, dom, and iconv modules. | |
Copyright 2022 Marco Arment. Released under the MIT license: | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights |