Skip to content

Instantly share code, notes, and snippets.

@acoomans
acoomans / gist:87e791a0553c96d03340
Created August 2, 2012 23:01
Check method arguments type
BOOL supportedMethod = YES;
NSMethodSignature *methodSignature = [object methodSignatureForSelector:selector];
for (int i=0; i<[methodSignature numberOfArguments]; i++) {
if (
strcmp(@encode(id), [methodSignature getArgumentTypeAtIndex:i]) != 0 &&
strcmp(@encode(NSString*), [methodSignature getArgumentTypeAtIndex:i]) != 0
) {
supportedMethod = NO;
NSLog(@"NOT supportedMethod: %@", methodSignature);
return supportedMethod;
@acoomans
acoomans / CustomFilePicker.m
Last active October 13, 2015 15:18
Customize FilePicker private Controller by rerouting
#import <objc/message.h>
IMP tableView_cellForRowAtIndexPath = nil;
IMP viewDidAppear = nil;
CGFloat myMethodIMP(id self, SEL _cmd, UITableView *tableView, int section) {
// implementation ....
NSLog(@"%@", tableView);
NSLog(@"%d", section);
@acoomans
acoomans / twitter_oauth_token.py
Created February 24, 2013 02:52
Quickstart for authenticating and sending a message using python _twitter_oauth_.
# http://pypi.python.org/pypi/twitter_oauth/0.2.0
# pip install twitter_oauth
import twitter_oauth
print "remember to leave callback blank in twitter settings!!"
consumer_key = 'CONSUMER_KEY'
consumer_secret = 'CONSUMER_SECRET'
get_oauth_obj = twitter_oauth.GetOauth(consumer_key, consumer_secret)
@acoomans
acoomans / CPModelTestCase.h
Created February 24, 2013 02:54
Test case class for core data
//
// CPModelTestCase.h
// CoursePad
//
// Created by Arnaud Coomans on 16/01/13.
// Copyright (c) 2013 Archer. All rights reserved.
//
#import <SenTestingKit/SenTestingKit.h>
@acoomans
acoomans / UIViewController+KeyboardNotifications.h
Created March 7, 2013 01:06
Register UIViewController to listen to keyboard notifications
//
// UIViewController+KeyboardNotifications.h
//
//
// Created by Arnaud Coomans on 15/02/13.
// Copyright (c) 2013 Arnaud Coomans. All rights reserved.
//
#import <UIKit/UIKit.h>
@acoomans
acoomans / ViewControllerContainer.m
Last active December 14, 2015 15:08
Container view controller
#pragma mark - container view controller
- (CGRect)frameForContentViewController:(UIViewController*)contentViewController {
return self.view.bounds;
}
- (void)addContentViewController: (UIViewController*)contentViewController; {
[self addChildViewController:contentViewController];
contentViewController.view.frame = [self frameForContentViewController:contentViewController];
[self.view addSubview:contentViewController.view];
@acoomans
acoomans / sim-device.sh
Created March 12, 2013 23:53
Simulator version and device change scripts
#!/bin/sh
exec <"$0" || exit; read v; read v; exec /usr/bin/osascript - "$@"; exit
-- Your AppleScript here
on run argv
if (count argv) is 0 then
set DeviceName to "iPad"
else
set DeviceName to item 1 of argv
@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}"
@acoomans
acoomans / storyboardReplace.m
Last active March 29, 2026 01:56
Go straight to a view controller by replacing the window's root view controller (with storyboard)
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone" bundle:nil];
UIViewController *viewController = [storyboard instantiateViewControllerWithIdentifier:@"aaa"];
[UIView transitionFromView:src.view
toView:dst.view
duration:0.28
options:UIViewAnimationOptionTransitionFlipFromLeft
completion:^(BOOL finished) {
[[UIApplication sharedApplication].delegate window].rootViewController = dst;
@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 {