Skip to content

Instantly share code, notes, and snippets.

View antonyalkmim's full-sized avatar

Antony Alkmim antonyalkmim

View GitHub Profile
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
@antonyalkmim
antonyalkmim / RefreshableCompat.swift
Created March 6, 2024 18:10
SwiftUI RefreshableCompat iOS13
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 {
@antonyalkmim
antonyalkmim / bash_commands.md
Created June 4, 2023 18:08
Awesome bash commands

List top10 mostly used cli commands

history | awk '{print $2}' | sort | uniq -c | sort -rn | head -10
@antonyalkmim
antonyalkmim / make_xcframeowork.sh
Created October 10, 2022 12:11
Make MLKit simulator-arm64
# 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"
@antonyalkmim
antonyalkmim / README.md
Created September 14, 2021 19:21 — forked from progrium/README.md
Setting up M1 Macs for x86 development with Homebrew

Key Points

  • 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 example arch -x86_64 go
  • Running a shell in this mode means you don't have to prefix commands: arch -x86_64 zsh then go or whatever
  • Don't just immediately install Homebrew as usual. It should most likely be installed in x86 mode.

Homebrew

Not all toolchains and libraries properly support M1 arm64 chips just yet. Although

@antonyalkmim
antonyalkmim / swiftui+uiview.swift
Created September 10, 2021 13:04
SwiftUI+UIView.swift
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 {
@antonyalkmim
antonyalkmim / oh-my-zsh-setup.md
Last active April 4, 2021 18:28
Setup Cmd+[left|right] and Option+[left|right] mac shortcuts for iTerm2
@antonyalkmim
antonyalkmim / CurrencyTextField.swift
Created December 13, 2020 18:39
SwiftUI CurrencyTextField
import SwiftUI
struct CurrencyTextField: View {
let title: String
@Binding var amountString: String
var body: some View {
TextField(title, text: $amountString)
.keyboardType(.numberPad)
@antonyalkmim
antonyalkmim / if+when.swift
Last active October 26, 2022 19:59
Iff + When Swift implementation
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
}
}
@antonyalkmim
antonyalkmim / cleanup.sh
Created October 9, 2020 12:21 — forked from Bunn/cleanup.sh
Cleanup space
#!/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