Skip to content

Instantly share code, notes, and snippets.

@CavalcanteLeo
CavalcanteLeo / GCDManager.h
Created March 22, 2016 02:49 — forked from shyambhat/GCDManager.h
Clean Objective C helper methods to perform background tasks and perform completion on main thread.
#import <Foundation/Foundation.h>
@interface GCDManager : NSObject
+ (void)performBackgroundTask:(void (^)())block withCompletion:(void (^)())completion;
+ (void)performHighPriorityBackgroundTask:(void (^)())block withCompletion:(void (^)())completion;
+ (void)performLowPriorityBackgroundTask:(void (^)())block withCompletion:(void (^)())completion;
@end
@CavalcanteLeo
CavalcanteLeo / YMKeyboardLayoutHelperView.m
Created March 22, 2016 02:50 — forked from shepting/YMKeyboardLayoutHelperView.m
A great little helper for handling keyboard animations nicely. Just put this view at the bottom vertically of your views and it will move everything else up and down for you.
//
// YMKeyboardLayoutHelperView.m
// ios-chat
//
// Created by Steven Hepting on 7/17/13.
// Copyright (c) 2013 Yammer. All rights reserved.
//
#import "YMKeyboardLayoutHelperView.h"
#import "UIView+LayoutAdditions.h"
@CavalcanteLeo
CavalcanteLeo / Helper.m
Created March 22, 2016 02:52 — forked from nicroth/Helper.m
iOS - Resize a UIImage - actually resizes the data for uploading!
//takes an image, and returns a dictionary with multiple sizes
-(NSDictionary *)resizeImage:(UIImage *)theImage
{
//Create the "large" size image to upload
float actualHeight = theImage.size.height;
float actualWidth = theImage.size.width;
float imgRatio = actualWidth/actualHeight;
//set the maximum size you want - width/height
float maxRatio = 640.0/960.0;
//determine the required size to use
@CavalcanteLeo
CavalcanteLeo / ColorHelper.h
Created March 22, 2016 02:54 — forked from hmcfletch/ColorHelper.h
A bunch of objective-c color helpers
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
// generate a UIColor from rgb and alpha values
#define RGBA(r, g, b, a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
#define RGB(r, g, b) RGBA(r, g, b, 1.0)
// generate a UIColor
#define GRAYSCALEA(rgb, a) RGBA(rgb, rgb, rgb, a)
#define GRAYSCALE(rgb) GRAYSCALEA(rgb, 1.0)
// generate a UIColor from a hex and an alpha value
@CavalcanteLeo
CavalcanteLeo / SnapshotHelper.h
Created March 22, 2016 02:55 — forked from vovkasm/SnapshotHelper.h
Objective C implementation of SnapshotHelper class for https://github.com/fastlane/snapshot
/* This SnapshotHelper class should be compatible with SnapshotHelper.swift version 1.2 */
@import Foundation;
@import XCTest;
@interface SnapshotHelper : NSObject
- (instancetype)initWithApp:(XCUIApplication*)app;
- (void)snapshot:(NSString*)name waitForLoadingIndicator:(BOOL)wait;
#import <Foundation/Foundation.h>
#import "Image.h"
@interface ImageHelper : NSObject{
@private
Image *image;
}
- (UIImage *)getThumbnailImage;
- (UIImage *)getFullScreenImage;
- (UIImage *)getOriginalImage;
#import "ImageHelper.h"
#import "EntryHelper.h"
@implementation ImageHelper
@synthesize image;
- (UIImage *)getFullScreenImage{
return [UIImage imageWithContentsOfFile:[self getFullScreenImagePath]];
}
@CavalcanteLeo
CavalcanteLeo / AppDelegate.m
Created March 22, 2016 02:59
GCM implementation
@interface AppDelegate() <GGLInstanceIDDelegate, GCMReceiverDelegate>
@property(nonatomic, strong) NSString *gcmSenderID;
@property(nonatomic, strong) NSDictionary *registrationOptions;
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>GCM_SENDER_ID</key>
<string>***************</string>
<key>PLIST_VERSION</key>
<string>1</string>
<key>BUNDLE_ID</key>
<string>com.example.testapp</string>
@CavalcanteLeo
CavalcanteLeo / UIButton+Block.h
Created March 27, 2016 08:57 — forked from azeitler/UIButton+Block.h
iOS - UIButton+Block
//
// UIButton+Block.h
// BoothTag
//
// Created by Josh Holtz on 4/22/12.
// Copyright (c) 2012 Josh Holtz. All rights reserved.
//
#define kUIButtonBlockTouchUpInside @"TouchInside"