rbenv install -l
rbenv install 2.6.5
rbenv local 2.6.5
gem install bundler
bundle install
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
extension AsyncSequence { | |
func forEach(_ body: (Element) async throws -> Void) async throws { | |
for try await element in self { | |
try await body(element) | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
// https://betterprogramming.pub/implement-a-multicast-delegate-design-pattern-in-swift-5-72079d695cfe | |
public class MulticastDelegate<T> { | |
// 1 | |
private class Wrapper { | |
weak var delegate: AnyObject? | |
init(_ delegate: AnyObject) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func quit() { | |
// home button pressed programmatically - to thorw app to background | |
DispatchQueue.main.async { | |
UIControl().sendAction(#selector(URLSessionTask.suspend), to: UIApplication.shared, for: nil) | |
// terminaing app in background | |
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1), execute: { | |
exit(EXIT_SUCCESS) | |
}) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class ViewController: UIViewController { | |
@IBOutlet weak var mySrchBar: UISearchBar! | |
private var lastSearchTxt = "" | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -eu | |
failed=0 | |
test_pattern='\b(fdescribe|fit|fcontext|xdescribe|xit|xcontext)\b' | |
if git diff-index -p -M --cached HEAD -- '*Tests.swift' '*Specs.swift' | grep '^+' | egrep "$test_pattern" >/dev/null 2>&1 | |
then | |
echo "COMMIT REJECTED for fdescribe/fit/fcontext/xdescribe/xit/xcontext." >&2 | |
echo "Remove focused and disabled tests before committing." >&2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
final class GradientLabel: UILabel { | |
private var colors: [UIColor] = [.supAzure, .supAppleFive] | |
private var startPoint: CGPoint = CGPoint(x: 0.0, y: 0.5) | |
private var endPoint: CGPoint = CGPoint(x: 1.0, y: 0.5) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
final class BubbleTriangleView: UIView { | |
private var viewBorderWidth: CGFloat = 3 | |
private var radius: CGFloat = 15 | |
private var viewFillColor: UIColor = .supAzure | |
private var viewBorderColor: UIColor = .white | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Source - https://medium.com/@topLayoutGuide/swift-3-so-i-wanted-to-animate-a-label-14dd2b332ef9 | |
// | |
// https://github.com/dataxpress/UICountingLabel/ | |
// | |
import UIKit | |
enum CountingMethod { | |
case easeInOut | |
case easeIn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
/// Represents a single `NSLayoutConstraint` | |
enum LayoutAnchor { | |
case constant(attribute: NSLayoutConstraint.Attribute, | |
relation: NSLayoutConstraint.Relation, | |
constant: CGFloat) | |
case relative(attribute: NSLayoutConstraint.Attribute, | |
relation: NSLayoutConstraint.Relation, |