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 struct CocoStringAttributeHolder { | |
internal let key: NSAttributedString.Key | |
internal let value: Any | |
internal let range: Range<String.Index>? | |
fileprivate init(key: NSAttributedString.Key, value: Any, range: Range<String.Index>?) { | |
self.key = key |
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 ContentView: View { | |
@State var isExpanded = false | |
@State var subviewHeight : CGFloat = 0 | |
var body: some View { | |
VStack { | |
Text("Headline") | |
VStack { | |
Text("More Info") |
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
from cv2 import resize, INTER_LINEAR | |
from multiprocessing import Pool | |
def compare(args): | |
img, img2 = args | |
img = (img - img.mean()) / img.std() | |
img2 = (img2 - img2.mean()) / img2.std() | |
return np.mean(np.abs(img - img2)) | |
class EpsilonPredictor: |
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 | |
extension UITapGestureRecognizer { | |
func didTapAttributedTextInLabel(label: UILabel, inRange targetRange: NSRange) -> Bool { | |
// Create instances of NSLayoutManager, NSTextContainer and NSTextStorage | |
let layoutManager = NSLayoutManager() | |
let textContainer = NSTextContainer(size: CGSize.zero) | |
let textStorage = NSTextStorage(attributedString: label.attributedText!) | |
// Configure layoutManager and textStorage |
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 ContentView: View { | |
@State var isExpanded = false | |
@State var subviewHeight : CGFloat = 0 | |
var body: some View { | |
VStack { | |
Text("Headline") | |
VStack { | |
Text("More Info") |
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 SceneManager { | |
var activityIdentifier: ActivityIdentifier? { | |
options | |
.userActivities | |
.compactMap { ActivityIdentifier(rawValue: $0.activityType) } | |
.first | |
} |
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 | |
#if canImport(Combine) | |
import Combine | |
@available(iOS 13.0, *) | |
final class ActionPublished: UIAction { | |
convenience init(actionSubject: InFailablePassThroughSubject<Void>?) { | |
self.init { [weak actionSubject] _ in | |
actionSubject?.send(()) |
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 Combine | |
import CoreData | |
import Foundation | |
class CDPublisher<Entity>: NSObject, NSFetchedResultsControllerDelegate, Publisher where Entity: NSManagedObject { | |
typealias Output = [Entity] | |
typealias Failure = Error | |
private let request: NSFetchRequest<Entity> | |
private let context: NSManagedObjectContext |
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 | |
infix operator ->>: DefaultPrecedence | |
public protocol Castable { | |
func forceCast<U>(to type: U.Type) -> U | |
func AS<U>(to type: U.Type) -> U? |
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
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) | |
extension Publisher where Self.Failure == Never { | |
func assign(to failablePublished: CurrentValuePublished<Self.Output,Self.Failure>) -> AnyCancellable { | |
self.assign(to: \.wrappedValue, on: failablePublished) | |
} | |
} | |
@available(macOS 10.15, iOS 13.0, tvOS 13.0, watchOS 6.0, *) |
OlderNewer