Skip to content

Instantly share code, notes, and snippets.

View alanf's full-sized avatar

Alan Fineberg alanf

View GitHub Profile
@alanf
alanf / XCTestCase+DebuggingAdditions.m
Last active April 21, 2016 00:22
XCTestCase (Debugging)
#import <objc/runtime.h>
@implementation XCTestCase (Debugging)
+ (XCTestSuite *)debug_defaultTestSuite {
NSString *className = NSStringFromClass(self);
// Only run tests that start with SQR.
if ([className rangeOfString:@"SQR"].location != 0) {
return nil;
@alanf
alanf / ViewController.swift
Created August 2, 2015 18:14
Simple Quantizer
//
// ViewController.swift
// quant
//
import Foundation
import UIKit
@objc class ViewController : UIViewController {
// Magic! Just specify the type and the function on the right hand side will magically get you the correct view from the xib.
let noteView: AlterationReceiptNoteView = ViewUtil.viewFromNib(.JPAlterations)
public enum XIBFileName : String {
case Receipt = "ReceiptViewController"
case USAlterations = "AlterationReceiptUSView"
case JPAlterations = "AlterationReceiptsJapanView"
}
public class func viewFromNib<T>(nibName: XIBFileName) -> T {
@alanf
alanf / .vimrc
Created June 17, 2015 18:00
vimrc
set nocompatible
filetype off
" filetype indent plugin on
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
Plugin 'surround.vim'
Plugin 'fatih/vim-go'
[
{
"directory": "/Users/af/Development/lintapp",
"command": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -x objective-c -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-cache-path=/Users/af/Library/Developer/Xcode/DerivedData/ModuleCache -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -
PATH=$PATH:'~/bin/'
PATH=$PATH:'/usr/bin/'
echo $PATH
hash oclint &> /dev/null
if [ $? -eq 1 ]; then
echo >&2 "oclint not found, analyzing stopped"
exit 1
fi
cd ${SRCROOT}
rm compile_commands.json
/Users/af/Development/xctool/xctool.sh -scheme lintapp -project lintapp.xcodeproj clean
/Users/af/Development/xctool/xctool.sh -scheme lintapp -project lintapp.xcodeproj -reporter json-compilation-database:compile_commands.json build
oclint-json-compilation-database | sed 's/\(.*\.\m\{1,2\}:[0-9]*:[0-9]*:\)/\1 warning:/'
[
{
"command" : "\/Applications\/Xcode.app\/Contents\/Developer\/Toolchains\/XcodeDefault.xctoolchain\/usr\/bin\/clang -x objective-c -arch armv7 -fmessage-length=0 -fdiagnostics-show-note-include-stack -fmacro-backtrace-limit=0 -std=gnu99 -fobjc-arc -fmodules -fmodules-cache-path=\/Users\/af\/Library\/Developer\/Xcode\/DerivedData\/ModuleCache -Wno-trigraphs -fpascal-strings -O0 -Wno-missing-field-initializers -Wno-missing-prototypes -Werror=return-type -Wno-implicit-atomic-properties -Werror=deprecated-objc-isa-usage -Werror=objc-root-class -Wno-receiver-is-weak -Wno-arc-repeated-use-of-weak -Wduplicate-method-match -Wno-missing-braces -Wparentheses -Wswitch -Wunused-function -Wno-unused-label -Wno-unused-parameter -Wunused-variable -Wunused-value -Wempty-body -Wuninitialized -Wno-unknown-pragmas -Wno-shadow -Wno-four-char-constants -Wno-conversion -Wconstant-conversion -Wint-conversion -Wbool-conversion -Wenum-conversion -Wshorten-64-to-32 -Wpointer-sign -Wno-newline-eof -Wno-selector -Wno-strict-sel
cd ${SRCROOT}
rm compile_commands.json
/Users/af/Development/xctool/xctool.sh -scheme lintapp -project lintapp.xcodeproj -reporter json-compilation-database:compile_commands.json clean
/Users/af/Development/xctool/xctool.sh -scheme lintapp -project lintapp.xcodeproj -reporter json-compilation-database:compile_commands.json build
oclint-json-compilation-database | sed 's/\(.*\.\m\{1,2\}:[0-9]*:[0-9]*:\)/\1 warning:/'
- (void)reloadInterfaceFromTextField;
{
self.keyboardAttributes = [(id)self.textField performSelectorIfResponds:SDProtocolSelector(SQCustomKeyboardTextField, keyboardAttributes)] ?: [self defaultKeyboardAttributes];
NSString *returnKeyTitle = [self _returnKeyTitle];
[self.currentContentView.returnButton setTitle:returnKeyTitle forState:UIControlStateNormal];
if (returnKeyTitle.length) {
// Sometimes the title will be cleared for visual effect, in which case we won't want to delete the accessibility hint from the xib.
self.currentContentView.returnButton.accessibilityLabel = returnKeyTitle;
}