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 | |
public protocol ReusableTableViewCell: class { | |
static var cellIdentifier: String { get } | |
static func reusableTableView<T>(tableView: UITableView, forIndexPath indexPath: NSIndexPath) -> T | |
} | |
extension ReusableTableViewCell { | |
public static func reusableTableView<T>(tableView: UITableView, forIndexPath indexPath: NSIndexPath) -> T { | |
guard let cell: T = tableView.dequeueReusableCellWithIdentifier(self.cellIdentifier, forIndexPath: indexPath) as? T else { |
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 | |
//Swift 2.2 | |
public func もし(val: Bool, @noescape _ closure: () -> Void) -> Void { | |
if val { | |
closure() | |
} | |
} | |
public func 間(@autoclosure check: (Void) -> Bool, @noescape _ closure: () -> Void) -> Void { |
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
# Mac側 | |
docker run --privileged -d -p 9080:9080 --name centos_realm centos:6.8 /sbin/init | |
docker exec -it centos_realm /bin/bash | |
# Docker内 | |
yum update -y && \ | |
yum install -y wget curl && \ | |
yum -y groupinstall base "Development tools" && \ | |
iptables -A INPUT -p tcp -m tcp --dport 9080 -j ACCEPT && \ | |
service iptables save && \ |
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
// Instantitable | |
import UIKit | |
public protocol Instantitable: class {} | |
public protocol StoryboardInstantitable: Instantitable { | |
static var viewControllerIdentifier: String? { get } | |
} |
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
// MARK: - Regular Expression | |
private extension String { | |
func regexp(_ pattern: String) -> NSRegularExpression { | |
do { | |
let regexp: NSRegularExpression = try NSRegularExpression(pattern: pattern, options: [NSRegularExpression.Options.caseInsensitive]) | |
return regexp | |
} catch { | |
fatalError("regular expression pattern is invalid.") | |
} | |
} |
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
[alias] | |
unstage=reset HEAD | |
pushcurrent=!git push origin `git rev-parse --abbrev-ref HEAD` | |
pullcurrent=!git pull origin `git rev-parse --abbrev-ref HEAD` | |
removemergedbranch=!git branch --merged | grep -vE '^\\*|master$|develop$' | xargs -I % git branch -d % |
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 AnyGetableAndSavable { | |
associatedtype T | |
func get() -> T | |
func save() | |
} | |
class GetAndSaver<U>: AnyGetableAndSavable { | |
typealias T = U | |
var value: T | |
required init(value: T) { | |
self.value = value |
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
sips icon.png -Z 20 --out icon_20.png | |
sips icon.png -Z 40 --out icon_20@2x.png | |
sips icon.png -Z 60 --out icon_20@3x.png | |
sips icon.png -Z 29 --out icon_29.png | |
sips icon.png -Z 58 --out icon_29@2x.png | |
sips icon.png -Z 87 --out icon_29@3x.png | |
sips icon.png -Z 40 --out icon_40.png | |
sips icon.png -Z 80 --out icon_40@2x.png |
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 class DIContainer { | |
public typealias Resolver = ([Any]) -> Any? | |
static var resolvers: [ObjectIdentifier: Resolver] = [:] | |
public static func register<T>(_ type: T.Type, resolver: @escaping Resolver) { | |
resolvers[ObjectIdentifier(type)] = resolver | |
} | |
public static func resolve<T>(_ type: T.Type, args: Any...) -> T? { | |
guard let resolver = resolvers[ObjectIdentifier(type)] else { return nil } | |
return resolver(args) as? 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 | |
public class Variable<T: Equatable> { | |
public var value: T { | |
didSet { | |
obserbers.forEach { | |
$0(value) | |
} | |
} |
OlderNewer