Skip to content

Instantly share code, notes, and snippets.

View burczyk's full-sized avatar

Kamil Burczyk burczyk

  • Kraków, Poland
View GitHub Profile
@burczyk
burczyk / instantiate VC from Storyboard
Last active December 10, 2015 09:08
iOS macro for easy instantiate UIViewController by name. Usage: INSTANTIATE(@"MyViewController");
#define INSTANTIATE(viewController) [[UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil] instantiateViewControllerWithIdentifier:viewController];
@burczyk
burczyk / iPhone 5 detection
Last active December 14, 2015 22:38
Check for iPhone 5. Copy of http://stackoverflow.com/questions/12535471/detect-iphone-5-4-screen, just to have it in one place :)
#define IS_IPHONE5 (([[UIScreen mainScreen] bounds].size.height-568)?NO:YES)
@burczyk
burczyk / LLDB recursive view description
Created April 10, 2013 08:48
LLDB command for recursive view output during debugging
po [[self view] recursiveDescription]
@burczyk
burczyk / LoggersInitialization
Last active December 20, 2015 08:49
iOS initialization for crash stack traces and Cocoa Lumberjack loggers
#import "DDASLLogger.h"
#import "DDTTYLogger.h"
int ddLogLevel = LOG_LEVEL_VERBOSE;
#pragma mark Initialization
- (void) initializeLoggers {
[DDLog addLogger:[DDASLLogger sharedInstance]];
[DDLog addLogger:[DDTTYLogger sharedInstance]];
[[DDTTYLogger sharedInstance] setColorsEnabled:YES];
@burczyk
burczyk / Constants.h
Created July 30, 2013 08:05
Some useful iOS development macros
#ifndef Constants_h
#define Constants_h
#pragma mark some useful macros
#define DEFAULTS [NSUserDefaults standardUserDefaults]
#define DEFAULTS_SET(key, value) [[NSUserDefaults standardUserDefaults] setObject:value forKey:key]; [[NSUserDefaults standardUserDefaults] synchronize];
#define INSTANTIATE(viewController) [[UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil] instantiateViewControllerWithIdentifier:viewController];
#define INSTANTIATE_VIEW(name) [[[NSBundle mainBundle] loadNibNamed:name owner:self options:nil] objectAtIndex:0];
@burczyk
burczyk / UIColor+Shorthand.h
Created August 2, 2013 08:32
UIColor shorthand which allows to define colors directly from RGB elements (0-255) instead of floats.
#import <UIKit/UIKit.h>
@interface UIColor (Shorthand)
+ (UIColor*) colorWithR: (unsigned char) r G: (unsigned char) g B: (unsigned char) b A: (float) a;
@end
@burczyk
burczyk / UIImage+Color.h
Created August 2, 2013 08:34
UIImage shorthand to create UIImage with specified color and size. It can be used e.g. to stylize UITabBar or UINavigationBar with single-color image in place.
#import <UIKit/UIKit.h>
@interface UIImage (Color)
+ (UIImage *)imageWithColor:(UIColor *)color andSize:(CGSize)size;
@end
@burczyk
burczyk / const.c
Created January 28, 2014 13:46
const int VS int const
The trick is to read the declaration backwards (right-to-left):
const int a = 1; // read as "a is an integer which is constant"
int const a = 1; // read as "a is a constant integer"
Both are the same thing. Therefore:
a = 2; // Can't do because a is constant
The reading backwards trick especially comes in handy when you're dealing with more complex declarations such as:
const char *s; // read as "s is a pointer to a char that is constant"
@burczyk
burczyk / .gitconfig
Created January 29, 2014 16:52
.gitconfig backup
[user]
name = Kamil Burczyk
email = [email protected]
[core]
excludesfile = /Users/kamil/.gitignore_global
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
@burczyk
burczyk / quicksort.swift
Created January 2, 2015 11:51
Quicksort the Swift way
var list = [8,1,55,34,13,8,5,0,1,3,2,21]
func quicksort1(list:[Int]) -> [Int] {
if list.count == 0 {
return []
}
let pivotValue = list[0]
let smaller = filter(list, { $0 < pivotValue })
smaller