Skip to content

Instantly share code, notes, and snippets.


Stefan Herold Blackjacx

Block or report user

Report or block Blackjacx

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
View XCUIElement+ClearAndEnterText.swift
extension XCUIElement {
Removes any current text in the field before typing in the new value
- Parameter text: the text to enter into the field
func clearAndEnterText(text: String) {
defer {
Blackjacx /
Last active May 20, 2017
Converts all tifs in the current directory to black and white and merges them into a single pdf
# use xargs to trim whitespaces
COUNT=`ls -1 *.$EXT 2>/dev/null | wc -l | xargs`
# check if there are files of the specified extension
if [ $COUNT != 0 ]
echo "Converting $COUNT $EXT's to black and white and merge them to one PDF..."
Blackjacx / UITextField_Replace_Text_The_Right_Way.swift
Created Apr 11, 2017
UITextField - Replace Text The Right Way
View UITextField_Replace_Text_The_Right_Way.swift
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
let strippedString = <change replacements string so it fits your requirement - strip, trim, etc>
// replace current content with stripped content
if let replaceStart = textField.position(from: textField.beginningOfDocument, offset: range.location),
let replaceEnd = textField.position(from: replaceStart, offset: range.length),
let textRange = textField.textRange(from: replaceStart, to: replaceEnd) {
textField.replace(textRange, withText: strippedString)
Blackjacx / UIView+AddingSubviews.swift
Created Nov 29, 2016
[iOS] Adding a subview maximized with insets
View UIView+AddingSubviews.swift
func addSubviewMaximized(subview: UIView, insets: UIEdgeInsets? = nil) {
let insets = insets ?? UIEdgeInsetsZero
let constraints: [NSLayoutConstraint] = [
subview.leftAnchor.constraintEqualToAnchor(leftAnchor, constant: insets.left),
subview.leftAnchor.constraintEqualToAnchor(leftAnchor, constant: -insets.right),
subview.topAnchor.constraintEqualToAnchor(topAnchor, constant:,
subview.bottomAnchor.constraintEqualToAnchor(bottomAnchor, constant: -insets.bottom),
subview.translatesAutoresizingMaskIntoConstraints = false
View deviceAndVersionSpecificInformationAsString.swift
static func deviceAndVersionSpecificInformationAsString(userID: String?) -> String {
let processInfo = NSProcessInfo()
let byteCountFormatter = NSByteCountFormatter()
var data = Array<String>()
var systemComponents = Array<String>()
byteCountFormatter.countStyle = .Memory
byteCountFormatter.allowsNonnumericFormatting = false
Blackjacx /
Last active Jul 9, 2016
WWDC 2016 Ressource ( HD-, SD-Video, PDF ) Download Script
# Bash script for downloading WWDC video and pdf ressources
# You can choose the year you're interested in by altering the variable YEAR (works only for 2014 until today).
# Please install wget prior running this script since this tool is used to download the pdf's and videos. I use it
# since it is able to prevent re-downloading already existing content. So you can just run this script again and
# again and it will just download new content. This is really useful in the week of the WWDC since videos are
View NibLoadableView.swift
import UIKit
class NibLoadableView: UIView {
@IBOutlet var view: UIView!
override init(frame: CGRect) {
super.init(frame: frame)
Blackjacx / gist:19351019cf5d76ffc718
Created Oct 12, 2015
View gist:19351019cf5d76ffc718
[CATransaction begin];
[CATransaction setCompletionBlock: ^{
// Do the animated table view stuff
[CATransaction commit];
Blackjacx /
Created Oct 2, 2015
App Icon Annotation (version, build number, etc)
# check if tools installed
if ! type "composite" > /dev/null; then
exit 0
buildNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "${PROJECT_DIR}/${INFOPLIST_FILE}")
versionNumber=$(/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${PROJECT_DIR}/${INFOPLIST_FILE}")
Blackjacx / Different_Ways_of_statusbarHeight.m
Last active Aug 29, 2015
Different Ways of statusbarHeight
View Different_Ways_of_statusbarHeight.m
CGFloat statusBarHeight = CGRectGetMaxY([self.view.window convertRect:UIApplication.sharedApplication.statusBarFrame toView:self.view]);
#define kStatusBarHeight [self.window convertRect:UIApplication.sharedApplication.statusBarFrame toView:self].size.height
- (CGFloat)AT_statusBarHeight
CGFloat statusBarHeight = 0.f;
You can’t perform that action at this time.