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 | |
import PlaygroundSupport | |
extension Double { | |
func toRadians() -> Double { | |
return self * Double.pi / 180 | |
} | |
func toCGFloat() -> CGFloat { | |
return CGFloat(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
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
# Apple Silicon laptops with firmware > 13.0 have a native charge threshold that does not required any userspace daemon running. | |
# This native limit works even when the laptop is sleeping or powered off therefore it is preferable to the userspace daemon. | |
# Nonetheless, it only works with fixed thresholds (80% as upper limit and 70% as lower limit). | |
# CHWA key is the one used to enable/disable the native limit. 01 = 80% limit, 00 = no limit | |
## | |
typeset -g smc_command="/usr/local/bin/smc" | |
typeset -g smc_charge_limit_key="CHWA" | |
typeset -g smc_charge_limit_status_on="01" | |
typeset -g smc_charge_limit_status_off="00" |