Skip to content

Instantly share code, notes, and snippets.

View yoterpa's full-sized avatar

Anish Chand yoterpa

  • Srijan
  • New Delhi, India
View GitHub Profile
@yoterpa
yoterpa / iphone_images_universal.md
Created March 25, 2015 17:47
How to support both iPad and iPhone retina graphics in universal apps

for devices without retina:

ImageName.png - For iPhone/iPod
ImageName~ipad.png -- For iPad

For devices with retina display:

[email protected] - For iPhone/iPod
ImageName@2x~ipad.png -- For iPad
@yoterpa
yoterpa / create_ipa_file_xcode.md
Last active August 29, 2015 14:17
How to create IPA in Xcode 6?
  1. Select your Project Target in your xcode, then select Product option, in which you could select Archive option.
  2. Then a new window would open up and in that window select the Export option.
  3. Then a pop up will come as below and select second option Save to ad-hoc deployment.
@yoterpa
yoterpa / images_ios_workaround.md
Created March 25, 2015 19:32
Xcode 6.1 using same 2x image for iPhone 6 and 4s simulator

best approach is the old-fashioned way. Create images for each size with names like test-667 and do something like:

[UIImage imageNamed:[NSString stringWithFormat:@"test-%g", [[UIScreen mainScreen] bounds].size.height]]

UIViewController's method invoke sequence is as below

  • awakeFromNib
  • viewDidLoad
  • viewWillAppear
  • viewWillLayoutSubviews
  • viewDidLayoutSubviews
  • viewDidAppear
@yoterpa
yoterpa / UIBarButtonFromCode.m
Created May 13, 2015 06:39
add toolbar and center toolbar buttons from code
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *item1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonItemStylePlain target:self action:@selector(item1Action:)];
UIBarButtonItem *item2 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonItemStylePlain target:self action:@selector(item2Action:)];
NSArray *toolbarItems = [NSArray arrayWithObjects:item1, flexibleSpace, item2];
[toolBar setItems:toolbarItems animated:NO];
@yoterpa
yoterpa / sublime_regex2.md
Last active August 29, 2015 14:27
regex: check if two strings are same

([\d]+), \1((?:\W|$))

^    : Start anchor
(    : Start of capturing group
 \w+ : A word
)    : End of capturing group
\s+  : One or more whitespace
\1   : Back reference to the first word
\b : Word boundary
@yoterpa
yoterpa / gist:f9cc579ad342cdffe597
Last active September 1, 2015 11:33 — forked from r3econ/gist:9923319
Downloading JSON file using NSURLSession.
// Create a sample URL.
NSURL *url = [NSURL URLWithString:@"http://www.bbc.co.uk/tv/programmes/genres/drama/scifiandfantasy/schedules/upcoming.json"];
// Create a download task.
NSURLSessionDataTask *task = [[NSURLSession sharedSession] dataTaskWithURL:url
completionHandler:^(NSData *data,
NSURLResponse *response,
NSError *error)
{
if (!error)
@yoterpa
yoterpa / gist:503b0bcfeb54c55d46ba
Created September 25, 2015 07:16 — forked from spenrose/gist:4539571
Logging macros
// Logging Macros
#ifdef DEBUG
# define DLog(FORMAT, ...) printf("%s %s ~ %s\n", [[[NSDate date] description] UTF8String], __PRETTY_FUNCTION__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String])
#else
# define DLog(...)
#endif
// ALog always displays output regardless of the DEBUG setting
#define ALog(FORMAT, ...) printf("%s %s ~ %s\n", [[[NSDate date] description] UTF8String], __PRETTY_FUNCTION__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String])

The corrent order of arguments

g++ -o test test.cpp pkg-config --cflags --libs opencv

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib