Skip to content

Instantly share code, notes, and snippets.

@ozgur
ozgur / git_rebase.md
Created August 13, 2020 14:23 — forked from ravibhure/git_rebase.md
Git rebase from remote fork repo

In your local clone of your forked repository, you can add the original GitHub repository as a "remote". ("Remotes" are like nicknames for the URLs of repositories - origin is one, for example.) Then you can fetch all the branches from that upstream repository, and rebase your work to continue working on the upstream version. In terms of commands that might look like:

Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

Fetch all the branches of that remote into remote-tracking branches, such as upstream/master:

git fetch upstream

@ozgur
ozgur / NIBLoadable.swift
Last active August 8, 2017 14:46
Swift protocols returning Self
public protocol NIBLoadable {
static func fromNib() -> Self
}
extension UIViewController: NIBLoadable {
public static func fromNib() -> Self {
return self.init(nibName: NSStringFromClass(self), bundle: Bundle(for: self))
}
@ozgur
ozgur / Label.swift
Created May 19, 2017 20:17
A UILabel subclass that supports insetting the content.
import UIKit
class Label: UILabel {
var contentInset: UIEdgeInsets = .zero {
didSet {
invalidateIntrinsicContentSize()
setNeedsLayout()
}
}
@ozgur
ozgur / EnumProtocol.swift
Created May 12, 2017 06:53
Simple generic protocol definition
protocol EnumProtocol {
associatedtype T
var rawValue: T { get }
}
enum MyColor: Int, EnumProtocol {
typealias T = Int
case red = 0
@ozgur
ozgur / AlamofireObjectMapper+Rx.swift
Last active March 7, 2019 20:52
AlamofireObjectMapper+Rx.swift
//
// AlamofireObjectMapper+Rx.swift
// AlamofireObjectMapper
//
// Created by Ozgur on 28/01/2017.
// Copyright © 2017 Ozgur. All rights reserved.
//
import AlamofireObjectMapper
import Alamofire