This file contains hidden or 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
//: | |
//: UIView Animation Syntax Sugar | |
//: | |
//: Created by Andyy Hope on 18/08/2016. | |
//: Twitter: @andyyhope | |
//: Medium: Andyy Hope, https://medium.com/@AndyyHope | |
import UIKit | |
extension UIView { |
This file contains hidden or 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 Dispatch | |
private var throttleWorkItems = [AnyHashable: DispatchWorkItem]() | |
private var lastDebounceCallTimes = [AnyHashable: DispatchTime]() | |
private let nilContext: AnyHashable = arc4random() | |
public extension DispatchQueue { | |
/** | |
- parameters: | |
- deadline: The timespan to delay a closure execution |
This file contains hidden or 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 Character { | |
func utf8() -> UInt8 { | |
let utf8 = String(self).utf8 | |
return utf8[utf8.startIndex] | |
} | |
} | |
func encrypt(c:Character, key:Character) -> String { |
This file contains hidden or 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
@interface SKStoreReviewDummyClass : NSObject @end | |
@implementation SKStoreReviewDummyClass | |
+ (void)load | |
{ | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
Class class = [self class]; |
This file contains hidden or 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
# taken from http://www.piware.de/2011/01/creating-an-https-server-in-python/ | |
# generate server.xml with the following command: | |
# openssl req -new -x509 -keyout server.pem -out server.pem -days 365 -nodes | |
# run as follows: | |
# python simple-https-server.py | |
# then in your browser, visit: | |
# https://localhost:4443 | |
import BaseHTTPServer, SimpleHTTPServer | |
import ssl |
This file contains hidden or 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 | |
enum timingFunction{ | |
case Linear,EaseIn,EaseOut,EaseInOut, | |
Spring, | |
EaseInSine,EaseOutSine,EaseInOutSine, | |
EaseInQuad,EaseOutQuad,EaseInOutQuad, | |
EaseInCubic,EaseOutCubic,EaseInOutCubic, | |
EaseInQuart,EaseOutQuart,EaseInOutQuart, | |
EaseInQuint,EaseOutQuint,EaseInOutQuint, |
This file contains hidden or 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 | |
import UIKit | |
struct ViewStyle<T> { | |
let style: (T) -> Void | |
} | |
let filled = ViewStyle<UIButton> { | |
$0.setTitleColor(.white, for: .normal) | |
$0.backgroundColor = .red |
This file contains hidden or 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 UIView { | |
func firstSuperview<T>(where predicate: (T) -> Bool) -> T? where T: UIView { | |
if let superview = superview as? T, predicate(superview) { | |
return superview | |
} | |
return superview?.firstSuperview(where: predicate) | |
} | |
} | |
// view.firstSuperview(where: { (view: UITableView) in view.isEditing }) |
This file contains hidden or 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 UIColor { | |
// get a complementary color to this color | |
// https://gist.github.com/klein-artur/025a0fa4f167a648d9ea | |
var complementary: UIColor { | |
let ciColor = CIColor(color: self) | |
// get the current values and make the difference from white: | |
let compRed: CGFloat = 1.0 - ciColor.red |
This file contains hidden or 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
//Inspired by: http://planetozh.com/blog/2012/10/generate-random-pronouceable-words/ | |
func randomWord(wordLength: Int = 6) -> String { | |
let kCons = 1 | |
let kVows = 2 | |
var cons: [String] = [ | |
// single consonants. Beware of Q, it"s often awkward in words | |
"b", "c", "d", "f", "g", "h", "j", "k", "l", "m", | |
"n", "p", "r", "s", "t", "v", "w", "x", "z", |
OlderNewer