View spmResolve.py
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
#!/opt/homebrew/bin/python3 | |
# Sometimes Xcode cannot resolve SPM(File -> Packages -> Resolve Package versions) if the dependency url is ssh | |
# This script is a workaround to resolve package versions. | |
# Usage: | |
# python spmResolve.py | |
# or | |
# python3 spmResolve.py | |
import os.path | |
import subprocess |
View AvatarView
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 AvatarView: View { | |
/// image | |
let image: String | |
/// size | |
let size: CGFloat | |
/// body | |
var body: some View { |
View appdocdir.zsh
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
function myappdocdir() { | |
devid=$(xcrun simctl list devices | grep Booted | sed -n 's/^.*\([A-F0-9]\{8\}-\([A-F0-9]\{4\}-\)\{3\}[A-F0-9]\{12\}\).*$/\1/p') | |
for folder in ~/Library/Developer/CoreSimulator/Devices/$devid/data/Containers/Data/Application/*; do | |
if [[ -a $folder/.com.apple.mobile_container_manager.metadata.plist ]]; then | |
if [[ 'com.apple.phone' = $(/usr/libexec/PlistBuddy -c 'Print :MCMMetadataIdentifier' $folder/.com.apple.mobile_container_manager.metadata.plist) ]]; then | |
echo $folder | |
break | |
fi | |
fi | |
done |
View advanced-swiftui-animations.swift
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
//------------------------------------------------------------------------ | |
// The SwiftUI Lab: Advanced SwiftUI Animations | |
// https://swiftui-lab.com/swiftui-animations-part1 (Animating Paths) | |
// https://swiftui-lab.com/swiftui-animations-part2 (GeometryEffect) | |
// https://swiftui-lab.com/swiftui-animations-part3 (AnimatableModifier) | |
//------------------------------------------------------------------------ | |
import SwiftUI | |
struct ContentView: View { | |
View .gitconfig
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
# Git Fuzzy Checkout | |
# | |
# Add the following script to your ~/.gitconfig by run: | |
# git config --global alias.fuzzy '!f() { git branch -a | grep -m1 -e ${1}.*${2} | sed "s/remotes\/origin\///" | xargs git checkout; }; f' | |
# | |
# alias of .gitconfig looks: | |
[alias] |
View DateExtensions
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://stackoverflow.com/questions/33145005/swift-nsdateformatter-not-using-correct-locale-and-format/61094162#61094162 | |
extension Date { | |
var timestamp: String { | |
let dataFormatter = DateFormatter() | |
dataFormatter.locale = Locale(identifier: "en_US_POSIX") | |
dataFormatter.dateFormat = "yyyy-MM-dd HH:mm:ss.SSSS" | |
return String(format: "%@", dataFormatter.string(from: self)) | |
} | |
} |
View Atomic
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://www.vadimbulavin.com/swift-atomic-properties-with-property-wrappers/ | |
/* | |
Although get and set are individually atomic, the combination of both is not. | |
Incrementing x is not atomic, since it first calls get and then set: | |
*/ | |
@propertyWrapper | |
struct Atomic<Value> { | |
private let queue = DispatchQueue(label: "com.vadimbulavin.atomic") | |
private var value: Value |
View UserDefaultExtensions
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://www.vadimbulavin.com/advanced-guide-to-userdefaults-in-swift/ | |
// what is the difference between WWDC2019 https://devstreaming-cdn.apple.com/videos/wwdc/2019/402fd460n3p3w5c/402/402_whats_new_in_swift.pdf | |
// The marker protocol | |
protocol PropertyListValue {} | |
extension Data: PropertyListValue {} | |
extension String: PropertyListValue {} | |
extension Date: PropertyListValue {} | |
extension Bool: PropertyListValue {} | |
extension Int: PropertyListValue {} |
View AppDelegate
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
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool | |
{ | |
let timeline = TimelineViewController() | |
let navigation = UINavigationController(rootViewController: timeline) | |
let frame = UIScreen.main.bounds | |
window = UIWindow(frame: frame) | |
window!.rootViewController = navigation | |
window!.makeKeyAndVisible() |
View sh_kits
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 | |
set -o nounset | |
set -o errexit | |
set -o verbose | |
set -o xtrace | |
log() { | |
local prefix="[$(date +%Y/%m/%d\ %H:%M:%S)]:" | |
echo "${prefix} $@" >&2 | |
} |
NewerOlder