Skip to content

Instantly share code, notes, and snippets.

View mike3k's full-sized avatar

Mike Cohen mike3k

View GitHub Profile
@mike3k
mike3k / main.m.m
Created June 21, 2011 03:13
Autorelease pool
#import <UIKit/UIKit.h>
#import "CoLocAppDelegate.h"
int main(int argc, char *argv[])
{
int retVal = 0;
NSAutoreleasePool *ap = [[NSAutoreleasePool alloc] init];
retVal = UIApplicationMain(argc, argv, nil, NSStringFromClass([CoLocAppDelegate class]));
[ap release];
@mike3k
mike3k / chk_enrypt.c
Created June 19, 2012 20:15
Check for encrypted iOS binary
#import <dlfcn.h>
#import <mach-o/loader.h>
/* The encryption info struct and constants are missing from the iPhoneSimulator SDK, but not from the iPhoneOS or
* Mac OS X SDKs. Since one doesn't ever ship a Simulator binary, we'll just provide the definitions here. */
#if TARGET_IPHONE_SIMULATOR && !defined(LC_ENCRYPTION_INFO)
#define LC_ENCRYPTION_INFO 0x21
struct encryption_info_command {
@mike3k
mike3k / launchparent.m
Created July 5, 2012 21:34
Launch parent from login helper
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
NSString *myPath = [[NSBundle mainBundle] bundlePath];
NSLog(@"Helper app at %@",myPath);
for (int i=0; i<4; ++i) {
myPath = [myPath stringByDeletingLastPathComponent];
}
NSLog(@"Launching %@",myPath);
[[NSWorkspace sharedWorkspace] launchApplication: myPath];
@mike3k
mike3k / .bashrc
Created December 1, 2012 18:50
My .bashrc
export DISPLAY=:0.0
export LC_ALL=C
export PS1="\e[0;36m\H:\W\e[0m (\!)\\$ "
append_path()
{
if ! eval test -z "\"\${$1##*:$2:*}\"" -o -z "\"\${$1%%*:$2}\"" -o -z "\"\${$1##$2:*}\"" -o -z "\"
\${$1##$2}\"" ; then
eval "$1=\$$1:$2"
fi
[user]
name = Mike Cohen
email = [email protected]
[core]
excludesfile = /Users/mike/.gitignore_global
[difftool "sourcetree"]
cmd = opendiff \"$LOCAL\" \"$REMOTE\"
path =
[mergetool "sourcetree"]
cmd = /Applications/SourceTree.app/Contents/Resources/opendiff-w.sh \"$LOCAL\" \"$REMOTE\" -ancestor \"$BASE\" -merge \"$MERGED\"
@mike3k
mike3k / .lldbinit
Created January 11, 2013 20:06
My favorite LLDB macro, thanks to Rob Mayoff via NSHipster
command regex rd 's/^[[:space:]]*$/po [[[UIApplication sharedApplication] keyWindow] recursiveDescription]/' 's/^(.+)$/po [%1 recursiveDescription]/'
@mike3k
mike3k / PDFView.m
Created March 20, 2013 04:36
Most frightening piece of code I've ever seen
- (void)
dealloc
{
// because of TiledLayer ( which draws in a separate threads) and propbably a bug in iOS dealloc is called twice.
// make sure it will execute once in our class
if ( _deallocCalled )
return;
_deallocCalled = YES;
@mike3k
mike3k / singleton
Created July 25, 2013 00:54
SharedInstance
+ (instancetype)sharedInstance {
static SingletonClass *shared = nil;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
shared = [[[self class] alloc] init];
});
return shared;
}
@mike3k
mike3k / git_completion.bash
Created July 30, 2013 02:20
A nice set of completions for git.
#!bash
#
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#
@mike3k
mike3k / git_completion.bash
Created July 30, 2013 02:20
A nice set of completions for git.
#!bash
#
# bash/zsh completion support for core Git.
#
# Copyright (C) 2006,2007 Shawn O. Pearce <[email protected]>
# Conceptually based on gitcompletion (http://gitweb.hawaga.org.uk/).
# Distributed under the GNU General Public License, version 2.0.
#
# The contained completion routines provide support for completing:
#