This file contains 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
- (void)textViewDidChange:(UITextView *)textView { | |
CGRect line = [textView caretRectForPosition: | |
textView.selectedTextRange.start]; | |
CGFloat overflow = line.origin.y + line.size.height | |
- ( textView.contentOffset.y + textView.bounds.size.height | |
- textView.contentInset.bottom - textView.contentInset.top ); | |
if ( overflow > 0 ) { | |
CGPoint offset = textView.contentOffset; | |
offset.y += overflow + 7; | |
[UIView animateWithDuration:.2 animations:^{ |
This file contains 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
//place a button somewhere and add a target with selector showMusic: | |
//.... | |
-(void)showMusic:(UIButton *)aButtonPlacedSomewhere{ | |
MPMediaPickerController* picker=[[MPMediaPickerController alloc] initWithMediaTypes:MPMediaTypeMusic]; | |
picker.showsCloudItems=YES; | |
picker.allowsPickingMultipleItems=YES; | |
picker.delegate=self; | |
[self presentViewController:picker animated:NO completion:NULL]; | |
} |
This file contains 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
// cheat in the game 2048 | |
// cheat is not funny so don't compile to cheat | |
// so why I did? | |
// what is funny is to make the cheat, not to play with it =) | |
// how to get headers of App Store Apps ? | |
// https://github.com/MP0w/dumpdecrypted | |
@interface ViewController: NSObject | |
- (void)cheat; |
This file contains 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
// I will not tell you why I made this, or you would think I am mad... | |
// But may be useful in future | |
// | |
// Yes is the equivalent of super.. but it's not allowed in categories | |
+ (void)load{ | |
method_exchangeImplementations(class_getInstanceMethod(self, @selector(setDelegate:)), class_getInstanceMethod(self, @selector(hooked_setDelegate:))); // hook the setDelegate to hook it (later) | |
} |
This file contains 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
knownhosts () { | |
cp ~/.ssh/known_hosts ~/.ssh/known_hosts_$(date +%Y%m%d-%H%M%S) ; | |
sed -e "$1d" ~/.ssh/known_hosts > ~/.ssh/known_hosts_new ; | |
mv ~/.ssh/known_hosts_new ~/.ssh/known_hosts ; | |
chmod 644 ~/.ssh/known_hosts | |
} |
This file contains 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
// | |
// ViewController.swift | |
// testSwift | |
// | |
// Created by Alex Manzella on 02/06/14. | |
// Copyright (c) 2014 mpow. All rights reserved. | |
// | |
import UIKit |
This file contains 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
// on iOS 7 present a popover from an UIBarButtonItem is buggy | |
// the arrow is not uncentered | |
// as always iOS 7 is broken setImageEdgeInsets | |
// try that | |
// the fix consist in setImageEdgeInsets: | |
- (UIBarButtonItem *)rightItem{ | |
if (GBIsNativeiPad() && GBIsIOS7()) { // ios 7 sucks |
This file contains 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
// | |
// main.m | |
// swizzle | |
// | |
// Created by Alex Manzella on 04/07/14. | |
// Copyright (c) 2014 mpow. All rights reserved. | |
// | |
#import <Foundation/Foundation.h> | |
#import <objc/runtime.h> |
This file contains 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
// Usage example : [self addConstraintsWithVisualFormat:@"V:|-0-[myAwesomeView]-0-|", self.awesome, nil]; | |
// no need to use underscore for property | |
// Actually would break with priority annotations but who care! It's just an experiment | |
// Not using NSDictionaryOfVariableBindings(...) to have easy use also in swift | |
- (void)addConstraintsWithVisualFormat:(NSString *)formatString,... NS_REQUIRES_NIL_TERMINATION { | |
va_list args; | |
va_start(args, formatString); | |
NSString *pattern = @"\\[(.*?)\\]"; |
This file contains 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
app = [[SBApplicationController sharedInstance] applicationWithBundleIdentifier:@"com.apple.mobilesafari"] | |
appIcon = [[SBApplicationIcon alloc] initWithApplication:app] | |
iconView = [[SBIconView alloc] init]; | |
iconView.icon = appIcon; | |
iconController = choose(SBIconController)[0] | |
iconView.delegate = iconController | |
[iconController _revealMenuForIconView:iconView presentImmediately:1] |
OlderNewer