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
#!/bin/bash | |
modelNumber=$(/usr/sbin/ioreg -l | awk '/product-name/ { split($0, line, "\""); printf("%s\n", line[4]); }') | |
now=`date +%d-%m-%Y_%H-%M` | |
destinationFolder="Xcode($now)-$modelNumber" | |
target="/Users/<yourUser>/Library/Developer/Xcode/UserData" | |
destination="<where to place>/$destinationFolder" | |
userDataFolderName="UserData" | |
libraryPreferencesTarget="/Users/<yourUser>/Library/Preferences" |
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
extension Optional where Wrapped: Collection, Wrapped.Element: Hashable { | |
func transformToSet() -> Set<Wrapped.Element>? { | |
if let self = self { | |
return Set(self) | |
} else { | |
return nil | |
} | |
} | |
} |
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
extension CLLocationCoordinate2D: Equatable { | |
public static func == (lhs: CLLocationCoordinate2D, rhs: CLLocationCoordinate2D) -> Bool { | |
let numbersAfterCommaAccuracy: Double = 4 | |
let ratio = numbersAfterCommaAccuracy * 10 | |
let isLatitudeEqual = ((lhs.latitude - rhs.latitude) * ratio).rounded(.down) == 0 | |
let isLongitudeEqual = ((lhs.latitude - rhs.latitude) * ratio).rounded(.down) == 0 | |
return isLatitudeEqual && isLongitudeEqual | |
} | |
} |
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
extension UIImage { | |
class func image(color: UIColor, size: CGSize = CGSize(width: 1, height: 1)) -> UIImage { | |
return UIGraphicsImageRenderer(size: size).image { rendererContext in | |
color.setFill() | |
rendererContext.fill(CGRect(origin: .zero, size: size)) | |
} | |
} | |
} |
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
// | |
// ClockView.h | |
// | |
#import <UIKit/UIKit.h> | |
@interface ClockView : UIControl { | |
NSTimer *updateTimer_; | |
CAShapeLayer *hourHand_; |
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
@interface KeyboardTextField() | |
@end | |
@implementation KeyboardTextField | |
- (void)viewDidLoad | |
{ | |
[super viewDidLoad]; | |
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardDidShowNotification object:nil]; |
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
// | |
// NibInitializableView.swift | |
// nik-kov.com | |
// | |
// Created by Nik Kov on 16.11.17. | |
// Copyright © 2017 Nik Kov. All rights reserved. | |
// | |
/// Just subclass it | |
@IBDesignable |
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
// | |
// NibInstantiableView.h | |
// nik-kov.com | |
// | |
// Created by Nik Kov on 23.03.2018. | |
// Copyright © 2018 Apple. All rights reserved. | |
// | |
#import <UIKit/UIKit.h> |
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
// Use | |
if indexPath.row < arrayOfObjects.count { | |
cell.label.text = arrayOfObjects[indexPath.row] | |
} else { | |
// Handle non-existing object here | |
} | |
// Example: | |
if let wheel = wheel, let row = indexPath?.row, row < wheel.comments.count { | |
let comment = wheel.comments[row] |