Skip to content

Instantly share code, notes, and snippets.

View jeksys's full-sized avatar

Eugene Yagrushkin jeksys

View GitHub Profile
@jeksys
jeksys / gist:1797397
Created February 11, 2012 07:04
KeyboardHide show
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShown:)
name:UIKeyboardWillShowNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillHide:)
name:UIKeyboardWillHideNotification
object:nil];}
@jeksys
jeksys / gist:1507490
Created December 21, 2011 20:07
Custom modal UIViewController transitions
Just a snippet.
Note: Don’t push or remove view controllers with non-opaque views. The underlying view of the parent view controller is removed.
[CATransaction begin];
CATransition *transition = [CATransition animation];
transition.type = kCATransitionFade;
transition.duration = animated ? 0.5f : 0.0f;
transition.fillMode = kCAFillModeForwards;
@jeksys
jeksys / gist:1423460
Created December 2, 2011 14:41
jumping to background
dispatch_queue_t callerQueue = dispatch_get_current_queue();
dispatch_retain(callerQueue);
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
// Do the work in the other thread...
// Example: NSArray* items = parseJSON(data);
dispatch_async(callerQueue, ^{
@jeksys
jeksys / gist:1313867
Created October 25, 2011 19:03
Xcode log macros
#define CMLog(format, ...) NSLog(@"%s:%@", __PRETTY_FUNCTION__,[NSString stringWithFormat:format, ## __VA_ARGS__]);
#define MARK CMLog(@"%s", __PRETTY_FUNCTION__);
#define START_TIMER NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate];
#define END_TIMER(msg) NSTimeInterval stop = [NSDate timeIntervalSinceReferenceDate]; CMLog([NSString stringWithFormat:@"%@ Time = %f", msg, stop-start]);
@jeksys
jeksys / LoaderURL.h
Created October 7, 2011 18:40
Download URL
@interface LoaderURL : NSObject
{
NSMutableData *responseData;
NSURLConnection *connectionXML;
}
@property (nonatomic, copy) NSString *xmlFileName;
- (BOOL) updateFile;
@jeksys
jeksys / gist:1268284
Created October 6, 2011 18:55
Log GCRect and GCPoint
#define NSLogFrame(description,aFrame) NSLog(@"%@ - {%0.0f:%0.0f}{%0.0f:%0.0f}", description, aFrame.origin.x, aFrame.origin.y, aFrame.size.width, aFrame.size.height);
#define NSLogPoint(description,aFrame) NSLog(@"%@ - {%0.0f:%0.0f}{%0.0f:%0.0f}", description, aFrame.origin.x, aFrame.origin.y, aFrame.size.width, aFrame.size.height);
@jeksys
jeksys / Lightning.h
Created August 23, 2011 19:19
Lighting, cocos2D
//
// Lightning.h
// Trundle
//
// Created by Robert Blackwood on 12/1/09.
// Copyright 2009 Mobile Bros. All rights reserved.
//
#import "cocos2d.h"
@jeksys
jeksys / gist:1107826
Created July 26, 2011 19:56
Accelerometer
- (void)accelerometer:(UIAccelerometer*)accelerometer didAccelerate:(UIAcceleration*)acceleration{
static float prevX=0, prevY=0;
float accelX = acceleration.x * kFilterFactor + (1- kFilterFactor)*prevX;
float accelY = acceleration.y * kFilterFactor + (1- kFilterFactor)*prevY;
prevX = accelX;
prevY = accelY;
pitch = accelX;
}
@jeksys
jeksys / gist:1095655
Created July 20, 2011 19:02
CALayer shadows
myView.layer.shadowOpacity = 0.8;
myView.layer.shadowRadius = 5.0;
myView.layer.shadowOffset = CGSizeZero;
myView.layer.shadowPath = [UIBezierPath bezierPathWithRect:myView.layer.bounds].CGPath;