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
No personal data shared with us will be given to any third party, under any circumstances. Your data will also never be used by us for any purpose without specific permission. | |
The app engages in no ad targeting, data mining, or other activities that may compromise your privacy, and we do not affiliate ourselves with any third parties that do so. |
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 Cocoa | |
import CoreImage | |
import CoreImage.CIFilterBuiltins | |
let nextButtonImage = NSImage(named: "next button")! | |
let startGameButtonImage = NSImage(named: "start game button")! | |
computeImageDifference(inputImage: nextButtonImage, inputImage2: startGameButtonImage) | |
// MARK: - |
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 MyViewController: UIViewController { | |
var name: String = "" { | |
didSet { | |
print("name = \(name)") | |
testLabel.text = name // 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
// Put this in a UITableViewCell or UICollectionViewCell subclass. | |
// Returns nil if point is not within the specified subviews. | |
override func hitTest(_ point: CGPoint, with event: UIEvent?) -> UIView? { | |
let subviews = [imageView, titleLabel, detailLabel, downloadButton] | |
for view in subviews { | |
if view.convert(view.bounds, to: self).contains(point) { | |
return super.hitTest(point, with: event) | |
} | |
} | |
return nil |
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
let layout = UICollectionViewCompositionalLayout(sectionProvider: { | |
(sectionIndex: Int, layoutEnvironment: NSCollectionLayoutEnvironment) -> NSCollectionLayoutSection? in | |
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), | |
heightDimension: .estimated(30)) | |
let item = NSCollectionLayoutItem(layoutSize: itemSize) | |
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), | |
heightDimension: .estimated(30)) |
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
let layout = UICollectionViewCompositionalLayout(sectionProvider: { | |
(sectionIndex: Int, layoutEnvironment: NSCollectionLayoutEnvironment) -> NSCollectionLayoutSection? in | |
let itemSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(1.0), | |
heightDimension: .fractionalHeight(1.0)) | |
let item = NSCollectionLayoutItem(layoutSize: itemSize) | |
// (1) setting widthDimension to half of collectionView size | |
let groupSize = NSCollectionLayoutSize(widthDimension: .fractionalWidth(0.5), | |
heightDimension: .absolute(50)) |
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 | |
class APIClient { | |
// 1 - Error enum | |
enum APIClientError: Error { | |
case dataTaskFailed(Error) | |
case noHTTPURLResponse | |
case badHTTPStatusCode(HTTPURLResponse) | |
case noData |
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 | |
import UIKit | |
// From an example view hierarchy... | |
// 1 -> 2 -> 3 -> 4 -> 5 | |
// | | |
// ---> 6 | |
// Find the least common ancestor of 2 views. | |
// Input |
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
find /Applications -name "*.app" -user old-user -maxdepth 1 | tr \\n \\0 | xargs -0 sudo chown -R $USER |
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 | |
// Allows defining CodingKey from String | |
struct DynamicCodingKey: CodingKey { | |
var intValue: Int? | |
var stringValue: String | |
init?(intValue: Int) { | |
assertionFailure("Not implemented") | |
return nil |
NewerOlder