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
let view = UIView().with {$0.backgroundColor = .red}.with({$0.alpha = 0.3}) | |
extension UIView { | |
func with(_ process: (UIView) -> ()) -> UIView { | |
process(self) | |
return self | |
} | |
} |
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
class SuperViewController: UIViewController { | |
typealias VoidClosure = () -> Void | |
private var onViewDidLoad: [VoidClosure] = [] | |
// public | |
func addOnViewdidLoad(block: @escaping VoidClosure) { | |
if isViewLoaded { | |
block() | |
} else { | |
self.onViewDidLoad.append(block) |
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
struct DictionaryToArrayTransform<T: Mappable>: TransformType { | |
init() {} | |
func transformFromJSON(_ value: Any?) -> [T]? { | |
guard let object = value as? [String: Any] else { | |
return nil | |
} | |
if let mapped = T(JSON: object) { | |
return [mapped] | |
} else { | |
return [] |
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
// | |
// DetectBlur.swift | |
// | |
// Created by Moath_Othman on 2/9/16. | |
// | |
import Foundation | |
//inpired by https://gist.github.com/mortenbekditlevsen/5a0ee16b73a084ba404d | |
extension UIDevice { | |
public func MO_isBlurAvailable() -> Bool { |
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
/** Find the Y point of a view related to the main screen | |
@pramater UIView the view to start | |
@return CGFloat the y point to the main screen | |
*/ | |
func findOutTheYPointToTheScreen(view: UIView) -> CGFloat { | |
var ypointSummation: CGFloat = view.frame.origin.y | |
var tView = view | |
while let v = tView.superview { | |
ypointSummation += v.frame.origin.y |
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
Snippet From Apple sample Code | |
UIImage *backButtonBackgroundImage = [UIImage imageNamed:@"back"]; | |
// The background should be pinned to the left and not stretch. | |
float margin = 12.0; | |
backButtonBackgroundImage = [backButtonBackgroundImage resizableImageWithCapInsets:UIEdgeInsetsMake(0, backButtonBackgroundImage.size.width - margin, 0, 0)]; | |
id appearance = [UIBarButtonItem appearanceWhenContainedIn:[ | |
CustomBackButtonNavController class], 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
Collection View Cell Size | |
Snippet for sizing the collectionViewCell depending on the screen size | |
Given its original designed for 4.7" inches | |
-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath{ | |
return CGSizeMake(<#currentWidthfor4.7inches#> *self.view.bounds.size.height/667.0, <#height#>*self.view.bounds.size.width/375.0); | |
} |
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
find . -type f | xargs wc -l | |
For specific file extension | |
find . -name '*.m' | xargs wc -l |
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
git rev-list HEAD --count |
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
fuser -v 8080/tcp -- give you list of pids using that port and that protocol | |
kill -s 15 pid -- kill //the process 15 could be 9 as well | |
or fuser -f ** not sure | |
- ps -aux |grep node | |
Close an application on some port on MAC | |
lsof | grep tcp | |
kill -9 ppid |
NewerOlder