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
extension StringProtocol { | |
subscript(_ offset: Int) -> String.Element { | |
if offset >= 0 { | |
self[index(startIndex, offsetBy: offset)] | |
} else { | |
self[index(endIndex, offsetBy: offset)] | |
} | |
} | |
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
struct Weakify<Object: AnyObject> { | |
weak var object: Object? | |
} | |
func weak<Object: AnyObject>(_ object: Object) -> Weakify<Object> { | |
Weakify(object: object) | |
} |
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
// | |
// ViewController.swift | |
// Demo | |
// | |
// Created by Andey on 04.01.2023. | |
// | |
import Combine | |
import UIKit |
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 | |
public class ScrollableStackView: UIView { | |
// MARK: Private Properties | |
private lazy var scrollView: UIScrollView = { | |
let scrollView = UIScrollView(frame: .zero) | |
scrollView.backgroundColor = .clear | |
scrollView.translatesAutoresizingMaskIntoConstraints = false |
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
post_install do |installer| | |
installer.pods_project.build_configurations.each do |config| | |
config.build_settings["EXCLUDED_ARCHS[sdk=iphonesimulator*]"] = "arm64" | |
end | |
end |
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
# - Download Sublime https://www.sublimetext.com/ | |
# - Install Sublime (move Sublime.app to Application folder) | |
# - Allow sublime to open files from terminal | |
$ ln -s /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime | |
# - Open ./.zshrc via TextEdit | |
$ open ~/.zshrc | |
#or | |
$ touch ~/.zshrc |
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
extension Sequence { | |
public func sortedAscending<T: Comparable>(by keyPath: KeyPath<Element, T>) -> [Element] { | |
sorted(by: keyPath, comparator: <) | |
} | |
public func sortedDescending<T: Comparable>(by keyPath: KeyPath<Element, T>) -> [Element] { | |
sorted(by: keyPath, comparator: >) | |
} | |
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 weak<T: AnyObject>(_ obj: T, _ block: @escaping (T) -> () -> Void) -> () -> Void { | |
return { [weak obj] in | |
obj.map(block)?() | |
} | |
} | |
func weak<T: AnyObject, Argument>(_ obj: T, _ block: @escaping (T) -> (Argument) -> Void) -> (Argument) -> Void { | |
return { [weak obj] a in | |
obj.map(block)?(a) | |
} |
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
@dynamicMemberLookup | |
@dynamicCallable | |
class Dsl<UrlsType> { | |
private let urls: UrlsType | |
private var components: [String] = [] | |
init(urls: UrlsType) { | |
self.urls = urls | |
} |
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
on zero_pad(value, string_length) | |
set string_zeroes to "" | |
set digits_to_pad to string_length - (length of (value as string)) | |
if digits_to_pad > 0 then | |
repeat digits_to_pad times | |
set string_zeroes to string_zeroes & "0" as string | |
end repeat | |
end if | |
set padded_value to string_zeroes & value as string | |
return padded_value |
NewerOlder