Skip to content

Instantly share code, notes, and snippets.

View barrettj's full-sized avatar

Barrett Jacobsen barrettj

View GitHub Profile
@barrettj
barrettj / gist:2367686
Created April 12, 2012 14:26
TextExpander Applescript to turn Methods into Declarations (from Clipboard contents)
set clipText to (the clipboard as string)
set theItems to paragraphs of clipText
set ret to ""
on replaceText(find, replace, subject)
set prevTIDs to text item delimiters of AppleScript
set text item delimiters of AppleScript to find
set subject to text items of subject
set text item delimiters of AppleScript to replace
@barrettj
barrettj / Example.m
Created April 21, 2012 13:51
Example of using BJImageCropper
- (void)displayCrop {
ImageCropViewController *crop = [[ImageCropViewController alloc] init];
NSMutableDictionary *imageInfo = [self getImageInfo:currentImage];
crop.image = [UIImage imageWithContentsOfFile:[imageInfo getStringSetting:@"Location" withDefault:@""]];
crop.cropSet = ^(CGRect newCrop, ImageCropViewController* imageCropView) {
NSMutableDictionary *imageInfo = [self getImageInfo:currentImage];
[imageInfo saveRectSetting:@"Crop" withValue:newCrop];
@barrettj
barrettj / gist:3403776
Created August 20, 2012 12:45
Nested BlockAlerts
BlockAlertView *alert = [BlockAlertView alertWithTitle:NSLocalizedString(@"FEEDBACK_PROBLEM_TITLE", nil) message:NSLocalizedString(@"FEEDBACK_PROBLEM_MESSAGE", nil)];
[alert setCancelButtonWithTitle:NSLocalizedString(@"Dismiss", nil) block:nil];
[alert addButtonWithTitle:NSLocalizedString(@"VIEW_HELP_BUTTON_TEXT", nil) block:^{
BlockAlertView *helpAlert = [BlockAlertView alertWithTitle:NSLocalizedString(@"HELP_TITLE", nil) message:NSLocalizedString(@"GOTALK_NOW_HELP_MESSAGE", nil)];
[helpAlert setCancelButtonWithTitle:@"Dismiss" block:nil];
[helpAlert addButtonWithTitle:NSLocalizedString(@"VIEW_OVERVIEW_BUTTON_TEXT", nil) block:^{
@barrettj
barrettj / gist:5420757
Created April 19, 2013 14:35
CGRectMakeWithDictionaryRepresentation
CGRect rect;
CGRectMakeWithDictionaryRepresentation((__bridge CFDictionaryRef)([NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"rect 1 of 500" ofType:@"plist"]]), &rect);
@barrettj
barrettj / gist:c662c2e646b7f8b75fa0
Created June 3, 2014 17:57
Custom Ternary Shorthand
import Cocoa
operator infix ~~ {}
@infix func ~~ (left: Any?, right: Any?) -> Any? {
if let temp = left {
return temp
}
if let temp = right {
@barrettj
barrettj / PopupViewController1.h
Created September 16, 2015 17:21
Demonstrating Table Issue with STPopup
//
// PopupViewController1.h
// STPopup
//
// Created by Kevin Lin on 11/9/15.
// Copyright (c) 2015 Sth4Me. All rights reserved.
//
#import <UIKit/UIKit.h>