Skip to content

Instantly share code, notes, and snippets.

Rob Mayoff mayoff

Block or report user

Report or block mayoff

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mayoff
mayoff / NSDateComponents+DictionaryLiteral.swift
Created Jun 3, 2016
Attempting to make NSDateComponents conform to DictionaryLiteralConvertible
View NSDateComponents+DictionaryLiteral.swift
import Cocoa
public extension NSDateComponents {
public convenience init(_ components: DictionaryLiteral<NSCalendarUnit, Int>) {
self.init()
for (key, value) in components {
setValue(value, forComponent: key)
}
}
}
@mayoff
mayoff / Main.storyboard
Created May 14, 2016
disclosable sections like Xcode inspectors
View Main.storyboard
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="10117" systemVersion="15E65" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="10117"/>
<capability name="stacking Non-gravity area distributions on NSStackView" minToolsVersion="7.0" minSystemVersion="10.11"/>
</dependencies>
<scenes>
<!--Application-->
<scene sceneID="JPo-4y-FX3">
@mayoff
mayoff / ConstraintCollection.swift
Last active Apr 19, 2016 — forked from jtbandes/ConstraintCollection.swift
Autolayout constraint literals in Swift (updated for Swift 2.2)
View ConstraintCollection.swift
#if os(iOS)
import UIKit
#else
import AppKit
#endif
let view = UIView(frame: CGRectMake(0, 0, 400, 300))
view.backgroundColor = UIColor.redColor()
let button = UIButton(type: .Custom)
@mayoff
mayoff / kvoperf.m
Created Feb 23, 2016
KVO 100x slowdown in El Capitan
View kvoperf.m
#import <Foundation/Foundation.h>
@interface Subject: NSObject
@property double a;
@property long b;
@property NSObject* c;
@property NSObject* d;
@property NSObject* e;
@property NSObject* f;
View Elad.storyboard
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="vXZ-lx-hvc">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
<capability name="Constraints with non-1.0 multipliers" minToolsVersion="5.1"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="ufC-wZ-h7g">
View FloatingViewController.swift
import UIKit
class FloatingButtonController: UIViewController {
private(set) var button: UIButton!
required init?(coder aDecoder: NSCoder) {
fatalError()
}
@mayoff
mayoff / Main.storyboard
Created Jan 12, 2016
Map view inside scroll view with screen edge available for paging
View Main.storyboard
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9531" systemVersion="15C50" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
View LayoutAnchor.swift
#if os(iOS)
import UIKit
typealias NSLayoutPriority = UILayoutPriority
#elseif os(OSX)
import AppKit
#endif
public extension NSLayoutAttribute {
/** Return a LayoutAnchor representing attribute `self` of `item`. */
@mayoff
mayoff / appfont-fontello-config.json
Last active Nov 12, 2018
Playground for drawing a UILabel with attributed text containing icons from a custom font
View appfont-fontello-config.json
{
"name": "appfont",
"css_prefix_text": "icon-",
"css_use_suffix": false,
"hinting": true,
"units_per_em": 1000,
"ascent": 850,
"glyphs": [
{
"uid": "324e9013e79ecf9e0e30a07feffa9d6b",
@mayoff
mayoff / maskCorners.swift
Created Nov 29, 2015
Playground for masking corners of a UIView
View maskCorners.swift
import XCPlayground
import Foundation
import UIKit
func maskCorners(corners: [UIViewContentMode], ofView view: UIView, toDepth depth: CGFloat) {
let s = 1 + 2 * depth
let path = UIBezierPath()
if corners.contains(.TopLeft) {
path.moveToPoint(CGPoint(x: 0, y: 0 + depth))
You can’t perform that action at this time.