Skip to content

Instantly share code, notes, and snippets.

View lennypham's full-sized avatar

Lenny Pham lennypham

View GitHub Profile
@lennypham
lennypham / gist:7123936
Created October 23, 2013 18:25
A UIView category for debugging auto layout issues. Taken from @justin williams presentation on auto layout http://vimeopro.com/360conferences/360idev-2013/video/75232527
#import <objc/objc-runtime.h>
#import "UIView+SGAutoLayoutExtensions.h"
@implementation UIView (SGAutoLayoutExtensions)
#ifdef DEBUG
- (NSString *)nsli_description
{
return [self restorationIdentifier] ?: [NSString stringWithFormat:@"%@:%p", [self class], self];
@lennypham
lennypham / gist:7120853
Created October 23, 2013 15:28
UIView category from @justin williams presentation on autolayout http://vimeopro.com/360conferences/360idev-2013/video/75232527
@import UIKit;
@interface UIView (SGAdditions)
+ (instancetype)sg_autolayoutVIew;
@end
#import "UIView+SGAdditions.h"
@lennypham
lennypham / gist:7026020
Created October 17, 2013 14:31
Macro for converting hex color values into a UIColor object.
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]
@lennypham
lennypham / iOSYTFrameAPI
Created October 3, 2013 20:23
iOS iFrame API - Playing a video inline in a iOS UIWebview.
static NSString *youTubeVideoHTML = @"<!DOCTYPE html><html><body><div id=\"player\"><script>var tag = document.createElement('script');tag.src = \"http://www.youtube.com/iframe_api\";var firstScriptTag = document.getElementsByTagName('script')[0];firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);var player;function onYouTubeIframeAPIReady() { player = new YT.Player('player', { height: '%0.0f', width: '%0.0f', videoId: '%@', events: { 'onReady': onPlayerReady, }, playerVars: { playsinline: 1 } }); } function onPlayerReady(event) { event.target.playVideo(); }</script></body></html>";
- (void)playVideoWithId:(NSString *)videoId
{
self.myWebView.allowsInlineMediaPlayback = YES;
self.myWebView.mediaPlaybackRequiresUserAction = NO;
NSString *html = [NSString stringWithFormat:youTubeVideoHTML,
self.myWebView.frame.size.height,
self.myWebView.frame.size.width,

Contract Killer 3

Revised date: 07/11/2012

Between us [company name] and you [customer name]

Summary:

We’ll always do our best to fulfil your needs and meet your expectations, but it’s important to have things written down so that we both know what’s what, who should do what and when, and what will happen if something goes wrong. In this contract you won’t find any complicated legal terms or long passages of unreadable text. We’ve no desire to trick you into signing something that you might later regret. What we do want is what’s best for both parties, now and in the future.

Date: [date]

Between us [company name] and you [customer name].

Summary:

In short; neither of us will share any confidential information about each-other, by any means, with anyone else.

What’s confidential information?

@lennypham
lennypham / gist:5778085
Last active December 18, 2015 11:49
Test for iOS version
NSUInteger DeviceSystemMajorVersion();
NSUInteger DeviceSystemMajorVersion() {
static NSUInteger _deviceSystemMajorVersion = -1;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
_deviceSystemMajorVersion = [[[[[UIDevice currentDevice] systemVersion] componentsSeparatedByString:@"."] objectAtIndex:0] intValue];
});
return _deviceSystemMajorVersion;
}
@lennypham
lennypham / gist:5215973
Last active July 26, 2017 06:47
Table View Controller Delegate and Datasource methods
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
#warning Potentially incomplete method implementation.
// Return the number of sections.
return 0;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
@lennypham
lennypham / gist:5167282
Created March 15, 2013 03:26
UIViewControllerTemplate
#pragma mark - Initialization
- (id)initWithCoder:(NSCoder *)aDecoder
{
self = [super initWithCoder:aDecoder];
if (self)
{
// Custom initialization
}
@lennypham
lennypham / gist:5163401
Last active December 14, 2015 23:08
Check for DONE key in iOS keyboard for UITextView
- (BOOL)textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text
{
if ([text isEqual:@"\n"])
{
[textView resignFirstResponder];
return NO;
}
return YES;
}