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 XCTest | |
import StoreKitTest | |
@available(iOS 14.0, *) | |
class SubscriptionTests: XCTestCase { | |
private var session: SKTestSession! | |
private var subscriptionsController: SubscriptionsController! | |
override func setUpWithError() throws { |
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
pushd ${ANDROID_HOME}/emulator | |
./emulator -list-avds | cat -n | |
printf "Select AVD: " | |
read index | |
avd=$(./emulator -list-avds | sed "${index}q;d") | |
echo "Selected $avd" | |
./emulator -netdelay none -netspeed full -avd $avd | |
popd |
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 gradient = CAGradientLayer() | |
gradient.frame = tableView.superview?.bounds ?? CGRectNull | |
gradient.colors = [UIColor.clearColor().CGColor, UIColor.clearColor().CGColor, UIColor.blackColor().CGColor, UIColor.blackColor().CGColor, UIColor.clearColor().CGColor, UIColor.clearColor().CGColor] | |
gradient.locations = [0.0, 0.15, 0.25, 0.75, 0.85, 1.0] | |
tableView.superview?.layer.mask = gradient | |
tableView.backgroundColor = UIColor.clearColor() |
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
simulatorsIdentifiers=$(instruments -s devices | | |
grep -o "iPhone .* (.*) \[.*\]" | #only iPhone | |
grep -o "\[.*\]" | #only UUID | |
sed "s/^\[\(.*\)\]$/\1/" | #remove square brackets | |
sed 's/^/"/;$!s/$/"/;$s/$/"/' | #add quotes | |
sed '$!s/$/,/' #add comma to separate each element | |
) | |
arrayOfSimulatorsIdentifiers=($(echo "$simulatorsIdentifiers" | tr ',' '\n')) |
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
// Author: SwiftUI-Lab (swiftui-lab.com) | |
// Description: this learning tool is designed to showcase the different | |
// Grid and GridRow view options, added in SwiftUI 2022. It is part of the | |
// blog article: https://swiftui-lab.com/eager-grids | |
// | |
import SwiftUI | |
import UniformTypeIdentifiers | |
// The root view of the application | |
struct ContentView: View { |
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
data class DownloadItem(val bytesDownloadedSoFar: Long = -1, val totalSizeBytes: Long = -1, val status: Int) | |
class DownloadProgressLiveData(private val application: Application, private val requestId: Long) : LiveData<DownloadItem>(), CoroutineScope { | |
private val downloadManager by lazy { | |
application.getSystemService(Context.DOWNLOAD_SERVICE) as DownloadManager | |
} | |
private val job = Job() |
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
class LeakCheckTestCase: XCTestCase { | |
private var excludedProperties = [String: Any]() | |
private var weakReferences = NSMapTable<NSString, AnyObject>.weakToWeakObjects() | |
// MARK: - SetUp | |
override func setUpWithError() throws { | |
try super.setUpWithError() |
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
class ViewController: UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
// by calling [NSURLProtocol registerClass:[MyURLProtocol class]]; in -application:didFinishLoadingWithOptions:, your protocol will have priority over any of the built-in protocols. | |
URLProtocol.registerClass(ActivityURLProtocol.self) | |
//URLProtocol.unregisterClass(ActivityURLProtocol.self) | |
print(URLSession.shared.configuration.protocolClasses) | |
} |
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 PHPhotoLibrary { | |
typealias PhotoAsset = PHAsset | |
typealias PhotoAlbum = PHAssetCollection | |
static func saveImage(image: UIImage, albumName: String, completion: (PHAsset?)->()) { | |
if let album = self.findAlbum(albumName) { | |
saveImage(image, album: album, completion: completion) | |
return | |
} |
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
public abstract class BaseViewBindingFragment extends Fragment { | |
private Field bindingField; | |
private Method inflate; | |
{ | |
try { | |
for (Field declaredField : this.getClass().getDeclaredFields()) { | |
if (ViewBinding.class.isAssignableFrom(declaredField.getType())) { | |
bindingField = declaredField; |
NewerOlder