This file contains hidden or 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
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]]; | |
NSArray *fontNames; | |
NSInteger indFamily, indFont; | |
for (indFamily=0; indFamily<[familyNames count]; ++indFamily) { | |
NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]); | |
fontNames = [[NSArray alloc] initWithArray:[UIFont fontNamesForFamilyName:[familyNames objectAtIndex:indFamily]]]; | |
for (indFont=0; indFont<[fontNames count]; ++indFont) { | |
NSString * fontName = [fontNames objectAtIndex:indFont]; | |
NSLog(@" Font name: %@", fontName); | |
} |
This file contains hidden or 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
UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)] autorelease]; | |
CAGradientLayer *gradient = [CAGradientLayer layer]; | |
gradient.frame = view.bounds; | |
gradient.colors = [NSArray arrayWithObjects:(id)[[UIColor blackColor] CGColor], (id)[[UIColor whiteColor] CGColor], nil]; | |
[view.layer insertSublayer:gradient atIndex:0]; |
This file contains hidden or 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
CALayer *mask = [CALayer layer]; | |
mask.contents = (id)[maskingImage CGImage]; | |
mask.frame = (CGRect){0, 0, maskingImage.size}; | |
view.layer.mask = mask; | |
view.layer.masksToBounds = YES; |
This file contains hidden or 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
bgTask = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler: | |
^{ | |
[[UIApplication sharedApplication] endBackgroundTask:bgTask]; | |
}]; | |
// Now call methods doing network activity | |
// ... | |
// WHEN I KNOW THE LAST ACTION HAS COMPLETED USE THIS BLOCK OF CODE | |
if (bgTask != UIBackgroundTaskInvalid) |
This file contains hidden or 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
UIGraphicsBeginImageContext(view.bounds.size); | |
[view.layer renderInContext: | |
UIGraphicsGetCurrentContext()]; | |
UIImage *destinationImage = UIGraphicsGetImageFromCurrentImageContext(); | |
UIGraphicsEndImageContext(); |
This file contains hidden or 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
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle: @" " style:UIBarButtonItemStylePlain target:nil action:nil]; | |
self.navigationItem.backBarButtonItem = backButton; | |
UIImage *backButtonImage = [[UIImage imageNamed: @"img-arrow-left"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 4, 0, 36)]; | |
[[UIBarButtonItem appearance] setBackButtonBackgroundImage:backButtonImage forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; |
This file contains hidden or 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
#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] |
This file contains hidden or 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
require 'optparse' | |
require 'pivotal-tracker' | |
TOKEN = 'YOUR_PIVOTAL_TOKEN' | |
PROJECT_IDS = [YOUR_PIVOTAL_PROJECT_ID] | |
TESTER_NAME = 'YOUR DEFAULT TESTER NAME (IF ANY)' | |
PivotalTracker::Client.token = TOKEN | |
def generate_options | |
options = { |
This file contains hidden or 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
#!/bin/bash | |
file=$1 | |
function tile() { | |
convert $file -scale ${s}%x -crop 256x256 \ | |
-set filename:tile "%[fx:page.x/256]_%[fx:page.y/256]" \ | |
+repage +adjoin "${file%.*}_${s}_%[filename:tile].${file#*.}" | |
} | |
s=100 | |
tile | |
s=50 |
This file contains hidden or 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
//: Playground - noun: a place where people can play | |
import Foundation | |
// DispatchGroup sample. | |
// we are waiting for all async blocks to be finished before typing "[Dispatch Group] sample has finished" | |
let group = DispatchGroup() | |
let q1 = DispatchQueue.global(qos: .background) | |
let q2 = DispatchQueue.global(qos: .background) |