git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git
cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
git clone [email protected]:YOUR-USERNAME/YOUR-FORKED-REPO.git
cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
| $ FILE=/some/path/to/file.txt | |
| ################################### | |
| ### Remove matching suffix pattern | |
| ################################### | |
| $ echo ${FILE%.*} # remove ext | |
| /some/path/to/file | |
| $ FILE=/some/path/to/file.txt.jpg.gpg # note various file exts |
| // Creates a UIColor from a Hex string. | |
| func colorWithHexString (hex:String) -> UIColor { | |
| var cString:String = hex.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet()).uppercaseString | |
| if (cString.hasPrefix("#")) { | |
| cString = cString.substringFromIndex(1) | |
| } | |
| if (countElements(cString) != 6) { | |
| return UIColor.grayColor() |
| let evenNumbersAsString = numbers | |
| .filter { $0 % 2 == 0 } | |
| .map { NSNumberFormatter.localizedStringFromNumber($0, numberStyle: .DecimalStyle) } | |
| .reduce("") { countElements($0) == 0 ? $1 : $0 + "\n" + $1 } | |
| // "10,000\n50,000\n100,000\n1,000,000" |
| func controllerWillChangeContent(controller: NSFetchedResultsController) { | |
| self.shouldReloadCollectionView = false | |
| self.blockOperation = NSBlockOperation() | |
| } | |
| func controller(controller: NSFetchedResultsController, didChangeSection sectionInfo: NSFetchedResultsSectionInfo, atIndex sectionIndex: Int, forChangeType type: NSFetchedResultsChangeType) { | |
| let collectionView = self.collectionView | |
| switch type { | |
| case NSFetchedResultsChangeType.Insert: | |
| self.blockOperation.addExecutionBlock({ |
| // Playground - noun: a place where people can play | |
| import UIKit | |
| enum SubtitleType { | |
| case SubRip, SubStationAlpha, LRC, SAMI, YouTube, SubViewer, MicroDVD, WebVTT, TTML, Unknown | |
| func description() -> String { | |
| switch self { | |
| case .SubRip: |
| // Numerical matrix examples | |
| let x: Matrix = [[10, 9, 8], [3, 2, 1]] | |
| let y: Matrix = [[1, 2, 3], [4, 5, 6]] | |
| let z: Matrix = [[1, 2], [3, 4], [5, 6]] | |
| x + y // [[11, 11, 11], [7, 7, 7]] | |
| x * y // [[10, 18, 24], [12, 10, 6]] | |
| 2 * x // [[20, 18, 16], [6, 4, 2]] | |
| y ** z // [[22, 28], [49, 64]] |
| import Foundation | |
| extension Dictionary { | |
| mutating public func setValue(val: AnyObject, forKeyPath keyPath: String) { | |
| var keys = keyPath.componentsSeparatedByString(".") | |
| guard let first = keys.first as? Key else { print("Unable to use string as key on type: \(Key.self)"); return } | |
| keys.removeAtIndex(0) | |
| if keys.isEmpty, let settable = val as? Value { | |
| self[first] = settable | |
| } else { |
| import UIKit | |
| import ResearchKit | |
| class DemoView: UIView { | |
| } | |
| class DemoStepViewController : ORKActiveStepViewController { |
| import Foundation | |
| import SystemConfiguration.CaptiveNetwork | |
| func getWiFiSsid() -> String? { | |
| var ssid: String? | |
| if let interfaces = CNCopySupportedInterfaces() as NSArray? { | |
| for interface in interfaces { | |
| if let interfaceInfo = CNCopyCurrentNetworkInfo(interface as! CFString) as NSDictionary? { | |
| ssid = interfaceInfo[kCNNetworkInfoKeySSID as String] as? String | |
| break |