Skip to content

Instantly share code, notes, and snippets.

Seivan Heidari seivan

Block or report user

Report or block seivan

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:8694065
__block XXCurrentUser * user = nil;
dispatch_group_t group = dispatch_group_create();
[[XXClient sharedManager] setObserverDidSignInBlock:^(XXAccessCredential *accessCredential, NSError *error) {
[[LUKeychainAccess standardKeychainAccess] setObject:accessCredential forKey:NSStringFromClass([self class])];
if(error)theBlock(nil,error);
else dispatch_group_leave(group);
}];
View gist:8696247
//Hmm lets not clear up the blocks because lol. ~ Seivan.
__block XXCurrentUser * user = nil;
dispatch_group_t groupRequestMyProfile = dispatch_group_create();
dispatch_group_t groupSaveMyProfile = dispatch_group_create();
dispatch_group_t groupRequestMyApplications = dispatch_group_create();
dispatch_group_t groupRequestMyNotifications = dispatch_group_create();
[[XXClient sharedManager] setObserverDidSignInBlock:^(XXAccessCredential *accessCredential, NSError *error) {
@seivan
seivan / 0_reuse_code.js
Created Jan 30, 2014
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
View gist:8726142
[SINavigationControllerAccompanyTransition accompanyFromController:self
withNavigationController:self.navigationController];
[self.txtFieldPhoneNumber SH_addControlEvents:UIControlEventEditingChanged withBlock:[ETPhoneHandlers handlePhoneWithController:self]];
[self.txtFieldCountryName SH_setShouldBeginEditingBlock:[ETPhoneHandlers handleCountryWithController:self]];
View gist:8741391
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;{
CGFloat heightForRowAtIndexPath = 44.f;
NSString * cellID = [self cellIdForIndexPath:indexPath];
UITableViewCell <XXApplicationTableViewCellConfiguring> * cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if([cell conformsToProtocol:@protocol(XXApplicationTableViewCellConfiguring)]) {
[cell configureCellWithApplicationModel:self.application];
[cell layoutSubviews];
heightForRowAtIndexPath = [cell.contentView systemLayoutSizeFittingSize:UILayoutFittingCompressedSize].height;
}
View gist:8751548
if(self.accessCredential.isAboutToExpire) [self refreshToken];
dispatch_group_notify(self.signalWaitingForRefresh, dispatch_get_main_queue(), ^{
[self.apiClient requestWithResourcePath:theResourcePath parameters:theParameters HTTPMethod:theHTTPMethod onComplete:^(NSDictionary *responseObject, NSError *error, NSHTTPURLResponse *HTTPURLResponse) {
theBlock(responseObject,error, HTTPURLResponse);
}];
});
@seivan
seivan / gist:8793649
Last active Aug 29, 2015
Because it's 23:30 and I'm tired as fuck.
View gist:8793649
-(NSString *)platformsAsOxfordComma; {
NSArray * platforms = (NSArray *)self.platforms;
return [platforms SH_reduceValue:@"".mutableCopy withBlock:^id(NSMutableString * memo, NSString * obj) {
if(platforms.lastObject == obj) {
if(platforms.count > 1) [memo appendString:NSLocalizedString(@"AND", nil)]; // Do other languages even work like this?
[memo appendString:obj];
}
else {
[memo appendString:obj];
[memo appendString:@", "];
View gist:8810423
self.navigationController.transitioningDelegate = self;
[self SH_setAnimationDuration:0.5 withPreparedTransitionBlock:^(UIView *containerView, UIViewController *fromVC, UIViewController *toVC, NSTimeInterval duration, id<SHViewControllerAnimatedTransitioning> transitionObject, SHTransitionAnimationCompletionBlock transitionDidComplete) {
if (transitionObject.isReversed) {
toVC.view.layer.affineTransform = CGAffineTransformMakeTranslation(-CGRectGetWidth(toVC.view.frame), 0);
}
else {
toVC.view.layer.affineTransform = CGAffineTransformMakeTranslation(CGRectGetWidth(toVC.view.frame), 0);
}
View gist:8933478
+(instancetype)me; {
XXXCurrentUser * me = [XXXCurrentUser MR_findFirst];
[XXXClient sharedManager].accessCredential = [[LUKeychainAccess standardKeychainAccess]
objectForKey:NSStringFromClass([self class])];
if(me == nil || [XXXClient sharedManager].accessCredential == nil) {
me = nil;
View gist:8966159
Proper naming
completion: for callbacks that are complete (option)
completionHandler: callbacks that are complete but need action (required)
handler: callbacks that need action but are not necessarily completion (required)
You can’t perform that action at this time.