rbenv install -l
rbenv install 2.6.5
rbenv local 2.6.5
gem install bundler
bundle install
This file contains hidden or 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 | |
extension UIImageView { | |
func downloadImage(from url: URL) { | |
URLSession.shared.dataTask(with: url) { data, response, error in | |
guard | |
let httpURLResponse = response as? HTTPURLResponse, httpURLResponse.statusCode == 200, | |
let mimeType = response?.mimeType, mimeType.hasPrefix("image"), | |
let data = data, error == nil, |
This file contains hidden or 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
// Based on https://code.tutsplus.com/articles/securing-communications-on-ios--cms-28529 | |
import Foundation | |
import Security | |
struct Certificate { | |
let certificate: SecCertificate | |
let data: Data | |
} | |
extension Certificate { |
This file contains hidden or 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 | |
struct MockDataConstants { | |
// MARK: - Image files | |
static let imageUrls: [String] = [ | |
"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/BigBuckBunny.jpg", | |
"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/ElephantsDream.jpg", | |
"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/ForBiggerBlazes.jpg", | |
"http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/images/ForBiggerEscapes.jpg", |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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) | |