Skip to content

Instantly share code, notes, and snippets.

View oliverbarreto's full-sized avatar

Oliver oliverbarreto

View GitHub Profile
@oliverbarreto
oliverbarreto / HTML base page.html
Created April 28, 2013 18:26
HTML: HTML base code #sublime
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>Bootstrap 101 Template</title>
@oliverbarreto
oliverbarreto / gist:5505224
Created May 2, 2013 20:37
ObjectiveC CA Load image and with sprites
NSString *path = [[NSBundle mainBundle] pathForResource:@"yourImage.png" ofType:nil];
CGImageRef img = [UIImage imageWithContentsOfFile:path].CGImage;
CALayer *layer = [CALayer layer];
layer.contents = (id)img;
layer.bounds = CGRectMake( 0, 0, CGImageGetWidth(img), CGImageGetHeight(img) );
// with sprites atlasses
CALayer *layer = [CALayer layer];
@oliverbarreto
oliverbarreto / new_gist_file
Created May 4, 2013 18:53
Objective-C: UIDevice Screen Size
CGRect screenSizeRect = [[UIScreen mainScreen] bounds];
CGRect screenSizeRect = [[UIScreen mainScreen] applicationFrame];
CGFloat screenWidth = screenSizeRect.size.width;
CGFloat screenHeight = screenSizeRect.size.height;
@oliverbarreto
oliverbarreto / new_gist_file
Created May 4, 2013 19:27
Objective-C: Create UIImageView
//First Create a Image & FrameRECT
UIImage *someImage = [UIImage imageNamed:@"a.png"];
someRECT = CGRectMake(0, 0, weight, height);
//Method A
UIImageView *imageView = [[UIImageView alloc] initWithFrame:someRECT;
[self.view addSubview:imageView];
//Method B
UIImageView *imageView = [[UIImageView alloc] initWithImage:someImage];
@oliverbarreto
oliverbarreto / gist:5591860
Created May 16, 2013 13:49
HTML & CSS: Zoom transition Class
<style type="text/css">
.zoom {
width: 200px; padding: 5px; border: 1px solid black;
-webkit-transition: all .3s ease-out;
-moz-transition: all .3s ease-out;
-o-transition: all .3s ease-out;
transition: all .3s ease-out;
}
.zoom:hover {
-moz-transform: scale(2);
@oliverbarreto
oliverbarreto / gist:6574148
Created September 15, 2013 20:38
Objective-C RoundedView:toDiameter:
-(void)setRoundedView:(UIImageView *)roundedView toDiameter:(float)newSize;
{
CGPoint saveCenter = roundedView.center;
CGRect newFrame = CGRectMake(roundedView.frame.origin.x, roundedView.frame.origin.y, newSize, newSize);
roundedView.frame = newFrame;
roundedView.layer.cornerRadius = newSize / 2.0;
roundedView.center = saveCenter;
}
@oliverbarreto
oliverbarreto / ObjectiveC Singleton
Last active December 27, 2015 09:39
Singleton Code for ObjectiveC iOS7
SingletonClass.h:
@interface SingletonClass : NSObject
@property (nonatomic, retain) NSString *myProperty;
+ (SingletonClass *)sharedInstance;
@end
SingletonClass.m:
@implentation
+ (SingletonClass *)sharedInstance
@oliverbarreto
oliverbarreto / Blocks presenting ViewControllers
Created December 5, 2013 23:15
Blocks for Presenting and Dismissing View Controllers instead of Protocols and Delegate callbacks
DETAIL VIEW CONTROLLER - PRESENTED VC
#instead of defining the protocol with its required callback methods and delegate property
# DetailViewController.h
typedef void (^DetailViewControllerCompletionBlock)(BOOL success);
@property (nonatomic, copy) DetailViewControllerCompletionBlock completionBlock;
# Instead of falling delegate call cakes from IBActions asociares with UI buttons... Assign the BOOL variable of the block
# DetailViewController.m
- (IBAction)cancel:(id)sender {
@oliverbarreto
oliverbarreto / Dlog.h
Created December 8, 2013 09:24 — forked from sendoa/Dlog.h
#ifdef DEBUG
#define DLog(...) NSLog(@"%s %@", __PRETTY_FUNCTION__, [NSString stringWithFormat:__VA_ARGS__])
#define ALog(...) [[NSAssertionHandler currentHandler] handleFailureInFunction:[NSString stringWithCString:__PRETTY_FUNCTION__ encoding:NSUTF8StringEncoding] file:[NSString stringWithCString:__FILE__ encoding:NSUTF8StringEncoding] lineNumber:__LINE__ description:__VA_ARGS__]
#else
#define DLog(...) do { } while (0)
#define ALog(...) [TestFlight passCheckpoint:[NSString stringWithFormat:__VA_ARGS__]]
#ifndef NS_BLOCK_ASSERTIONS
#define NS_BLOCK_ASSERTIONS
#endif
#endif
// http://cocoawithlove.com/2009/10/ugly-side-of-blocks-explicit.html has a nice breakdown of the syntax--it helps to think of the ^ as similar to a pointer dereference symbol *
// block typedef:
typedef void(^Block)();
typedef void(^ConditionalBlock)(BOOL);
typedef NSString*(^BlockThatReturnsString)();
typedef NSString*(^ConditionalBlockThatReturnsString)(BOOL);
// block property with typedef: