This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import fileinput | |
import json | |
if name == "main": | |
jsonStr = '' | |
for aline in fileinput.input(): | |
jsonStr = jsonStr + ' ' + aline.strip() | |
jsonObj = json.loads(jsonStr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Substitute [ACHCoreDataHelper sharedHelper].defaultContext for the managedObjectContext | |
NSEntityDescription *entity = [NSEntityDescription entityForName:@"StickerPack" inManagedObjectContext:[ACHCoreDataHelper sharedHelper].defaultContext]; | |
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; | |
[fetchRequest setEntity:entity]; | |
NSError *error; | |
NSArray *items = [[ACHCoreDataHelper sharedHelper].defaultContext executeFetchRequest:fetchRequest error:&error]; | |
NSLog(@"items: %@", items); | |
StickerPack *pack = items[0]; | |
NSLog(@"pack: %@", pack); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Easy helper method: | |
- (void)setMaskTo:(UIView *)view byRoundingCorners:(UIRectCorner)corners | |
{ | |
CGFloat cornerRadius = 6.0; | |
UIBezierPath *rounded = [UIBezierPath bezierPathWithRoundedRect:view.bounds byRoundingCorners:corners cornerRadii:CGSizeMake(cornerRadius, cornerRadius)]; | |
CAShapeLayer *shape = [[CAShapeLayer alloc] init]; | |
[shape setPath:rounded.CGPath]; | |
view.layer.mask = shape; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__weak id weakSelf = self; | |
[[[[[self signalGetNetworkStep1] flattenMap:^RACStream*(id *x) { | |
// perform your custom business logic | |
return [weakSelf signalGetNetworkStep2:x]; | |
}] flattenMap:^RACStream*(id *y) { | |
// perform additional business logic | |
return [weakSelf signalGetNetworkStep3:y]; | |
}] flattenMap:^RACStream*(id *z) { | |
// more business logic | |
return [weakSelf signalGetNetworkStep4:z]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NSString *filePath = [[NSBundle mainBundle] pathForResource:JohnSmith ofType:@"json"]; | |
NSData *data = [NSData dataWithContentsOfFile:filePath]; | |
if (data) { | |
NSString *jsonString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; | |
KCUser *appUser = [[KCUser alloc] init]; | |
NSString* MIMEType = @"application/json"; | |
NSError* error; | |
NSData *data = [jsonString dataUsingEncoding:NSUTF8StringEncoding]; | |
id parsedData = [RKMIMETypeSerialization objectFromData:data MIMEType:MIMEType error:&error]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Helper method to animate the showing of a view | |
private void showLayout (final LinearLayout theLayout) { | |
AlphaAnimation fade_in = new AlphaAnimation(0.0f, 1.0f); | |
fade_in.setDuration(500); | |
fade_in.setAnimationListener(new AnimationListener() { | |
public void onAnimationStart(Animation arg0) { | |
} | |
public void onAnimationRepeat(Animation arg0) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// in viewDidLoad | |
[self.mySegmentedConrol setTintColor:[UIColor colorWithRed:153.0/255.0 green:153.0/255.0 blue:153.0/255.0 alpha:1]]; | |
[self.mySegmentedConrol setSegmentedControlStyle:UISegmentedControlStyleBar]; | |
// Update tints on valueChanged | |
- (IBAction)valueChanged:(UISegmentedControl *)sender { | |
UIColor *selectedTintColor = [UIColor colorWithRed:80.0f/255.0f green:185.0f/255.0f blue:72.0f/255.0f alpha:1.0]; | |
UIColor *unselectedTintColor = [UIColor colorWithRed:153.0/255.0 green:153.0/255.0 blue:153.0/255.0 alpha:1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <QuartzCore/QuartzCore.h> | |
// Form validation. You'll probably place this in your buttonClicked action | |
if ([textField.text isEqualToString:@""]) // checks if field is empty, add other form validation here | |
{ | |
textField.layer.cornerRadius = 8.0f; | |
textField.layer.masksToBounds = YES; | |
textField.layer.borderColor = [[UIColor redColor] CGColor]; | |
textField.layer.borderWidth = 1.0f; | |
} |