Author: Chris Lattner
The only way I've succeeded so far is to employ SSH.
Assuming you are new to this like me, first I'd like to share with you that your Mac has a SSH config file in a .ssh directory. The config file is where you draw relations of your SSH keys to each GitHub (or Bitbucket) account, and all your SSH keys generated are saved into .ssh directory by default. You can navigate to it by running cd ~/.ssh within your terminal, open the config file with any editor, and it should look something like this:
Host * AddKeysToAgent yes
> UseKeyChain yes
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
| # PR is a work in progress and shouldn't be merged yet | |
| warn "PR is classed as Work in Progress" if github.pr_title.include? "[WIP]" | |
| # Warn when there is a big PR | |
| warn "Big PR, consider splitting into smaller" if git.lines_of_code > 500 | |
| # Ensure a clean commits history | |
| if git.commits.any? { |c| c.message =~ /^Merge branch '#{github.branch_for_base}'/ } | |
| fail "Please rebase to get rid of the merge commits in this PR" | |
| end |
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
| disabled_rules: # rule identifiers to exclude from running | |
| - variable_name | |
| - nesting | |
| - function_parameter_count | |
| opt_in_rules: # some rules are only opt-in | |
| - control_statement | |
| - empty_count | |
| - trailing_newline | |
| - colon | |
| - comma |
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 CGRect | |
| { | |
| /** Creates a rectangle with the given center and dimensions | |
| - parameter center: The center of the new rectangle | |
| - parameter size: The dimensions of the new rectangle | |
| */ | |
| init(center: CGPoint, size: CGSize) | |
| { | |
| self.init(x: center.x - size.width / 2, y: center.y - size.height / 2, width: size.width, height: size.height) |
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 RxSwift // Version 3.2.0 | |
| import RxCocoa // Version 3.2.0 | |
| func keyboardHeight() -> Observable<CGFloat> { | |
| return Observable | |
| .from([ | |
| NotificationCenter.default.rx.notification(NSNotification.Name.UIKeyboardWillShow) | |
| .map { notification -> CGFloat in | |
| (notification.userInfo?[UIKeyboardFrameBeginUserInfoKey] as? NSValue)?.cgRectValue.height ?? 0 | |
| }, |
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
| //reference types | |
| class someClass { | |
| var name: String | |
| init(name: String) { | |
| self.name = name | |
| } | |
| } | |
| var aClass = someClass(name: "James") | |
| var bClass = aClass |
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 UIKit | |
| extension UITableView { | |
| func dequeueReusableCell<T: UITableViewCell>() -> T { | |
| return dequeueReusableCell(withIdentifier: NSStringFromClass(T.self)) as! T | |
| } | |
| } | |
| //using: let cell: ExampleTableViewCell = tableView.dequeueReusableCell() |
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
| # The trick is to link the DeviceSupport folder from the beta to the stable version. | |
| # sudo needed if you run the Mac App Store version. Always download the dmg instead... you'll thank me later :) | |
| # Support iOS 15 devices (Xcode 13.0) with Xcode 12.5: | |
| sudo ln -s /Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport/15.0 /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/DeviceSupport | |
| # Then restart Xcode and reconnect your devices. You will need to do that for every beta of future iOS versions | |
| # (A similar approach works for older versions too, just change the version number after DeviceSupport) |
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 UIKit | |
| // Swift rewrite challenge | |
| // Starting point: https://gist.github.com/jkereako/200342b66b5416fd715a#file-scale-and-crop-image-swift | |
| func scaleAndCropImage( | |
| image: UIImage, | |
| toSize size: CGSize, | |
| fitImage: Bool = true | |
| ) -> UIImage { |