Skip to content

Instantly share code, notes, and snippets.

View alexruperez's full-sized avatar
:octocat:
Tech Director @globant

Alex Rupérez alexruperez

:octocat:
Tech Director @globant
View GitHub Profile
@alexruperez
alexruperez / ARRegisterForRemoteNotificationTypes.m
Last active August 29, 2015 14:02
- registerForRemoteNotificationTypes:categories: NS_AVAILABLE_IOS(3_0); ( iOS 8 Compatible )
- (void)registerForRemoteNotificationTypes:(NSUInteger)notificationTypes categories:(NSSet *)categories
{
if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)] && [UIApplication instancesRespondToSelector:@selector(registerForRemoteNotifications)])
{
[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:notificationTypes categories:categories]];
[[UIApplication sharedApplication] registerForRemoteNotifications];
}
else if ([UIApplication instancesRespondToSelector:@selector(registerForRemoteNotificationTypes:)])
{
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:notificationTypes];
@alexruperez
alexruperez / ParseExtensions.h
Created December 9, 2014 16:04
Parse Extensions Categories Objective-C iOS SDK
//
// ParseExtensions.h
//
// Created by Alejandro Rupérez on 9/12/14.
//
#import <Foundation/Foundation.h>
#import <Parse/Parse.h>
@alexruperez
alexruperez / MKMapView (setVisibleMapAnnotations).swift
Created December 29, 2014 15:52
MKMapView extension with setVisibleMapAnnotations edgePadding animated helper in Swift
extension MKMapView
{
func setVisibleMapAnnotations(edgePadding: UIEdgeInsets, animated: Bool)
{
var zoomRect = MKMapRectNull
for annotationObject in annotations
{
let annotation = annotationObject as MKAnnotation
let annotationPoint = MKMapPointForCoordinate(annotation.coordinate)
@alexruperez
alexruperez / ARURLOperation.h
Last active August 29, 2015 14:13
ARURLOperation -> NSOperation subclass. NSURLRequest. NSURLConnection. NSURLResponse. Response NSData. NSError. KVO. NSThread. NSRunLoop.
//
// ARURLOperation.h
// ARURLOperation
//
// Created by alexruperez on 13/1/15.
//
//
#import <Foundation/Foundation.h>
@alexruperez
alexruperez / NSString+SnakeCaseToTitleCase.h
Created May 10, 2013 07:35
How to convert a NSString from snake_case to Title Case in Objective-C
//
// NSString+SnakeCaseToTitleCase.h
//
// Copyright (c) 2013 alexruperez.
//
#import <Foundation/Foundation.h>
@interface NSString (SnakeCaseToTitleCase)
@alexruperez
alexruperez / NSDictionary+AllKeysStartingWith.h
Created May 10, 2013 07:46
How to get all keys starting with a common NSString in a NSDictionary
//
// NSDictionary+AllKeysStartingWith.h
//
// Copyright (c) 2013 alexruperez.
//
#import <Foundation/Foundation.h>
@interface NSDictionary (AllKeysStartingWith)
@alexruperez
alexruperez / ARSafariViewController.h
Last active April 4, 2016 10:37
Fix SFSafariViewController StatusBar Style, StatusBar Hidden and freezing when swiping back on iOS 9.2
//
// ARSafariViewController.h
//
// Copyright © 2016 alexruperez. The MIT License (MIT)
//
@import SafariServices;
@interface ARSafariViewController : SFSafariViewController
@alexruperez
alexruperez / BranchActivityObject.swift
Created March 15, 2018 13:28
BranchUniversalObject subclass with BranchActivityItemProviderDelegate custom or default implementation.
import Branch
public protocol BranchActivityObjectDelegate: BranchActivityItemProviderDelegate {}
public class BranchActivityObject: BranchUniversalObject {
private weak var delegate: BranchActivityObjectDelegate?
private var params: [AnyHashable : Any]!
private var linkProperties: BranchLinkProperties!
@alexruperez
alexruperez / BearmojiViewController.swift
Last active April 23, 2018 11:41
Create your own Animoji in Swift | Lil ‘Bits | https://www.youtube.com/watch?v=6Khyi2xKow4
import UIKit
import Vision
import AVFoundation
class BearmojiViewController: UIViewController {
private lazy var drawLayer = CALayer()
private lazy var captureSession: AVCaptureSession = {
let captureSession = AVCaptureSession()
guard let captureDevice = AVCaptureDevice.default(.builtInWideAngleCamera, for: .video, position: .front),
@alexruperez
alexruperez / AppDelegate.swift
Last active April 23, 2018 11:43
Silent Remote Notifications
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
if !application.isRegisteredForRemoteNotifications {
application.registerForRemoteNotifications()
}
return true
}
func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
print(deviceToken.reduce("", {$0 + String(format: "%02X", $1)}))
}