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
void main() async { | |
print(await foo().catchError((_) => false)); | |
} | |
Future<bool> foo() async { | |
throw Error(); | |
// return Future.value(true); | |
} |
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/Foundation.h> | |
NS_ASSUME_NONNULL_BEGIN | |
typedef NSComparisonResult (^ABOrderedKeyArrayComparator)(id _Nonnull obj1, | |
id _Nonnull obj2); | |
@interface ABOrderedKeyArray<__covariant KeyType, __covariant ObjectType> | |
: NSObject <NSFastEnumeration> |
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 ArchiverContainer<T: Codable>: NSObject, NSCoding { | |
enum ArchiverContainerError: Error { | |
case failedDecoding | |
} | |
let info: T | |
init(info: T) { | |
self.info = info | |
} | |
required init?(coder: NSCoder) { |
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 ProfileAppDelegate: UIResponder, UIApplicationDelegate { | |
func application(_ application: UIApplication, | |
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { | |
for i in 100...100000000 { | |
let side = i | |
let size = CGSize(width: side, height: side) | |
print("size: \(side)x\(side) => \(ImageStitcher.bytes(for: size))") | |
} |
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
private func activeArea(pixelBuffer: CVPixelBuffer) -> CGRect { | |
let width = CVPixelBufferGetWidth(pixelBuffer) | |
let height = CVPixelBufferGetHeight(pixelBuffer) | |
let verticalInset = Double(height) * self.activeInsetProcent | |
let horizontalInset = Double(width) * self.activeInsetProcent | |
return CGRect(x: horizontalInset, | |
y: verticalInset, | |
width: Double(width) - 2*horizontalInset, | |
height: Double(height) - 2*verticalInset) | |
} |
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 framesPerSecond = min(self.nominalFrameRate, self.framesPerSecond) | |
let processedFrameIdx = Int64(self.nominalFrameRate / framesPerSecond) | |
guard self.frameCounter.value % processedFrameIdx == 0 else { | |
sample = self.assetReader?.outputs.first?.copyNextSampleBuffer() | |
continue | |
} | |
usleep(UInt32(1000 * Int(1000.0 * 1.0 / framesPerSecond) * self.framesRate)) |
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
still 00:00:00 00:00:10 | |
right 00:00:10 00:00:13 | |
up 00:00:13 00:00:15 | |
still 00:00:15 00:00:19 | |
right 00:00:19 00:00:20 | |
left 00:00:20 00:00:24 | |
right 00:00:24 00:00:26 | |
down 00:00:26 00:00:27 | |
right 00:00:27 00:00:28 | |
right 00:00:28 00:00: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
extension Array where Element: UIImage { | |
func stitchImages(isVertical: Bool) -> UIImage { | |
let maxWidth = self.compactMap { $0.size.width }.max() | |
let maxHeight = self.compactMap { $0.size.height }.max() | |
let maxSize = CGSize(width: maxWidth ?? 0, height: maxHeight ?? 0) | |
let totalSize = isVertical ? | |
CGSize(width: maxSize.width, height: maxSize.height * (CGFloat)(self.count)) | |
: CGSize(width: maxSize.width * (CGFloat)(self.count), height: maxSize.height) |
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
{ | |
varitaion: "words" | |
} |
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
#!/usr/bin/env python3 | |
import os | |
match_keyword ="<some stuff here to find>" | |
import_line = "<some stuff needed to be imported>" | |
def find_first_line_match_idx(lines, match_str): | |
lastmatchIdx = None | |
idx = 0 |
NewerOlder