Skip to content

Instantly share code, notes, and snippets.

View mike3k's full-sized avatar

Mike Cohen mike3k

View GitHub Profile
[user]
name = Mike Cohen
email = mike3k@gmail.com
[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 / .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
@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 / 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 / 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 / MarchingAntsView.plain_text
Created May 27, 2011 19:56
View that implements marching ants selection
@interface MarchingAntsView : NSView {
NSPoint clickLoc;
NSRect selection;
}
@end
@implementation MarchingAntsView
@mike3k
mike3k / Sugar Rush Link.m
Created May 17, 2011 00:54
App store link for sugar rush
@mike3k
mike3k / Share Items.m
Created May 11, 2011 01:33
Use ShareKit for individual items
- (IBAction)tweet:(id)sender
{
SHKItem *aTweet = [SHKItem text: [NSString stringWithFormat:
@"I just scored %@ in @SugarRushApp! How high can you jump? http://sugarrush-app.com/",
[UserSettings get].formattedScore]];
[SHKTwitter shareItem:aTweet];
}
- (IBAction)facebook:(id)sender
{
@mike3k
mike3k / set size.m
Created January 21, 2011 02:02
use sizeOfString to resize a view
CGSize constraint = CGSizeMake(200000.0, 10.0);
CGSize size = [sourceLabel.text sizeWithFont:[UIFont italicSystemFontOfSize:7.0] constrainedToSize:constraint
lineBreakMode:UILineBreakModeTailTruncation];
sourceLabel.frame = CGRectMake(318.0 - size.width,
quantityPickerView.frame.origin.y,
size.width,
size.height);