Skip to content

Instantly share code, notes, and snippets.

@acoomans
acoomans / chspecs.sh
Created May 1, 2014 15:21
Change Xcode build specs by merging OSX's specs in iPhone Simulator's specs
#!/bin/bash
# Change Xcode build specs by merging OSX's specs in iPhone Simulator's specs
# This allows to build dynamic libraries for the simulator
PLISTBUDDY="/usr/libexec/PlistBuddy"
ROOT=`xcode-select -print-path`
SIM_SPECS_DIR="$ROOT/Platforms/iPhoneSimulator.platform/Developer/Library/Xcode/Specifications"
OSX_SPECS_DIR="$ROOT/Platforms/MacOSX.platform/Developer/Library/Xcode/Specifications"
@acoomans
acoomans / macrostr.h
Last active August 29, 2015 13:57
C Pre-processor macro Stringification
// http://gcc.gnu.org/onlinedocs/cpp/Stringification.html
#define xstr(s) str(s)
#define str(s) #s
@acoomans
acoomans / swizzling.m
Created February 2, 2014 04:18
Objective-C Method Swizzling
// source: https://www.mikeash.com/pyblog/friday-qa-2010-01-29-method-replacement-for-fun-and-profit.html
#import <objc/runtime.h>
void __attribute__((weak)) MethodSwizzle(Class c, SEL origSEL, SEL overrideSEL) {
Method origMethod = class_getInstanceMethod(c, origSEL);
Method overrideMethod = class_getInstanceMethod(c, overrideSEL);
if (class_addMethod(c, origSEL, method_getImplementation(overrideMethod), method_getTypeEncoding(overrideMethod))) {
class_replaceMethod(c, overrideSEL, method_getImplementation(origMethod), method_getTypeEncoding(origMethod));
} else {
@acoomans
acoomans / 360.rb
Last active December 30, 2015 02:19
CapitalOne 360 cafe login script
# 360 script
# This script (re)login automatically on the wifi of CapitalOne 360 cafe in San Francisco
# created by: unknown
# adapted by: acoomans
require 'net/http'
require 'uri'
puts "<" * 80
@acoomans
acoomans / fb.h
Created November 21, 2013 23:55
Headers of Facebook's internal frameworks: FBUIKit, FBBase, FBAppKit, FBFoundation
/** FBUIKit */
@interface UIImageView (FBUIKit)
+ (id)imageViewWithImageNamed:(id)arg1;
@end
@interface UITableView (FBUIKit)
- (id)indexPathForLastRowInSection:(int)arg1;
- (id)indexPathForLastRow;
@end
@acoomans
acoomans / availability.h
Last active December 28, 2015 22:39
Macros for handling iOS API availabilities, disabling deprecation warnings in both clang and deploymate
#define SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define SYSTEM_VERSION_EQUAL_OR_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define SYSTEM_VERSION_EQUAL_OR_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)
// pragmas
@acoomans
acoomans / sub_1b1638.c
Created November 10, 2013 07:54
In-memory Instagram 4 key
//__attribute__((noinline))
void sub_1b1638_i(char *v) {
int r11 = 0x37;
int r6 = 0x65;
int r3 = 0x35;
int r2 = 0x38;
int r4 = 0x31;
int r9 = 0x34;
int r12 = 0x61;
int lr = 0x39;
@acoomans
acoomans / info.js
Last active December 26, 2015 09:19
UIAutomation target information
var target = UIATarget.localTarget();
// Bundle ID, ie "com.domain.myapp"
UIALogger.logDebug("bundleID: " + target.frontMostApp().bundleID());
// Name, ie "iPhone Simulator"
UIALogger.logDebug("name : " + target.name());
// Model, ie "iPhone Simulator"
UIALogger.logDebug("model: " + target.model());
@acoomans
acoomans / proxy.m
Last active December 20, 2015 11:39
delegate proxying
#pragma mark - delegate proxying
- (BOOL)respondsToSelector:(SEL)selector {
return (
[super respondsToSelector:selector] ||
[self.delegate respondsToSelector:selector]
);
}
- (id)forwardingTargetForSelector:(SEL)selector {
@acoomans
acoomans / vlcrecord.sh
Last active February 13, 2021 13:56
Record screen with VLC from command line (needs VLC nightly build)
/Applications/VLC-unstable.app/Contents/MacOS/VLC -I rc screen:// --noaudio --sout "#transcode{vcodec=h264,venc=x264, vb=800,acodec=none,scale=1.0}:std{access=file,mux=mp4,dst=my_first_transcoded_movie.mp4}"