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
cp /Applications/Xcode.app/Contents/SharedFrameworks/SourceModel.framework/Versions/A/Resources/LanguageSpecifications/Swift.xclangspec /Applications/Xcode.app/Contents/SharedFrameworks/DVTFoundation.framework/Versions/A/Resources/Swift.xclangspec |
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
sudo hidutil property --set '{ "UserKeyMapping": [ { "HIDKeyboardModifierMappingSrc": 0x700000064, "HIDKeyboardModifierMappingDst": 0x700000035 }, { "HIDKeyboardModifierMappingSrc": 0x700000035, "HIDKeyboardModifierMappingDst": 0x7000000E1 } ] }' |
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
appnope==0.1.2 | |
argon2-cffi==20.1.0 | |
attrs==21.2.0 | |
backcall==0.2.0 | |
bleach==4.0.0 | |
certifi==2021.5.30 | |
cffi==1.14.6 | |
cycler==0.10.0 | |
debugpy==1.4.1 | |
decorator==4.4.2 |
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
appnope==0.1.2 | |
argon2-cffi==20.1.0 | |
attrs==21.2.0 | |
backcall==0.2.0 | |
bleach==4.0.0 | |
cffi==1.14.6 | |
cycler==0.10.0 | |
debugpy==1.4.1 | |
decorator==5.0.9 | |
defusedxml==0.7.1 |
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
/// Example of using static functions and properties to construct an instance of a type | |
/// for a struct, similar to how enum uses its cases. | |
/// Let's call it Maybe. | |
struct Maybe<Wrapped> { | |
private(set) var value: Wrapped! | |
var hasValue: Bool { | |
value != nil | |
} |
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
/// Represents loading status, consisting of multiple steps. | |
/// All values' types can be specified depending on the problem. | |
enum AnyLoadingStatus<Loading, Loaded, Failed, Error: Swift.Error> { | |
case idle | |
case loading(Loading) | |
case loaded(Loaded) | |
case failed(Failed, Error) | |
} | |
extension AnyLoadingStatus { |
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 CoreLocation | |
/// Geohash algorithm implementation. | |
/// | |
/// It is a hierarchical spatial data structure which subdivides space into buckets of grid shape, | |
/// which is one of the many applications of what is known as a Z-order curve, and generally space-filling curves. | |
/// | |
/// Geohashes offer properties like arbitrary precision | |
/// and the possibility of gradually removing characters from the end of the code to reduce its size (and gradually lose precision). | |
/// Geohashing guarantees that the longer a shared prefix between two geohashes is, the spatially closer they are together. |
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
public indirect enum OneOrMore<T> { | |
case one(T) | |
case more(T, Self) | |
} | |
// MARK: Creation simplified | |
public extension OneOrMore { | |
static func few(_ head: T, _ tail: T...) -> OneOrMore { | |
few(head, tail) |
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
// inspired by https://blog.jle.im/entry/introduction-to-singletons-1.html | |
protocol DoorState {} | |
enum Opened: DoorState {} | |
enum Closed: DoorState {} | |
enum Locked: DoorState {} | |
struct Door<State: DoorState> { | |
let id: Int | |
} |
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 ExponentialBackoffConfig { | |
let initialRetries: Int | |
let initialInterval: TimeInterval | |
let maxInterval: TimeInterval | |
let factor: TimeInterval | |
init(initialRetries: Int = 2, initialInterval: TimeInterval = 0.3, maxInterval: TimeInterval = 120, factor: TimeInterval = 1.6) { | |
precondition(initialRetries >= 0 && initialInterval >= 0 && maxInterval >= initialInterval && factor > 1) | |
self.initialRetries = initialRetries |
NewerOlder