This file contains hidden or 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
NSData *msg = [@"This is a message" dataUsingEncoding:NSUTF8StringEncoding]; | |
NSData *key = [@"the password" dataUsingEncoding:NSUTF8StringEncoding]; | |
NSLog(@"Unencrypted message: [%@]", msg); | |
uint8_t iv[kCCBlockSizeAES128]; | |
if (SecRandomCopyBytes(kSecRandomDefault, sizeof(iv), iv)) | |
{ | |
// ERROR |
This file contains hidden or 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
// The problem: AFNetworking calls the operation's completion block asynchronously, so it breaks `-[NSOperation addDependency:]` order as the dependent is started *before* the dependency's completion block. | |
dispatch_semaphore_t sem = dispatch_semaphore_create(0); | |
__block NSOperation* blockOperation = nil; | |
void (^networkOperationHandler)(NSOperation *, id) = ^(NSOperation *operation, id __unused unused) { | |
if (operation.cancelled) | |
{ | |
NSLog(@"networkOperation: networkOperation cancelled!"); | |
[blockOperation cancel]; | |
} |
This file contains hidden or 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
// attempt 1 | |
static BOOL isBeingDebugged() | |
{ | |
static BOOL cachedValue = NO; | |
static dispatch_once_t onceToken; | |
dispatch_once(&onceToken, ^{ | |
char buffer[2*MAXCOMLEN + 1]; | |
int len = proc_name(getppid(), buffer, 2*MAXCOMLEN); | |
buffer[len] = 0; | |
cachedValue = !strncmp(buffer, "debugserver", len); |
This file contains hidden or 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
#!/usr/bin/env bash -e -u -o pipefail | |
export LANG="en_US.UTF-8" | |
usage() { | |
cat <<EOT | |
NAME | |
${0##*/} -- Build iOS stuff. | |
SYNOPSIS |
This file contains hidden or 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
#!/usr/bin/env bash | |
set -e -u -o pipefail | |
export LANG="en_US.UTF-8" | |
cat <<EOT | |
Creating IPA with the following parameters: | |
Application path: "${1:-}" | |
Code signing identity: "${2:-}" | |
Provisioning profile path: "${3:-}" |
This file contains hidden or 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
# source this in your Bash scripts | |
reset-sim() { | |
printf 'Close the frontend app if needed…' | |
killall iOS\ Simulator 2>&- && sleep 5 || true | |
printf ' Done.\n' | |
declare SIM_OS SIM SIM_ID | |
while read SIM | |
do |
This file contains hidden or 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
// Only called on iOS<8 | |
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation __unused)toInterfaceOrientation duration:(NSTimeInterval __unused)duration { | |
[self _beforeOrientationChange]; | |
} | |
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation __unused)fromInterfaceOrientation { | |
[self _afterOrientationChange]; | |
} | |
// Only called on iOS>8 |
This file contains hidden or 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; | |
@import CoreLocation; | |
//////////////////////////////////////////////////////////////////////////// | |
@interface XXXLocation : NSObject<CLLocationManagerDelegate> | |
@property (nonatomic) BOOL trackingEnabled; | |
@property (nonatomic) BOOL updating; | |
@property (nonatomic, strong) CLLocationManager *locationManager; | |
@end |
This file contains hidden or 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
# assuming SAR is 1:1, | |
SRC=Foo.mp4 | |
SRC_WIDTH=1916 | |
SRC_HEIGHT=852 | |
DST_WIDTH=720 | |
DST_HEIGHT=480 | |
DST_ASPECT=16/9 | |
DST_FPS=24000/1001 | |
DST_RATE=4100k |