Skip to content

Instantly share code, notes, and snippets.

View exce11ent's full-sized avatar

Vitalii Kraiovyi exce11ent

  • Україна
View GitHub Profile
@exce11ent
exce11ent / AppDelegate.swift
Created November 14, 2017 12:57
Part of AppDelegate.swift
func application(_ application: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any]) -> Bool {
if let dynamiclink = DynamicLinks.dynamicLinks()?.dynamicLink(fromCustomSchemeURL: url) {
handleLink(link: dynamiclink)
return true
}
return false
}
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([Any]?) -> Void) -> Bool {
class PostImagesModel {
enum CellImage {
case Required, Add, Actual(image: UIImage), Remote(url: NSURL)
}
private let maxLimit = 6
private var items: [CellImage] = []
func add(image: UIImage) {
- (instancetype)initWithElements:(id)firstObj, ... {
self = [self init];
if (self) {
va_list(args);
va_start(args, firstObj);
[_objects addObject:firstObj];
id obj;
while ((obj = va_arg(args, id)) != nil) {
[_objects addObject:obj];
}
NSArray * eng_items() {
return @[@"Laptop charging",
@"iPhone charging",
@"Cosmetics",
@"Watch",
@"Umbrella",
@"Toothbrush",
@"Deodorant",
@"Headphones",
@"Wipes",
@exce11ent
exce11ent / gist:dbf8435e52c1ef08fabf
Created October 20, 2014 09:59
Swift singleton
class WithSingleton {
class var sharedInstance :WithSingleton {
struct Singleton {
static let instance = WithSingleton()
}
return Singleton.instance
}
}
@exce11ent
exce11ent / ProjectsPool.m
Created April 22, 2014 08:14
SynchronizedLayer
AVPlayerItem * playerItem = [project playerItem];
if ([playerItem.videoComposition.instructions count] < 1) {
if (completionHandler) completionHandler(nil);
return;
}
AVSynchronizedLayer *synchronizedLayer = [project synchronizedLayer];
AVMutableVideoComposition *mvc = [AVMutableVideoComposition videoComposition];
mvc.instructions = playerItem.videoComposition.instructions;
mvc.renderScale = playerItem.videoComposition.renderScale;
mvc.renderSize = playerItem.videoComposition.renderSize;
@exce11ent
exce11ent / LinesOfCode
Last active August 29, 2015 13:59
Print number of lines of code in all source files in current directory and all subdirectories
find . "(" -name "*.m" -or -name "*.mm" -or -name "*.cpp" -or -name "*.h" ")" -print0 | xargs -0 wc -l
@exce11ent
exce11ent / gist:7943766
Created December 13, 2013 12:48
Macros for logging
#ifdef DEBUG
#define NSLog(...) NSLog(__VA_ARGS__)
#else
#define NSLog(...)
#endif
//for loggin memory usage:
#import "mach/mach.h"
vm_size_t usedMemory(void) {
struct task_basic_info info;
mach_msg_type_number_t size = sizeof(info);
kern_return_t kerr = task_info(mach_task_self(), TASK_BASIC_INFO, (task_info_t)&info, &size);
return (kerr == KERN_SUCCESS) ? info.resident_size : 0; // size in bytes
}
+(NSString *)cacheFilenameForURL:(NSURL *)resourceURL atSize:(CGSize)size atScaleFactor:(CGFloat)scaleFactor atPage:(int)page
{
NSString *cacheFilename = nil;
#ifdef UIIMAGE_PDF_CACHEING
NSFileManager *fileManager = [ NSFileManager defaultManager ];
NSString *filePath = [ resourceURL path ];