Skip to content

Instantly share code, notes, and snippets.

View clapslock's full-sized avatar

Bartosz Kunat clapslock

View GitHub Profile
@clapslock
clapslock / format-string.py
Created January 8, 2018 08:47
Simple Python 3 function that removes all special characters and spaces from the string passed as an argument
def removeSpacesAndSpecialChars(inputText):
whitelist = set('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
answer = ''.join(filter(whitelist.__contains__, inputText))
answer = answer.lower()
return answer
@clapslock
clapslock / GetRootVC.swift
Created July 4, 2019 07:45
Swift- get nearest ViewController in the view hierarchy
private func getRootViewController() -> UIViewController? {
var rootViewController = UIApplication.shared.keyWindow?.rootViewController
if let navigationController = rootViewController as? UINavigationController {
rootViewController = navigationController.viewControllers.first
}
if let tabBarController = rootViewController as? UITabBarController {
rootViewController = tabBarController.selectedViewController
}
return rootViewController
}