Skip to content

Instantly share code, notes, and snippets.

View Kirow's full-sized avatar

Kirill Serebriakov Kirow

View GitHub Profile
//
// LOOProfiling.h
//
// Created by Marcin Swiderski on 4/12/12.
// Copyright (c) 2012 Marcin Swiderski. All rights reserved.
//
// This software is provided 'as-is', without any express or implied
// warranty. In no event will the authors be held liable for any damages
// arising from the use of this software.
//
@Kirow
Kirow / UIImage+Blur.m
Created May 7, 2014 10:58
Blur category. This method is taken from Apple's UIImageEffects category provided in WWDC 2013 sample code
@implementation UIImage (ImageBlur)
// This method is taken from Apple's UIImageEffects category provided in WWDC 2013 sample code
- (UIImage *)applyBlurWithRadius:(CGFloat)blurRadius tintColor:(UIColor *)tintColor saturationDeltaFactor:(CGFloat)saturationDeltaFactor maskImage:(UIImage *)maskImage {
// Check pre-conditions.
if (self.size.width < 1 || self.size.height < 1) {
NSLog(@"*** error: invalid size: (%.2f x %.2f). Both dimensions must be >= 1: %@", self.size.width, self.size.height, self);
return nil;
}
if (!self.CGImage) {
NSLog(@"*** error: image must be backed by a CGImage: %@", self);
@Kirow
Kirow / Available Fonts.m
Last active August 29, 2015 14:01
Enumerate Fonts available in the application
//======================================
for (NSString* family in [UIFont familyNames]) {
NSLog(@"%@", family);
for (NSString* name in [UIFont fontNamesForFamilyName: family]) {
NSLog(@" %@", name);
}
}
//======================================
@Kirow
Kirow / UIVIew+Cell.m
Created May 26, 2014 16:35
Return Cell superview
@implementation UIView (CellSuperview)
- (UITableViewCell *)cellSuperview {
UIView *tableCell = self;
do {
tableCell = tableCell.superview;
} while (tableCell && ![tableCell isKindOfClass:[UITableViewCell class]]);
return (UITableViewCell *) tableCell;
}
@end
/** String: Identifier **/
#define DEVICE_IDENTIFIER ( ( IS_IPAD ) ? DEVICE_IPAD : ( IS_IPHONE ) ? DEVICE_IPHONE , DEVICE_SIMULATOR )
/** String: iPhone **/
#define DEVICE_IPHONE @"iPhone"
/** String: iPad **/
#define DEVICE_IPAD @"iPad"
/** String: Device Model **/
@Kirow
Kirow / Image.m
Created June 9, 2014 08:33
Get image size by URL w/o loading it to memory
// This method requires ImageIO.framework
#import <ImageIO/ImageIO.h>
- (CGSize)sizeOfImageAtURL:(NSURL *)imageURL
{
// With CGImageSource we avoid loading the whole image into memory
CGSize imageSize = CGSizeZero;
CGImageSourceRef source = CGImageSourceCreateWithURL((CFURLRef)imageURL, NULL);
if (source) {
NSDictionary *options = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:NO] forKey:(NSString *)kCGImageSourceShouldCache];
@Kirow
Kirow / StringEnum.h
Created July 8, 2014 08:39
String Enumeration
//================.h File======================
typedef enum {
EnumType_1,
EnumType_2,
EnumTypeCount // enum count
} EnumType;
//enum to string
#import "FileChangeObserver.h"
#undef Assert
#define Assert(COND) { if (!(COND)) { raise( SIGINT ) ; } }
@interface FileChangeObserver ()
@property ( nonatomic, readonly ) int kqueue ;
@property ( nonatomic ) enum FileChangeNotificationType typeMask ;
@end
//
// FDRCollectionViewCell.h
//
//
// Created by Brent Royal-Gordon on 7/10/13.
//
//
#import <UIKit/UIKit.h>
@Kirow
Kirow / Console.sh
Created November 17, 2014 11:29
How to fix home and end keys on Mac OS X
$ cd ~/Library
$ mkdir KeyBindings
$ cd KeyBindings
$ vi DefaultKeyBinding.dict