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
- (void)keyboardWillShow:(NSNotification *)notification { | |
CGRect keyboardFrame = [[[notification userInfo] objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue]; | |
CGRect convertedFrame = [self.view convertRect:keyboardFrame fromView:self.view.window]; | |
CGFloat animationDuration = [[[notification userInfo] objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue]; | |
UIViewAnimationCurve animationCurve = [[[notification userInfo] objectForKey:UIKeyboardAnimationCurveUserInfoKey] integerValue]; | |
[UIView animateWithDuration:animationDuration delay:0 options:animationCurve animations:^{ | |
self.viewToMove.bottom = self.view.height - convertedFrame.size.height - 15; |
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 poll() { | |
let backgroundQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) | |
let source = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, backgroundQueue) | |
let interval: UInt64 = UInt64(10) * NSEC_PER_SEC | |
let leeway: UInt64 = UInt64(0.1) * NSEC_PER_SEC | |
dispatch_source_set_timer(source, DISPATCH_TIME_NOW, interval, leeway) | |
dispatch_source_set_event_handler(source) { () -> Void in | |
self.pollDidFinish(source: source) |
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
var alert = UIAlertController(title: "Title", message: "Alert view message", preferredStyle: UIAlertControllerStyle.Alert) | |
alert.addAction(UIAlertAction(title: "Save", style: .Default, handler: { (action: UIAlertAction!) in | |
println("Saved") | |
})) | |
alert.addAction(UIAlertAction(title: "Cancel", style: .Default, handler: { (action: UIAlertAction!) in | |
println("Cancel") | |
})) | |
presentViewController(alert, animated: true, completion: nil) |
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
UIView *autoLayoutView = [[UIView alloc] init]; | |
autoLayoutView.backgroundColor = [UIColor redColor]; | |
autoLayoutView.translatesAutoresizingMaskIntoConstraints = NO; | |
[self.view addSubview:autoLayoutView]; | |
NSDictionary *views = NSDictionaryOfVariableBindings(autoLayoutView); | |
NSArray *hConstraints = [NSLayoutConstraint constraintsWithVisualFormat:@"|[autoLayoutView]|" | |
options:nil | |
metrics:nil |
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
Verifying my Blockstack ID is secured with the address 13XP5d1aPsUQZHt55f3WyYMCHvaWQjgDKu https://explorer.blockstack.org/address/13XP5d1aPsUQZHt55f3WyYMCHvaWQjgDKu |
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 "UIImage+Extension.h" | |
@implementation UIImage (Extension) | |
- (UIImage *)imageWithColor:(UIColor *)color | |
{ | |
UIGraphicsBeginImageContextWithOptions(self.size, NO, self.scale); | |
CGContextRef context = UIGraphicsGetCurrentContext(); | |
CGContextTranslateCTM(context, 0, self.size.height); | |
CGContextScaleCTM(context, 1.0, -1.0); |
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
// First, delete the two storyboard entries in the Info.plist (one newer one for SceneDelegate and a newer one for AppDelegate) | |
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
guard let windowScene = scene as? UIWindowScene else { | |
return | |
} | |
let blueViewController = UIViewController() | |
blueViewController.view.backgroundColor = .blue | |
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
static func load(_ entityId: Int, completion: @escaping ( (SampleServiceResponse?) -> Void)) { | |
let urlString = "https://api.sweetpeamobile.com/v1/sampleService?locationId=\(locationId)" | |
AF.request(urlString).responseDecodable(of: SampleServiceResponse.self) { response in | |
switch response.result { | |
case .success(let decodedResponse): | |
completion(decodedResponse) | |
case .failure(let error): | |
print("Networking error: \(error.localizedDescription)") | |
completion(nil) | |
} |
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
location /blog/ { | |
proxy_pass http://YOUR_IP_ADDRESS/; # this last forward slash is important | |
proxy_http_version 1.1; | |
proxy_cache_bypass $http_upgrade; | |
# Proxy headers | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_set_header Host $host; | |
proxy_set_header X-Real-IP $remote_addr; |
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
define( 'WP_HOME', 'https://yoursite.com/blog'); | |
define( 'WP_SITEURL', 'https://yoursite.com/blog'); | |
/** | |
* This is needed for a reverse proxy setup that terminates SSL and forwards /blog to another host. | |
* Without it, the Wordpress host doesn't know that it needs to make requests to itself using https. | |
*/ | |
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') { | |
$_SERVER['HTTPS'] = 'on'; | |
} |