Skip to content

Instantly share code, notes, and snippets.

View rydermackay's full-sized avatar

Ryder Mackay rydermackay

View GitHub Profile
import UIKit
struct InvalidationOptions: OptionSet {
static let constraints = InvalidationOptions(rawValue: 1)
static let layout = InvalidationOptions(rawValue: 1 << 1)
static let display = InvalidationOptions(rawValue: 1 << 2)
let rawValue: Int8
}
@propertyWrapper
import Foundation
struct Box<Value> {
let value: Value
}
extension Box {
// 1.
func map<T>(_ f: @escaping (Value) -> T) -> Box<T> {
return Box<T>(value: f(value))

Keybase proof

I hereby claim:

  • I am rydermackay on github.
  • I am ryder (https://keybase.io/ryder) on keybase.
  • I have a public key whose fingerprint is 7465 F04C 22DB 6BD9 88A8 DC87 C1A1 0B26 7866 5CE2

To claim this, I am signing this object:

int -[UIViewController setValue:forKey:](int arg0, int arg1, int arg2, int arg3) {
r14 = arg1;
rbx = [arg2 retain];
r12 = [arg3 retain];
*var_38 = arg0;
*(var_38 + 0x8) = _OBJC_CLASS_$_UIViewController;
[[var_38 super] setValue:rbx forKey:r12];
[rbx release];
if (*(int32_t *)__UIApplicationLinkedOnVersion != 0x0) {
if (*(int32_t *)__UIApplicationLinkedOnVersion >= 0x90000) {
// Xcode 8.3b1 (8W109m)
import Foundation
struct Box<T> {
let value: T
init(value: T) {
self.value = value
}
import Cocoa
private let _rfc3339Formatter: DateFormatter = {
let formatter = DateFormatter()
formatter.dateFormat = "yyyy'-'MM'-'dd'T'HH':'mm':'ss'Z'"
formatter.timeZone = TimeZone(secondsFromGMT: 0)
formatter.locale = Locale(identifier: "en_US_POSIX")
return formatter
}()
@rydermackay
rydermackay / MinimumViableButton.m
Created February 25, 2015 23:32
UIButton that lies about its bounds
@interface MinimumViableButton : UIButton
@end
@implementation MinimumViableButton
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event {
BOOL result = [super pointInside:point withEvent:event];
if (!result) {
const CGFloat length = 44;
@rydermackay
rydermackay / gist:7ddb1078b0d484da8bc4
Last active August 29, 2015 14:07
Wrapping the NSError ** dance
final class Box<T> {
let value: T
init(_ v: T) {
value = v
}
}
enum Result<T> {
case Success(Box<T>)
case Error(NSError)
@rydermackay
rydermackay / TempusFugit.playground
Last active August 29, 2015 14:06
CoreMedia could use some Swift love…
// Tempus fugit
import CoreMedia
let defaultTimeScale = Int32(kCMTimeMaxTimescale)
extension CMTime {
static var invalid: CMTime { return kCMTimeInvalid }
static var indefinite: CMTime { return kCMTimeIndefinite }
static var positiveInifinity: CMTime { return kCMTimePositiveInfinity }
@rydermackay
rydermackay / RGMKeyValueObservance.h
Created December 10, 2013 21:39
KVO in a nut. Use it, or don’t?
//
// RGMKeyValueObservance.h
// RGMKeyValueObservance
//
// Created by Ryder Mackay on 12/9/2013.
// Copyright (c) 2013 Ryder Mackay. All rights reserved.
//
#import <Foundation/Foundation.h>