Skip to content

Instantly share code, notes, and snippets.

View izackp's full-sized avatar

Isaac Paul izackp

View GitHub Profile
@izackp
izackp / gist:9189380
Created February 24, 2014 14:32
Code Organization and Standards
Functions/Methods
Should do one thing and one thing only
Should not be longer than 30 lines (if possible, most of the time the expections are large switch statements)
Single lines should not exceed screen width
Any unused functions should be removed
Method names should be self explainatory
No side effects!
Yes, these means we don't override getters and setters.
Functions should follow 'the golden path'. Which means the developer minimizes nested code by 'returning' instead of using if else statements.
For more guidelines refer to this document: https://github.com/raywenderlich/objective-c-style-guide
@izackp
izackp / UIViewController+AddChild.m
Last active August 29, 2015 13:57
A quick implementation of adding a child view controller to another view controller and specifies which view to add it to.
@interface UIViewController (AddChild)
- (void)addChildController:(UIViewController*)childController toView:(UIView*)view;
@end
@implementation UIViewController (AddChild)
- (void)addChildController:(UIViewController*)childController toView:(UIView*)view {
[childController willMoveToParentViewController:self];
#!/bin/bash
#Taken from: http://stackoverflow.com/questions/6113243/how-to-find-unused-images-in-an-xcode-project
for i in `find . -name "*.png" -o -name "*.jpg"`; do
file=`basename -s .jpg "$i" | xargs basename -s .png | xargs basename -s @2x`
result=`ack -i "$file"`
if [ -z "$result" ]; then
echo "$i"
fi
done
@izackp
izackp / downSampleRetina.sh
Created April 23, 2014 17:50
Resizes retina images in the directory by half.
dir=$(pwd)
find "$dir" -name "*@2x.png" | while read image; do
outfile=$(dirname "$image")/$(basename "$image" @2x.png).png
if [ "$image" -nt "$outfile" ]; then
basename "$outfile"
width=$(sips -g "pixelWidth" "$image" | awk 'FNR>1 {print $2}')
height=$(sips -g "pixelHeight" "$image" | awk 'FNR>1 {print $2}')
@izackp
izackp / GradientIOS.m
Last active August 29, 2015 14:01
Creates a gradient for a view in code (IOS)
//By: Brandon Levasseur
- (void)viewDidLoad {
[super viewDidLoad];
CAGradientLayer *gradientLayer = [CAGradientLayer layer];
gradientLayer.frame = self.containerView.bounds;
[self.view.layer addSublayer:gradientLayer];
gradientLayer.colors = @[(__bridge id)[UIColor redColor].CGColor, (__bridge id)[UIColor yellowColor].CGColor, (__bridge id)[UIColor greenColor].CGColor];
@izackp
izackp / UIView+Pop.h
Created May 13, 2014 12:12
A simple rubber band pop animation I created.
#import <UIKit/UIKit.h>
@interface UIView (Pop)
- (void)popWithMagnitude:(CGFloat)magnitude numPops:(int)numPops duration:(CGFloat)duration;
@end
@izackp
izackp / uselessWebsites.md
Last active August 29, 2015 14:01
List of Useless/Bad Websites
source ~/.bash_profile
hash oclint &> /dev/null
if [ $? -eq 1 ]; then
echo >&2 "oclint not found, analyzing stopped"
exit 1
fi
@izackp
izackp / Widget.h
Last active August 29, 2015 14:01
Widget class which allows you to inherit from widget and create a xib file with the same name as the class. Once this is done you can reuse the xib anywhere by setting a view's subclass.
#import <UIKit/UIKit.h>
@interface Widget : UIView
@property (strong, nonatomic, readonly) IBOutlet UIView* view;
@end
@izackp
izackp / .gitignore
Created May 22, 2014 17:20
IOS .gitignore file
# Xcode
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
*.xcworkspace