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
protocol P0 { | |
associatedtype Parent: P0 | |
} | |
protocol P1: P0 {} | |
protocol P2: P1 { | |
associatedtype X: P4 where X.Parent == Self | |
} |
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
public struct Fibonacci<Number: FixedWidthInteger>: Sequence { | |
public let startsAtZero: Bool | |
public init(startAtZero: Bool = true) { | |
startsAtZero = startAtZero | |
} | |
public func makeIterator() -> Iterator { | |
return .first(startsAtZero: startsAtZero) | |
} |
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
public struct Lazy<T> { | |
private let initialization: () -> T | |
public private(set) lazy var: T = self.initialization() | |
public init(initialization: () -> T) { | |
self.initialization = initialization | |
} | |
public init(other: Lazy<T>) { |
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 | |
open class LayerView<Layer: CALayer>: UIView { | |
public final override class var layerClass: Swift.AnyClass { | |
return Layer.self | |
} | |
public final var concreteLayer: Layer { | |
return layer as! Layer | |
} |
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
//ObjC | |
typedef NS_OPTIONS(NSUInteger, SomeOptions) { | |
SomeOptionsStarted, | |
SomeOptionsWorking, | |
SomeOptionsFailed, | |
SomeOptionsFinished | |
}; | |
// Swift | |
// Generated: |
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
Verifying that +ffried is my blockchain ID. https://onename.com/ffried |
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
- (UIImage *)fixRotation | |
{ | |
if (self.imageOrientation == UIImageOrientationUp) return self; | |
CGAffineTransform transform = CGAffineTransformIdentity; | |
switch (self.imageOrientation) { | |
case UIImageOrientationDown: | |
case UIImageOrientationDownMirrored: | |
transform = CGAffineTransformTranslate(transform, self.size.width, self.size.height); | |
transform = CGAffineTransformRotate(transform, M_PI); |
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 UIImage { | |
public func imageRotatedByDegrees(degrees: CGFloat) -> UIImage { | |
let radiansToDegrees: (CGFloat) -> CGFloat = { | |
return $0 * (180.0 / CGFloat(M_PI)) | |
} | |
let degreesToRadians: (CGFloat) -> CGFloat = { | |
return $0 / (180.0 * CGFloat(M_PI)) | |
} | |
// calculate the size of the rotated view's containing box for our drawing space |
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 Security | |
class Keychain { | |
class func save(key: String, data: NSData) -> Bool { | |
let query: [String: AnyObject] = [ | |
kSecClass : kSecClassGenericPassword, | |
kSecAttrAccount : key, | |
kSecValueData : data ] |
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
// | |
// UIColor+FFColorWithHex.h | |
// | |
// Created by Florian Friedrich on 11.07.14. | |
// Copyright (c) 2014 Florian Friedrich. All rights reserved. | |
// | |
// Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), | |
// to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, | |
// and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
// |
NewerOlder