In Git you can add a submodule to a repository. This is basically a repository embedded in your main repository. This can be very useful. A couple of usecases of submodules:
- Separate big codebases into multiple repositories.
$ git status | |
5 commits pending | |
$ git reset --soft HEAD~5 # where 5 is the number of commits you saw in the `git status` | |
$ git stash |
Alamofire.request(urlString).responseJSON { response in | |
guard case let .failure(error) = response.result else { return } | |
if let error = error as? AFError { | |
switch error { | |
case .invalidURL(let url): | |
print("Invalid URL: \(url) - \(error.localizedDescription)") | |
case .parameterEncodingFailed(let reason): | |
print("Parameter encoding failed: \(error.localizedDescription)") | |
print("Failure Reason: \(reason)") |
// MARK: - Adding a header to a single request | |
func doRequestWithHeaders1() { | |
let headers: HTTPHeaders = [ | |
"X-Mashape-Key": MY_API_KEY, | |
"Accept": "application/json" | |
] | |
Alamofire.request("https://mashape-community-urban-dictionary.p.mashape.com/define?term=smh", headers: headers) | |
.responseJSON { response in | |
debugPrint(response) |
// NSCalendar+Swift.swift | |
// A set of Swift-idiomatic methods for NSCalendar | |
// | |
// (c) 2015 Nate Cook, licensed under the MIT license | |
extension NSCalendar { | |
/// Returns the hour, minute, second, and nanoseconds of a given date. | |
func getTimeFromDate(date: NSDate) -> (hour: Int, minute: Int, second: Int, nanosecond: Int) { | |
var (hour, minute, second, nanosecond) = (0, 0, 0, 0) | |
getHour(&hour, minute: &minute, second: &second, nanosecond: &nanosecond, fromDate: date) |
extension UIViewController { | |
func topMostViewController() -> UIViewController { | |
if self.presentedViewController == nil { | |
return self | |
} | |
if let navigation = self.presentedViewController as? UINavigationController { | |
return navigation.visibleViewController.topMostViewController() | |
} | |
if let tab = self.presentedViewController as? UITabBarController { | |
if let selectedTab = tab.selectedViewController { |
func generateRandomColor() -> UIColor { | |
let hue : CGFloat = CGFloat(arc4random() % 256) / 256 // use 256 to get full range from 0.0 to 1.0 | |
let saturation : CGFloat = CGFloat(arc4random() % 128) / 256 + 0.5 // from 0.5 to 1.0 to stay away from white | |
let brightness : CGFloat = CGFloat(arc4random() % 128) / 256 + 0.5 // from 0.5 to 1.0 to stay away from black | |
return UIColor(hue: hue, saturation: saturation, brightness: brightness, alpha: 1) | |
} |
1. Create a folder called Payload | |
2. Place the .app folder inside of that | |
3. Zip up the Payload folder using normal compression | |
4. Then rename the file with a .ipa extension |
Generate the list yourself:
$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./* | \
sed 's/NS_AVAILABLE_IOS(.*)//g' | \
sed 's/NS_DEPRECATED_IOS(.*)//g' | \
sed 's/API_AVAILABLE(.*)//g' | \
sed 's/API_UNAVAILABLE(.*)//g' | \
sed 's/UI_APPEARANCE_SELECTOR//g' | \