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
// | |
// URL+XAttr.swift | |
// Xattr Editor | |
// | |
// Created by Richard Csiko on 2017. 01. 21.. | |
// https://raw.githubusercontent.com/rcsiko/xattr-editor/master/xattr-editor/Xattr%20Editor/Classes/Extensions/URL%2BXAttr.swift | |
// | |
// MIT License | |
// | |
// Copyright (c) 2017 rcsiko |
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 | |
extension String { | |
/** | |
Returns a country flag from an **uppercased** ISO Alpha-2 country code String | |
Example usage: "US".flag | |
@return A flag emoji. Example: 🇺🇸 | |
*/ |
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
CGFloat ScaleToAspectFitRectInRect(CGRect rfit, CGRect rtarget) | |
{ | |
// first try to match width | |
CGFloat s = CGRectGetWidth(rtarget) / CGRectGetWidth(rfit); | |
// if we scale the height to make the widths equal, does it still fit? | |
if (CGRectGetHeight(rfit) * s <= CGRectGetHeight(rtarget)) { | |
return s; | |
} | |
// no, match height instead | |
return CGRectGetHeight(rtarget) / CGRectGetHeight(rfit); |
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 NSViewController { | |
var document: AnyObject? { | |
if let target = self.parent, target.responds (to: #selector(getter: self.document)) { | |
return target.perform(#selector(getter: self.document)) as AnyObject? | |
} | |
return self.view.window?.windowController?.document | |
} | |
var managedObjectContext: NSManagedObjectContext? { |
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
- (void)controllerWillChangeContent:(NSFetchedResultsController *)controller | |
{ | |
self.shouldReloadCollectionView = NO; | |
self.blockOperation = [[NSBlockOperation alloc] init]; | |
} | |
- (void)controller:(NSFetchedResultsController *)controller didChangeSection:(id<NSFetchedResultsSectionInfo>)sectionInfo | |
atIndex:(NSUInteger)sectionIndex forChangeType:(NSFetchedResultsChangeType)type | |
{ | |
__weak UICollectionView *collectionView = self.collectionView; |
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 UIKit | |
import MapKit | |
import XCPlayground | |
// https://macteo.it/ios/2016/08/10/blurred-rounded-uiview.html | |
let extraLightBlur = UIBlurEffect(style: .extraLight) | |
let cornerRadius : CGFloat = 0 | |
class BlurredRoundedView: UIView { |
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
// | |
// Created by Adam Preble on 2/19/15. | |
// | |
/// Weak, unordered collection of objects. | |
public struct WeakSet<T where T: AnyObject, T: Hashable> { | |
typealias Element = T | |
/// Maps Element hashValues to arrays of Entry objects. | |
/// Invalid Entry instances are culled as a side effect of add() and remove() |
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
//: Playground - noun: a place where people can play | |
import Foundation | |
// Use of the protocol allows us to hold collections of ActionTrampolices of any type T | |
protocol Action { | |
func performAction() -> Bool | |
} | |
class ActionTrampoline<T: AnyObject>: NSObject, Action |
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
// | |
// Adaptable.swift | |
// | |
// Created by Jason Jobe on 5/2/17. | |
// Copyright © 2017 WildThink. All rights reserved. | |
// | |
import Foundation | |
public protocol Adaptable { |
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 | |
protocol Currency { | |
static var code: String { get } | |
static var factor: NSDecimalNumber { get } | |
} | |
enum GBP: Currency { | |
static let code = "GBP" | |
static let factor: NSDecimalNumber = 1.44 | |
} |