This file contains hidden or 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 UIImage { | |
| @objc public func clipWith(_ path: UIBezierPath) -> UIImage? { | |
| let shotest = min(size.width, size.height) | |
| let outputRect = CGRect(x: 0, y: 0, width: shotest, height: shotest) | |
| UIGraphicsBeginImageContextWithOptions(outputRect.size, false, 0) | |
| defer { | |
| UIGraphicsEndImageContext() | |
| } |
This file contains hidden or 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
| BOOL PSPDFSystemFunctionOverriddenInCategory(Class theClass, SEL selector, NSString *__autoreleasing* categoryName) { | |
| NSCParameterAssert(theClass); | |
| NSCParameterAssert(selector); | |
| Dl_info info; | |
| if (dladdr(class_getMethodImplementation(theClass, selector), &info)) { | |
| // /System/Library/Frameworks is a common denominator, some methods are in /usr/lib/libobjc.A.dylib | |
| // Custom app is in /private/var/mobile/Containers/Bundle/Application/<UID>/PSPDFCatalog.app/PSPDFCatalog | |
| if (!strstr(info.dli_fname, "/System/Library") && !strstr(info.dli_fname, "/usr/lib")) { | |
| if (categoryName) *categoryName = @(info.dli_sname); |
This file contains hidden or 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
| #define PSPDF_KEYPATH(object, property) (^{ \ | |
| _Pragma("clang diagnostic push") \ | |
| _Pragma("clang diagnostic ignored \"-Wunreachable-code\"") \ | |
| _Pragma("clang diagnostic ignored \"-Wimplicit-retain-self\"") \ | |
| return ((void)(NO && ((void)object.property, NO)), @#property); \ | |
| _Pragma("clang diagnostic pop") \ | |
| }()) |
This file contains hidden or 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
| NSString *const PSPDFApplicationDidReceiveMemoryWarningNotification = @"PSPDFApplicationDidReceiveMemoryWarningNotification"; | |
| // Test with sudo memory_pressure -l critical. Don't forget to re-set afterwards! | |
| __attribute__((constructor)) static void PSPDFInstallLowMemoryNotificationWarningMac(void) { | |
| static dispatch_source_t source; | |
| static dispatch_once_t onceToken; | |
| dispatch_once(&onceToken, ^{ | |
| source = dispatch_source_create(DISPATCH_SOURCE_TYPE_MEMORYPRESSURE, 0, DISPATCH_MEMORYPRESSURE_WARN|DISPATCH_MEMORYPRESSURE_CRITICAL, dispatch_get_main_queue()); | |
| dispatch_source_set_event_handler(source, ^{ | |
| dispatch_source_memorypressure_flags_t pressureLevel = dispatch_source_get_data(source); |
This file contains hidden or 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
| // | |
| // LinkMapParser.swift | |
| // | |
| // Created by lihang on 02/02/2018. | |
| // | |
| import Foundation | |
| public typealias SortDescriptor<Value> = (Value, Value) -> Bool |
This file contains hidden or 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
| var readline = require('readline'), | |
| fs = require('fs'); | |
| var LinkMap = function(filePath) { | |
| this.files = [] | |
| this.filePath = filePath | |
| } | |
| LinkMap.prototype = { | |
| start: function(cb) { |
This file contains hidden or 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
| static func formaterNumber(_ number: Double) -> String { | |
| if number < 1e4 { | |
| return "\(number)" | |
| } | |
| if number >= 1e4 && number < 1e5 { | |
| return String(format: "%.1f", number / 1e4) + "万" | |
| } | |
This file contains hidden or 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
| NSMutableDictionary *query = [[NSMutableDictionary alloc] initWithObjects: objects forKeys: keys]; | |
| long retainCount = CFGetRetainCount((__bridge CFTypeRef) query); |
This file contains hidden or 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
| built_products_dir = ENV["BUILT_PRODUCTS_DIR"] | |
| frameworks_folder_path = ENV["FRAMEWORKS_FOLDER_PATH"] | |
| srcroot = ENV["SRCROOT"] | |
| dest = File.join(built_products_dir, frameworks_folder_path) | |
| platform = ENV["PLATFORM_DISPLAY_NAME"] | |
| carthage_frameworks_dir = File.join(srcroot, 'Carthage', 'Build', platform) | |
| input_file_count = ENV["SCRIPT_INPUT_FILE_COUNT"].to_i | |
| env = {"SCRIPT_INPUT_FILE_COUNT" => "0"} |
This file contains hidden or 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
| NSDate *date = [NSDate date]; | |
| NSTimeZone *zone = [NSTimeZone systemTimeZone]; | |
| NSInteger interval = [zone secondsFromGMTForDate:date]; | |
| NSDate *localDate = [date dateByAddingTimeInterval:interval]; |