Skip to content

Instantly share code, notes, and snippets.

View saiday's full-sized avatar
:shipit:
su su su

Saiday saiday

:shipit:
su su su
View GitHub Profile
@saiday
saiday / .slather.yml
Created April 10, 2015 09:06
Slather yml
ci_service: travis_pro
ci_access_token: coveralltoken
coverage_service: coveralls
xcodeproj: Project.xcodeproj
source_directory: Project
ignore:
- ProjectTests/*
- Pods/*
@saiday
saiday / .travis.yml
Created April 10, 2015 08:49
Travis yml
language: objective-c
before_install:
- gem install cocoapods --no-rdoc --no-ri --no-document --quiet
- gem install slather --no-rdoc --no-ri --no-document --quiet
- cd Project && pod install
script:
- xctool test -workspace Project.xcworkspace -scheme ProjectTests -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 6' GCC_INSTRUMENT_PROGRAM_FLOW_ARCS=YES GCC_GENERATE_TEST_COVERAGE_FILES=YES
after_success:
- cd $TRAVIS_BUILD_DIR && slather
#import <RestKit/RestKit.h>
#import "CoreData+MagicalRecord.h"
// Use a class extension to expose access to MagicalRecord's private setter methods
@interface NSManagedObjectContext ()
+ (void)MR_setRootSavingContext:(NSManagedObjectContext *)context;
+ (void)MR_setDefaultContext:(NSManagedObjectContext *)moc;
@end
@implementation AppDelegate
@saiday
saiday / UILabelSubClass
Created March 27, 2015 05:32
Self calculate height label
- (void)layoutSubviews
{
[super layoutSubviews];
if (self.numberOfLines == 0 && self.preferredMaxLayoutWidth != CGRectGetWidth(self.frame)) {
self.preferredMaxLayoutWidth = self.frame.size.width;
[self setNeedsUpdateConstraints];
}
}
@saiday
saiday / soften edges
Created March 19, 2015 14:29
TableView with soften edges
CAGradientLayer *maskLayer = [CAGradientLayer layer];
CGColorRef outerColor = [UIColor colorWithWhite:1.0 alpha:0.0].CGColor;
CGColorRef innerColor = [UIColor colorWithWhite:1.0 alpha:1.0].CGColor;
maskLayer.colors = @[(__bridge id)outerColor, (__bridge id)innerColor];
maskLayer.locations = @[@0, @.05];
maskLayer.bounds = self.tableView.bounds;
maskLayer.anchorPoint = CGPointZero;
@saiday
saiday / gist:077b65f6f47a278a725e
Created March 19, 2015 13:29
Monitor resolution lower than iOS simulator even scaling to 50%
defaults write ~/Library/Preferences/com.apple.iphonesimulator SimulatorWindowLastScale "0.4"
@saiday
saiday / ReactiveCocoa+TextView
Created March 16, 2015 07:35
The consistency with AppKit and programatically setting text of UITextView
[[RACSignal merge:@[self.nameField.rac_textSignal, RACObserve(self.nameField, text)]] subscribeNext:^(NSString* text){ self.viewModel.name = text; }];
@saiday
saiday / BlackGradientView.m
Created March 13, 2015 09:23
BlackGradientView
- (instancetype)init
{
self = [super init];
if (self) {
[self setOpaque:NO];
}
return self;
}
@saiday
saiday / NSArray+Extensions
Created March 6, 2015 13:24
NSArray shuffle items
- (NSArray *)shuffle
{
NSUInteger count = [self count];
NSMutableArray *mutableArray = [NSMutableArray arrayWithArray:self];
for (NSUInteger i = 0; i < count; ++i) {
NSInteger remainingCount = count - i;
NSInteger exchangeIndex = i + arc4random_uniform((u_int32_t )remainingCount);
[mutableArray exchangeObjectAtIndex:i withObjectAtIndex:exchangeIndex];
}
@saiday
saiday / NSArray+Extensions
Created March 6, 2015 13:22
NSArray group by
- (NSDictionary *)groupByKey:(NSString *)key
{
NSMutableDictionary *dictionary = [NSMutableDictionary dictionary];
for (id obj in self) {
id keyValue = [obj valueForKey:key];
if (keyValue) {
NSMutableArray *array = dictionary[keyValue];
if (!array) {
array = [NSMutableArray array];