Skip to content

Instantly share code, notes, and snippets.

💭
🏄

Marco Pappalardo racer1988

💭
🏄
  • Italy
Block or report user

Report or block racer1988

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@racer1988
racer1988 / SafeArea.swift
Created Feb 16, 2018
A way to access the bottom anchor in every iOS version
View SafeArea.swift
extension UIView {
var safeTopAnchor: NSLayoutYAxisAnchor {
if #available(iOS 11.0, *) {
return self.safeAreaLayoutGuide.topAnchor
} else {
return self.topAnchor
}
}
var safeLeftAnchor: NSLayoutXAxisAnchor {
@racer1988
racer1988 / CoreDataManager.swift
Created Feb 9, 2018
A CoreData wrapper using iOS 10 stack
View CoreDataManager.swift
//
// CoreDataManager.swift
//
// Created by Marco Pappalardo
//
import CoreData
/// Core Data Stack
///
@racer1988
racer1988 / setup.swift
Created Nov 17, 2015
Setup for testing iOS View controllers
View setup.swift
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
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() {}
}
@racer1988
racer1988 / getDisplayedViewController.swift
Created Oct 20, 2015
Swift Get Displayed View Controller
View getDisplayedViewController.swift
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)
@racer1988
racer1988 / style_test.py
Last active Dec 30, 2015
pep8 Python Test (with nosetests) printing list of files checked
View style_test.py
import pep8
import unittest
from glob import glob
class TestCodeFormat(unittest.TestCase):
def test_pep8_conformance(self):
files = glob('*.py') + glob('test/*.py')
@racer1988
racer1988 / Sudden_Motion_Sensor_Test
Created Nov 15, 2013
Simple Script to test and output if the Hard Drive Sudden Motion Sensor (Macintosh) is activated or not. (In order to disable it with a SSD)
View Sudden_Motion_Sensor_Test
#!/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
You can’t perform that action at this time.