Skip to content

Instantly share code, notes, and snippets.

@jobinkurian
jobinkurian / Macros.h
Created January 14, 2016 06:11 — forked from numo16/Macros.h
Some useful iOS/Objective-C Macros
#define ApplicationDelegate ((AppDelegate *)[[UIApplication sharedApplication] delegate])
#define UserDefaults [NSUserDefaults standardUserDefaults]
#define NotificationCenter [NSNotificationCenter defaultCenter]
#define SharedApplication [UIApplication sharedApplication]
#define Bundle [NSBundle mainBundle]
#define MainScreen [UIScreen mainScreen]
#define ShowNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = YES
#define HideNetworkActivityIndicator() [UIApplication sharedApplication].networkActivityIndicatorVisible = NO
#define NetworkActivityIndicatorVisible(x) [UIApplication sharedApplication].networkActivityIndicatorVisible = x
#define NavBar self.navigationController.navigationBar
@jobinkurian
jobinkurian / gist:09ba4bd225622296b839
Created January 6, 2016 12:50 — forked from taylorhughes/gist:4dc50b2fe674c0a84cc6
Update Facebook token in iOS client from existing server-side cached token
[self.apiClient retrieveConnectedServicesWithSuccessBlock:^(NSDictionary *services) {
NSArray *facebookTokens = services[@"facebook"];
if (facebookTokens.count == 0) {
return;
}
NSDictionary *mostRecentFacebookTokenDict = facebookTokens[0];
NSNumber *refreshTimeNumber = mostRecentFacebookTokenDict[@"refreshTime"];
NSDate *refreshDate = [NSDate dateWithTimeIntervalSince1970:[refreshTimeNumber doubleValue]];
@jobinkurian
jobinkurian / Commit changed files.
Created December 16, 2015 07:19
This script will get all the file changed in a particular commit id and then print checkout command with the indiviual files
git show --pretty="format:" --name-only commitID > temp.txt &&
awk '{print "git checkout commitID " $0}' temp.txt && rm temp.txt
@jobinkurian
jobinkurian / backup-github.sh
Created December 14, 2015 11:08 — forked from rodw/backup-github.sh
A simple script to backup an organization's GitHub repositories, wikis and issues.
#!/bin/bash
# A simple script to backup an organization's GitHub repositories.
GHBU_BACKUP_DIR=${GHBU_BACKUP_DIR-"github-backups"} # where to place the backup files
GHBU_ORG=${GHBU_ORG-"<CHANGE-ME>"} # the GitHub organization whose repos will be backed up
# (if you're backing up a user's repos instead, this should be your GitHub username)
GHBU_UNAME=${GHBU_UNAME-"<CHANGE-ME>"} # the username of a GitHub account (to use with the GitHub API)
GHBU_PASSWD=${GHBU_PASSWD-"<CHANGE-ME>"} # the password for that account
GHBU_GITHOST=${GHBU_GITHOST-"github.com"} # the GitHub hostname (see comments)
GHBU_PRUNE_OLD=${GHBU_PRUNE_OLD-true} # when `true`, old backups will be deleted
@jobinkurian
jobinkurian / sublime-text-3-build-3065-license.md
Created November 27, 2015 09:03
Sublime Text 3 (build 3065+) - VALID License

SublimeText3 Valid License without cracking! Just download/install then use this license.

Notice that it may not work on dev builds, but still works on 3083 build!

----- BEGIN LICENSE -----

Andrew Weber
Single User License
EA7E-855605
813A03DD 5E4AD9E6 6C0EEB94 BC99798F
@jobinkurian
jobinkurian / Sublime Text License Key.md
Created November 27, 2015 09:03
Sublime Text 2 License Key, Sublime Text 3 License Key, Sublime Text Full Version.

Sublime Text 2 & 3 License Key, Sublime Text Full Version

Sublime Text License Key

How to activate license key

  1. Go to menu Help > Enter License.
  2. Copy the license key below and paste it into the textbox > Click the Use License button.
  3. Enjoy! 👍
@jobinkurian
jobinkurian / YourMainDataModel.m
Created September 25, 2015 21:03 — forked from hollance/YourMainDataModel.m
Saving an NSMutableArray to a plist file using NSKeyedArchiver and NSCoding.
// Gets the path to the app's Documents folder
- (NSString *)documentsDirectory
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
return paths[0];
}
// Gets the path to the data file
- (NSString *)dataFilePath
{
UIView *myView = cell.containerView;
CALayer *layer = myView.layer;
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m34 = 1.0 / -1000;
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, M_PI / 0.3, 0.0f, 1.0f, 0.0f);
layer.transform = rotationAndPerspectiveTransform;
[UIView animateWithDuration:1.0 animations:^{
layer.transform = CATransform3DIdentity;
}];
#import <Foundation/Foundation.h>
void method1(NSArray *numbers)
{
NSArray *sorted = [numbers sortedArrayUsingSelector:@selector(compare:)];
}
void method2(NSArray *numbers)
{
NSNumber *max=[numbers valueForKeyPath:@"@max.doubleValue"];
/*
Copied and pasted from David Hamrick's blog:
Source: http://www.davidhamrick.com/2011/12/31/Changing-the-UINavigationController-animation-style.html
*/
@interface UINavigationController (Fade)
- (void)pushFadeViewController:(UIViewController *)viewController;
- (void)fadePopViewController;