View SafeArea.swift
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 UIView { | |
var safeTopAnchor: NSLayoutYAxisAnchor { | |
if #available(iOS 11.0, *) { | |
return self.safeAreaLayoutGuide.topAnchor | |
} else { | |
return self.topAnchor | |
} | |
} | |
var safeLeftAnchor: NSLayoutXAxisAnchor { |
View CoreDataManager.swift
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
// | |
// CoreDataManager.swift | |
// | |
// Created by Marco Pappalardo | |
// | |
import CoreData | |
/// Core Data Stack | |
/// |
View setup.swift
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
override func setUp() { | |
super.setUp() | |
let storyboard = UIStoryboard(name: Storyboard.StoryBoardName, bundle: NSBundle.mainBundle()) | |
let navigationController = storyboard.instantiateViewControllerWithIdentifier(Storyboard.NVCID) as! UINavigationController | |
viewController = navigationController.topViewController as! TheControllerToTest | |
viewController.coreDataManager = CoreDataManagerMock() |
View Singleton.swift
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
private let sharedInstance = Something() | |
public class Something { | |
// http://krakendev.io/blog/the-right-way-to-write-a-singleton | |
// This returns the singleton | |
class let sharedInstance = Something() | |
// This avoid people to create Something() | |
private init() {} | |
} |
View getDisplayedViewController.swift
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
func getDisplayedViewController(controller: UIViewController? = UIApplication.sharedApplication().keyWindow?.rootViewController) -> UIViewController? { | |
if let navigationController = controller as? UINavigationController { | |
return getDisplayedViewController(navigationController.visibleViewController) | |
} | |
if let tabBarController = controller as? UITabBarController { | |
if let selectedTab = tabBarController.selectedViewController { | |
return getDisplayedViewController(selectedTab) |
View style_test.py
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
import pep8 | |
import unittest | |
from glob import glob | |
class TestCodeFormat(unittest.TestCase): | |
def test_pep8_conformance(self): | |
files = glob('*.py') + glob('test/*.py') |
View Sudden_Motion_Sensor_Test
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 | |
SMSTEST=`pmset -g | grep sms | awk '{print $2}'` | |
if [ "$SMSTEST" != 0 ] | |
then | |
echo -e "WARNING: Sudden Motion Sensor is ON" | |
else | |
echo -e "Sms Ok" | |
fi |