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
snapShotter.startWithCompletionHandler { (snapshot:MKMapSnapshot?, error:NSError?) in | |
let image = snapshot?.image | |
} |
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
let mapSnapshotOptions = MKMapSnapshotOptions() | |
// Set the region of the map that is rendered. | |
let location = CLLocationCoordinate2DMake(37.332077, -122.02962) // Apple HQ | |
let region = MKCoordinateRegionMakeWithDistance(location, 1000, 1000) | |
mapSnapshotOptions.region = region | |
// Set the scale of the image. We'll just use the scale of the current device, which is 2x scale on Retina screens. | |
mapSnapshotOptions.scale = UIScreen.mainScreen().scale |
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
let dispatch_group: dispatch_group_t = dispatch_group_create() | |
func startRequests(){ | |
asyncFunctionA() | |
asyncFunctionB() | |
dispatch_group_wait(dispatch_group, DISPATCH_TIME_FOREVER) // Wait forever! or set a reasonable default for timeout | |
} | |
func alsoStartRequests(){ | |
asyncFunctionA() |
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
func asyncFunctionA(){ | |
let urlRequest: NSURLRequest = ... | |
let task = self.session?.dataTaskWithRequest(urlRequest, completionHandler: { | |
(data:NSData?, response:NSURLResponse?, error:NSError?) in | |
self.taskAComplete = true | |
self.checkResults() | |
}) | |
} |
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 <Foundation/Foundation.h> | |
#import "PASConstants.h" | |
#import "PASViewController.h" | |
@interface PASHideDetailAnimator : NSObject <UIViewControllerAnimatedTransitioning> | |
@end | |
@implementation PASHideDetailAnimator |
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
#app/helpers/application_helper.rb | |
def wikify(text) | |
text.gsub!(/(\<wp\>(.*?)\<\/wp\>)/) do |m| | |
n = m.gsub!(/(\<wp\>|<\/wp\>)/, '') | |
link_to(n, "http://en.wikipedia.org/wiki/#{n}") | |
end | |
end |
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
# app/helpers/application_helper.rb | |
# In your View, simply call fb_share with options. app_id and redirect_uri are mandatory. | |
# For more details, please see http://www.behindtechlines.com/2011/12/09/facebook-feed-dialog-rails/ | |
module ApplicationHelper | |
def fb_share(app_id, redirect_uri, opts={}) | |
o = {:text => 'Share', | |
:name => '', |