Skip to content

Instantly share code, notes, and snippets.

View toddhopkinson's full-sized avatar

Todd Hopkinson toddhopkinson

View GitHub Profile
@ethanhuang13
ethanhuang13 / VirtualKeyboard.swift
Last active February 7, 2024 05:58
MacBook Air M1 Zhuyin Keyboard written with SwiftUI ~=300 LOC, < 4hrs
//
// 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 {
@JadenGeller
JadenGeller / Logger.swift
Last active September 2, 2016 17:09
Lightweight Multi-Severity Named Logging
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())
}
@JadenGeller
JadenGeller / ClockController.swift
Last active September 2, 2016 17:12
Clock Controller
import Foundation
// Controller that evokes its callback every minute
class ClockController {
private let minuteCallback: NSDate -> ()
init(minuteCallback: NSDate -> ()) {
self.minuteCallback = minuteCallback
callbackAndReschedule()
}
@JadenGeller
JadenGeller / NSDate Emoji Clock.swift
Created August 23, 2015 05:59
Emoji Clock from NSDate 🕛
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 "🕧"
@DJBen
DJBen / Emoji.swift
Created January 3, 2015 18:17
Emoji-Swift
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}"
@lukeredpath
lukeredpath / ExampleClass.m
Created June 30, 2011 22:18
Macro for creating your "shared instance" using GCD
@implementation MySharedThing
+ (id)sharedInstance
{
DEFINE_SHARED_INSTANCE_USING_BLOCK(^{
return [[self alloc] init];
});
}
@end