history | awk '{print $2}' | sort | uniq -c | sort -rn | head -10
This file contains hidden or 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 MyComponent: View { | |
var textColor: Color = .black | |
var textSize: CGFloat = 12 | |
} | |
extension MyComponent { | |
func set<V>(_ keypath: WritableKeyPath<Self, V>, to value: V) -> Self { | |
var copy = self | |
copy[keyPath: keypath] = value | |
return copy |
This file contains hidden or 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 | |
private struct RefreshableCompat: ViewModifier { | |
let onRefresh: () async -> Void | |
@State private var isRefreshing = false | |
private let threshold: CGFloat = 50.0 | |
func body(content: Content) -> some View { |
This file contains hidden or 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
# mkdir -p iphoneos | |
# mkdir -p iphonesimulator | |
cp -R MLImage.framework/ iphoneos/MLImage.framework | |
cp -R MLImage.framework/ iphonesimulator/MLImage.framework | |
xcrun lipo -remove i386 -remove x86_64 -remove armv7 ./iphoneos/MLImage.framework/MLImage -o ./iphoneos/MLImage.framework/MLImage | |
xcrun lipo -i iphoneos/MLImage.framework/MLImage | |
xcrun lipo -remove i386 -remove arm64 -remove armv7 ./iphonesimulator/MLImage.framework/MLImage -o ./iphonesimulator/MLImage.framework/MLImage | |
xcrun lipo -i iphonesimulator/MLImage.framework/MLImage | |
xcodebuild -create-xcframework -framework iphoneos/MLImage.framework/ -framework iphonesimulator/MLImage.framework/ -output "MLImage.xcframework" |
- In general, binaries built just for x86 architecture will automatically be run in x86 mode
- You can force apps in Rosetta 2 / x86 mode by right-clicking app, click Get Info, check "Open using Rosetta"
- You can force command-line apps by prefixing with
arch -x86_64
, for examplearch -x86_64 go
- Running a shell in this mode means you don't have to prefix commands:
arch -x86_64 zsh
thengo
or whatever - Don't just immediately install Homebrew as usual. It should most likely be installed in x86 mode.
Not all toolchains and libraries properly support M1 arm64 chips just yet. Although
This file contains hidden or 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 UIKit | |
import SwiftUI | |
extension UIViewController { | |
/// Add a SwiftUI `View` as a child of the input `UIView`. | |
/// - Parameters: | |
/// - swiftUIView: The SwiftUI `View` to add as a child. | |
/// - view: The `UIView` instance to which the view should be added. | |
func addSubview<Content>(_ swiftUIView: Content, to view: UIView) where Content: View { |
Setup Cmd+[left|right] and Option+[left|right] mac shortcuts for iTerm2
StackOverflow question with its answer: https://stackoverflow.com/questions/6205157/how-to-set-keyboard-shortcuts-to-jump-to-beginning-end-of-line
For | Action | Send |
---|
This file contains hidden or 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 | |
struct CurrencyTextField: View { | |
let title: String | |
@Binding var amountString: String | |
var body: some View { | |
TextField(title, text: $amountString) | |
.keyboardType(.numberPad) |
This file contains hidden or 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
typealias IfResultClosure<Result> = (() -> Result) | |
typealias Case<Value, Result> = (Value, IfResultClosure<Result>) | |
@_functionBuilder | |
struct CaseBuilder<Value, Result> { | |
static func buildBlock(_ cases: Case<Value, Result>...) -> [Case<Value, Result>] { | |
cases | |
} | |
} |
This file contains hidden or 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 | |
echo "Removing unavailable simulators..." | |
xcrun simctl delete unavailable | |
echo "Brew cleanup..." | |
brew cleanup | |
echo "Removing Xcode Caches..." | |
rm -rf ~/Library/Caches/com.apple.dt.Xcode |
NewerOlder