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 PhoneNumberKit | |
/* Dear Future Me, | |
You abandoned this code as you realized, immediately after implemented it, and getting it to work that there were multiple points still left unaddresssed. | |
1. You were unsure how this text field would interact with accessibility, you set the attributedText to include the suffix of the placeholder ... this would get read by any voice over and would completely ruin an experience of something simple for people using voice over. | |
2. While this text field lets you type over the placeholder the moment you stray from the placeholder format it makes the experience worse. | |
3. You decided simple is better than fancy looking but extremely complicated. |
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
@propertyWrapper | |
class LazyToOne<Value: Decodable & FetchableRecord>: Decodable { | |
var field: String | |
var table: String | |
var id: String? | |
var cachedValue: Value? | |
init(field: String, table: String) { |
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 | |
@available(iOS 10.0, *) | |
class CustomAlertController: UIViewController { | |
var statusBarFadeWindow = UIWindow() | |
var previousViewControllerStatusBarStyle = UIStatusBarStyle.default | |
var contentView = UIView() | |
var buttons: [UIButton] = [] |
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
var instructions: [UInt32] = [] | |
let supported = archSupported(.arm64) | |
if !supported { | |
print("Your installation of unicorn does not include support for ARM64") | |
print(" If you installed with homebrew you can include the ARM64 instruction set using the install flag --with-all") | |
exit(1) | |
} | |
var mov = encodeMOVZi(use64Bits: true, hw: 0, imm16: 2, .R0) |
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
#if os(macOS) | |
import Darwin | |
#else | |
import Glibc | |
#endif | |
final class ThreadLocal<T> { | |
var key: pthread_key_t |
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 builtin("compiler") | |
#import kai("fmt") | |
#import kai("time") | |
#import kai("os") | |
// NOTE: This is internal to the builtin package "compiler" | |
#compiler { | |
BeginWorkspace :: fn(named: string, configure: (*compiler.Workspace) -> void) -> void { /* ... */ } |
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 builtin("types") | |
u8 :: types.Integer{width: 8, signed: false} | |
u16 :: types.Integer{width: 16, signed: false} | |
u32 :: types.Integer{width: 32, signed: false} | |
u64 :: types.Integer{width: 64, signed: false} | |
i8 :: types.Integer{width: 8, signed: true} | |
i16 :: types.Integer{width: 16, signed: true} |
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 builtin("platform") | |
UnmaskTypePointer :: fn(ptr: *$T) -> *T { | |
return cast(*T) ((cast(platform.UIntptr) type) & ~0b111) | |
} | |
#assert(SizeOf(Type) == platform.PointerSize) | |
// NOTE: This just means the compiler skips over this code it's provided for reference |
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
#!/usr/bin/swift | |
import Foundation | |
func usage() -> Never { | |
print("usage: exec (start | finish | total | history | nuke)") | |
exit(1) | |
} | |
guard CommandLine.arguments.count > 1 else { |
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
func longZip<S1: Sequence, S2: Sequence>(_ seq1: S1, _ seq2: S2) -> AnySequence<(S1.Iterator.Element?, S2.Iterator.Element?)> { | |
var (iter1, iter2) = (seq1.makeIterator(), seq2.makeIterator()) | |
return AnySequence { | |
return AnyIterator { () -> (S1.Iterator.Element?, S2.Iterator.Element?)? in | |
let (l, r) = (iter1.next(), iter2.next()) | |
switch (l, r) { | |
case (nil, nil): | |
return nil |
NewerOlder