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 | |
// Notes: | |
// - You must explicitly weak link to UIKit to support iOS 7 | |
// - Action sheets on iOS 7 only show a title | |
func showAlert(viewController: UIViewController, style: UIAlertControllerStyle = .Alert, title: String? = nil, message: String? = nil, sourceView: UIView? = nil, completion: (() -> ())? = nil, buttons: (UIAlertActionStyle, String, (() -> ())?)...) { | |
if (NSClassFromString("UIAlertController") != nil) { | |
// iOS 8+ |
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 ApplyProtocol { } | |
extension NSObject: ApplyProtocol { } | |
extension ApplyProtocol { | |
@discardableResult func apply(closure: (Self) -> Void) -> Self { | |
closure(self) | |
return 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
// | |
// SimpleMediaSaver.swift | |
// | |
// Created by Dennis Lysenko on 27-09-16. | |
// Copyright © 2016 Dennis Lysenko. All rights reserved. | |
// https://gist.github.com/dennislysenko/5388cacb83b754e8983e99bff7fef2d2 | |
// | |
// This gist is licensed under the terms of the MIT license. | |
// |
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
brew list -1 | while read line; do brew unlink $line; brew link $line; done |
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
# ag <https://github.com/ggreer/the_silver_searcher> | |
# usage: ag-replace.sh [search] [replace] | |
# caveats: will choke if either arguments contain a forward slash | |
# notes: will back up changed files to *.bak files | |
ag -0 -l $1 | xargs -0 perl -pi.bak -e "s/$1/$2/g" | |
# or if you prefer sed's regex syntax: | |
ag -0 -l $1 | xargs -0 sed -ri.bak -e "s/$1/$2/g" |