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
struct ScrollViewOffsetPreferenceKey: PreferenceKey { | |
static var defaultValue: CGPoint = .zero | |
static func reduce(value: inout CGPoint, nextValue: () -> CGPoint) { | |
value = nextValue() | |
print("value = \(value)") | |
} | |
typealias Value = CGPoint | |
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 Foundation | |
import WebKit | |
final class WebCacheCleaner { | |
class func clean() { | |
HTTPCookieStorage.shared.removeCookies(since: Date.distantPast) | |
print("[WebCacheCleaner] All cookies deleted") | |
WKWebsiteDataStore.default().fetchDataRecords(ofTypes: WKWebsiteDataStore.allWebsiteDataTypes()) { records in |
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
https://statici.icloud.com/fmipmobile/deviceImages-9.0/iPhone/iPhone9,4-2-3-0/online-infobox__3x.png | |
A B C D E F G | |
A: deviceImages version seems to determine the format of the image specifier (C, D, E, F) | |
B: device marketing name | |
C: device model identifier | |
D: color cover glass (front color) | |
1 - Black | |
2 - White | |
E: device enclosure color (back color) |
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 | |
#if os(iOS) || os(tvOS) | |
public typealias PlatformView = UIView | |
public typealias PlatformViewRepresentable = UIViewRepresentable | |
#elseif os(macOS) | |
public typealias PlatformView = NSView | |
public typealias PlatformViewRepresentable = NSViewRepresentable | |
#endif |
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
protocol ReferenceEncodable: Identifiable { | |
static var referenceStorageKey: CodingUserInfoKey { get } | |
} | |
extension ReferenceEncodable { | |
static var referenceStorageKey: CodingUserInfoKey { | |
CodingUserInfoKey(rawValue: String(describing: Self.self) + "ReferenceStorage")! | |
} | |
} |
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
# Add to your zsh profile | |
function devicepid() { | |
if [ -z "$1" ]; then | |
echo "Usage: devicepid <device-name> <search>" | |
echo "Example: devicepid 'iPhone 15 Pro Max' SpringBoard" | |
return 1 | |
fi | |
if [ -z "$2" ]; then |
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
#!/bin/bash | |
# Recursivelly removes all apps from your Xcode archives from the LaunchServices database, preventing them from being used for widgets, launch at login, etc. | |
/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -R -f -u $HOME/Library/Developer/Xcode/Archives |
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
/** | |
A better way to "store value types" in NSUserDefaults or NSUbiquitousKeyValueStore | |
*/ | |
import Foundation | |
/// ValueCoder is a class that can encode values of a specific type via NSCoding | |
protocol ValueCoder: NSObjectProtocol, NSCoding { | |
/// The type this coder can encode/decode | |
associatedtype ValueType |
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 | |
#if !os(watchOS) | |
#if canImport(UIKit) | |
public typealias PlatformViewRepresentableType = UIViewRepresentable | |
#else | |
public typealias PlatformViewRepresentableType = NSViewRepresentable | |
#endif // canImport(UIKit) |
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
/// Created by Gui Rambo | |
/// This wraps Apple's Compression framework to compress/decompress Data objects. | |
/// It will use Compression's modern API for iOS 13+ and its old API for older versions. | |
/// For more information, check out Apple's documentation: https://developer.apple.com/documentation/compression | |
/* | |
Copyright 2020 Guilherme Rambo | |
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 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: |
NewerOlder