Skip to content

Instantly share code, notes, and snippets.

View andkon's full-sized avatar
🤠

Andrew Konoff andkon

🤠
View GitHub Profile
@andkon
andkon / DjangoDebugging.py
Last active August 29, 2015 14:01
Python-Django debugging with Foreman/gunicorn/celery.
# 1. Use Celery:
# http://celery.readthedocs.org/en/latest/tutorials/debugging.html
from celery import task
from celery.contrib import rdb
@task()
def add(x, y):
result = x + y
rdb.set_trace() # <- set breakpoint
@andkon
andkon / images.py
Last active August 29, 2015 14:02
Using Image from Pillow
from PIL import Image
img = Image.open("imagefilename.png")
print img.size
# 512, 512
print img.format
# PNG
print img.mode
# RGB
@andkon
andkon / UIViewController.m
Created June 16, 2014 23:49
Making a view behind iOS 7 status bar
- (void)viewDidLoad
{
CGRect rect = CGRectMake(0, 0, self.view.frame.size.width, 20);
UIView *statusBarBg = [[UIView alloc] initWithFrame:rect];
[self.view addSubview:statusBarBg];
statusBarBg.backgroundColor = [UIColor purpleColor];
}
@andkon
andkon / BouncyTransition.h
Created June 20, 2014 03:13
Custom Transitions Between VCs
#import <Foundation/Foundation.h>
@interface BouncyTransition : NSObject <UIViewControllerAnimatedTransitioning>
@end
@andkon
andkon / RootVC.h
Created June 20, 2014 19:00
Custom dismissal animation
@interface RootVC : UIViewController <UIViewControllerTransitioningDelegate>
@andkon
andkon / InteractiveTransition.h
Created June 22, 2014 03:19
Interactive Transitions
@interface InteractiveTransition.h : NSObject <UIViewControllerAnimatedTransitioning>
@end
@andkon
andkon / ViewController.h
Created June 25, 2014 18:35
UIKit Gravity!
@property (strong, nonatomic) UIDynamicAnimator *animator;
@property (strong, nonatomic) UIView *boxView;
@andkon
andkon / RootVC.h
Created June 25, 2014 18:58
Notification views
@interface RootVC : UIViewController <UIDynamicAnimatorDelegate>
@property (strong, nonatomic) UIDynamicAnimator *animator;
@property (strong, nonatomic) UIView *noticeView;
@andkon
andkon / Thing.m
Created July 18, 2014 18:27
Not sure what's in a dict you GET'd?
NSDictionary *dict = responseObject;
NSLog(@"dict");
for (id key in dict) {
id obj = [dict objectForKey:key];
NSLog(@"key=%@ value=%@ class=%@", key, obj, [obj class]);
}
@andkon
andkon / gist:6fd173142a8b8391885a
Last active August 29, 2015 14:15
iPhone screen size macros
// http://stackoverflow.com/questions/12446990/how-to-detect-iphone-5-widescreen-devices
#define IS_IPHONE ( [ [ [ UIDevice currentDevice ] model ] isEqualToString: @"iPhone" ] )
#define IS_IPHONE_4 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )480 ) < DBL_EPSILON )
#define IS_IPHONE_5 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )568 ) < DBL_EPSILON )
#define IS_IPHONE_6 ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )667 ) < DBL_EPSILON )
#define IS_IPHONE_6_PLUS ( fabs( ( double )[ [ UIScreen mainScreen ] bounds ].size.height - ( double )736 ) < DBL_EPSILON )