Skip to content

Instantly share code, notes, and snippets.

View 0x8badf00d's full-sized avatar

0x8badf00d 0x8badf00d

View GitHub Profile
@0x8badf00d
0x8badf00d / CrashManager
Created March 24, 2014 03:04
Generate live crash report using PLCrashReporter
@interface CrashManager:NSObject
/**
* Generates live crash report, without triggering an actual crash condition.
*
* Works only if the vendor SDK is built using PLCrashReporter v 1.1 atleast.
* We are using runtime magic to call generateLiveReportAndReturnError: method on PLCrashReporter instance without changing vendor sdk (QuincyKit, HockeyApp, others)
*/
- (void)generateLiveReport;
@end
#import "PLCrashReporterConfig.h"
#import "PLCrashReporter.h"
#import "PLCrashReport.h"
#import "PLCrashReportTextFormatter.h"
- (void)watchdog
{
NSTimeInterval pingInterval = 1.0/60.0;
NSTimeInterval watchdogInterval = 1.0/30.0;
expr -- (void)printf("[%s, %s]\n",(char *) object_getClassName(*(long*)($esp+4)), (char *) *(long *)($esp+8) )
AFJSONRequestOperation *operationJSON = [AFJSONRequestOperation
JSONRequestOperationWithRequest:requestJSON
success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSMutableArray *results = [JSON valueForKey:@"results"];
// UPDATED CODE
for (id obj in [results valueForKey:@"value"]) {
if (![items containsObject:obj]) {
[items addObject:obj];
@0x8badf00d
0x8badf00d / CCamera.m
Created November 27, 2012 18:53
Really simple Objective-C AVFoundation Camera class
//
// CCamera.h
// CCamera
//
// Created by Jonathan Wight on 7/12/12.
// Copyright (c) 2012 Jonathan Wight. All rights reserved.
//
#import <Foundation/Foundation.h>
@0x8badf00d
0x8badf00d / gist:3973770
Created October 29, 2012 14:13
UIAlertViewStylePlainTextInput
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title" message:@"Alert Message" delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
alert.alertViewStyle = UIAlertViewStylePlainTextInput;
[alert textFieldAtIndex:0].borderStyle = UITextBorderStyleRoundedRect;
[alert show];
@0x8badf00d
0x8badf00d / NSNotificationCenter+ObserverAdditions.h
Created September 14, 2012 04:02
NSNotificationCenter+ObserverAdditions
#import <Foundation/Foundation.h>
@interface NSNotificationCenter (ObserverAdditions)
- (void)registerObserver:(id)observer
forName:(NSString *)name
object:(id)obj
queue:(NSOperationQueue *)queue
usingBlock:(void (^)(NSNotification *note))block;
#import <UIKit/UIKit.h>
@interface UIButton (UIButton_BackgroundImageAdditions)
-(void) setBackgroundImageWithColor: (UIColor *) color
cornerRadius: (CGFloat) cornerRadius
forState: (UIControlState) state;
@end
@0x8badf00d
0x8badf00d / DownloadOperation.h
Created April 2, 2012 22:25 — forked from zoul/DownloadOperation.h
Asynchronous NSURLConnection in concurrent NSOperation
@interface DownloadOperation : NSOperation
{
NSURLRequest *request;
NSURLConnection *connection;
NSMutableData *receivedData;
}
@property(readonly) BOOL isExecuting;
@property(readonly) BOOL isFinished;
@0x8badf00d
0x8badf00d / gist:1876181
Created February 21, 2012 12:15
setter
- (void)setValue:(NSString *)aValue
{
if (value != aValue)
{
[value release];
value = [aValue retain];
}
}