Skip to content

Instantly share code, notes, and snippets.

View Blackjacx's full-sized avatar
👨‍💻
Coding

Stefan Herold Blackjacx

👨‍💻
Coding
View GitHub Profile
@Blackjacx
Blackjacx / AsyncStreamNonConcurrentDemo.swift
Last active June 17, 2024 15:47
AsyncStream Non-Concurrent Demo
import UIKit
/// This object should contain everything we need to process async,
/// non-concurrent stream updates.
struct Update {
var id: Int
var finishStream: () -> Void
}
final class UpdateMonitor {
@Blackjacx
Blackjacx / tuist-pros-cons.md
Created September 27, 2023 08:27
Tuist Pro/Con

PRO

  • Tuist own explanation of its advantages
  • Tuist is developed in Swift (no additional dependencies needed for installation)
  • Fast bug fixes since Tuist is open source and developed in a community driven way
  • Developers can write configuration files in Swift ❤️
  • Code for setting up multiple projects can be shared using Project-Description-Helpers
  • Project configuration and build settings can be documented
  • External dependencies can be integrated in an easy way. Carthage and SPM are supported too.
  • The workspace and project file can be removed from git which leads to a high reduction of merge conflicts and a smoother development process.
  • Supports the creation of release pipelines for GitHub Actions and Bitrise.
@Blackjacx
Blackjacx / Swift-Override-In-Extension.swift
Created April 5, 2023 14:57
Swift Override In Extension
extension GMSMapView {
override open func traitCollectionDidChange(_ previousTraitCollection: UITraitCollection?) {
super.traitCollectionDidChange(previousTraitCollection)
guard traitCollection.hasDifferentColorAppearance(comparedTo: previousTraitCollection) else {
return
}
updateMapStyle()
}
}
@Blackjacx
Blackjacx / iOS-Parallax-Effect.swift
Created March 31, 2022 08:37
iOS Parallax Effect as UIView Extension
extension UIView {
func applyParallax() {
let amount = 10
let horizontal = UIInterpolatingMotionEffect(keyPath: "center.x", type: .tiltAlongHorizontalAxis)
horizontal.minimumRelativeValue = -amount
horizontal.maximumRelativeValue = amount
let vertical = UIInterpolatingMotionEffect(keyPath: "center.y", type: .tiltAlongVerticalAxis)
@Blackjacx
Blackjacx / projects.md
Last active February 11, 2021 02:22
Projects

Projects

I am the maintainer of the following open source software:

Information

  • WWDC Bullet-point summaries for the most popular WWDC session videos

Apps

  • Emojis My SwiftUI playground
@Blackjacx
Blackjacx / XCUIElement+ClearAndEnterText.swift
Created February 12, 2018 13:55
XCUIElement+ClearAndEnterText
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 {
self.typeText(text)
}
@Blackjacx
Blackjacx / pdfify_scanned_documents.sh
Last active May 20, 2017 14:09
Converts all tifs in the current directory to black and white and merges them into a single pdf
#/bin/bash
EXT="tif"
# use xargs to trim whitespaces
COUNT=`ls -1 *.$EXT 2>/dev/null | wc -l | xargs`
THRESHOLD="50%"
# check if there are files of the specified extension
if [ $COUNT != 0 ]
then
echo "Converting $COUNT $EXT's to black and white and merge them to one PDF..."
@Blackjacx
Blackjacx / UITextField-Replace-TextTheRightWay.swift
Last active December 28, 2023 17:18
UITextField - Replace Text The Right Way
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
Blackjacx / UIView+AddingSubviews.swift
Created November 29, 2016 14:28
[iOS] Adding a subview maximized with insets
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: insets.top),
subview.bottomAnchor.constraintEqualToAnchor(bottomAnchor, constant: -insets.bottom),
]
subview.translatesAutoresizingMaskIntoConstraints = false