Skip to content

Instantly share code, notes, and snippets.

Avatar
🍏

Michel Storms stormychel

🍏
View GitHub Profile
@stormychel
stormychel / create-folder.py
Created May 7, 2021 — forked from keithweaver/create-folder.py
Create a folder with Python
View create-folder.py
import os
def createFolder(directory):
try:
if not os.path.exists(directory):
os.makedirs(directory)
except OSError:
print ('Error: Creating directory. ' + directory)
@stormychel
stormychel / gist:e6683e6b6c35e88cea6534c755be65d1
Created Nov 20, 2022
CoreData: NSManagedObject extension that prints all data to console. Usage: nsManagedObjectName.printContent()
View gist:e6683e6b6c35e88cea6534c755be65d1
extension NSManagedObject {
/// Print content of object to console.
func printContent() {
print("\nNSManagedObjectID: \(self.objectID) - key/value dump:")
for key in self.entity.attributesByName.keys {
print("\(key): \(self.value(forKey: key) ?? "nil")")
}
print("\n")
}
}
@stormychel
stormychel / PreviousViewController.swift
Created Nov 27, 2022 — forked from susieyy/PreviousViewController.swift
Access previous view controller in navigation stack
View PreviousViewController.swift
extension UIViewController {
var previousViewController: UIViewController? {
guard let navigationController = navigationController else { return nil }
let count = navigationController.viewControllers.count
return count < 2 ? nil : navigationController.viewControllers[count - 2]
}
}