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
// | |
// VirtualKeyboard.swift | |
// MacBook Air M1 Zhuyin Keyboard | |
// Written with SwiftUI ~=300 LOC, < 4hrs | |
// Created by Ethan Huang on 2021/1/13. | |
// Twitter: @ethanhuang13 | |
import SwiftUI | |
struct VirtualKeyboard: View { |
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 Foundation | |
public final class Logger { | |
public let name: String? | |
private var minimumSeverity: Severity? | |
public func error(@autoclosure message: () -> String) { | |
guard minimumSeverity >= .error else { return } | |
NSLog(message()) | |
} |
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 Foundation | |
// Controller that evokes its callback every minute | |
class ClockController { | |
private let minuteCallback: NSDate -> () | |
init(minuteCallback: NSDate -> ()) { | |
self.minuteCallback = minuteCallback | |
callbackAndReschedule() | |
} |
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
extension NSDate { | |
var emojiDescription: Character { | |
let components = NSCalendar.currentCalendar().components(.CalendarUnitHour | .CalendarUnitMinute, fromDate: self) | |
let clockHour = components.hour % 12 | |
let isSecondHalfOfHour = components.minute >= 15 && components.minute < 45 | |
switch (clockHour, isSecondHalfOfHour) { | |
case (0, false): return "🕛" | |
case (0, true): return "🕧" |
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
enum Emoji: String { | |
case Copyright = "\u{00A9}" | |
case Registered = "\u{00AE}" | |
case Bangbang = "\u{203C}" | |
case Interrobang = "\u{2049}" | |
case Tm = "\u{2122}" | |
case InformationSource = "\u{2139}" | |
case LeftRightArrow = "\u{2194}" | |
case ArrowUpDown = "\u{2195}" | |
case ArrowUpperLeft = "\u{2196}" |
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
@implementation MySharedThing | |
+ (id)sharedInstance | |
{ | |
DEFINE_SHARED_INSTANCE_USING_BLOCK(^{ | |
return [[self alloc] init]; | |
}); | |
} | |
@end |