Skip to content

Instantly share code, notes, and snippets.

View gfontenot's full-sized avatar
football

Gordon Fontenot gfontenot

football
View GitHub Profile
static id _commonInit(MyView *self)
{
// common init stuff like so...
self.opaque = YES;
self->_scale = 1.0;
return self;
}
- initWithFrame:(CGRect)frame;
@subdigital
subdigital / test.rb
Created October 22, 2012 13:05
Running objective-c tests from the command line (with color)
# based on https://gist.github.com/3349345
# Thanks, @alloy!
#
# To get your project ready for this, you'll have to create a scheme for your unit test project, make sure run is checked in
# the build step, and then delete the Test Host setting.
# Also, make sure you have the colored and open4 gems installed.
require 'rubygems'
require 'colored'
require 'pathname'

Useful Vim mappings

...you didn't know you wanted

Convert Ruby 1.8 to 1.9 hash syntax

nnoremap <Leader>: :%s/:\([^ ]*\)\(\s*\)=>/\1:/gc<CR>
@mattt
mattt / uiappearance-selector.md
Last active March 19, 2024 12:52
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \
@ZevEisenberg
ZevEisenberg / fixXcode.sh
Last active January 6, 2024 07:31
Function to fix Xcode’s code snippets library by replacing it with the one from the ZevEisenberg/ios-convenience git repo
function fixXcode
{
pushd > /dev/null
cd
xcodepath=`xcode-select --print-path`/..
destination=$xcodepath/Frameworks/IDEKit.framework/Versions/A/Resources/SystemCodeSnippets.codesnippets
shouldRelaunchXcode=false
if [[ `osascript -e 'tell app "System Events" to count processes whose name is "Xcode"'` == 1 ]]; then
@alloy
alloy / gist:5850206
Last active December 18, 2015 21:49
Meta alert: A Kiwi matcher that allows you to define custom matchers with one block instead of subclassing KWMatcher.
#import "KWMatcher.h"
typedef BOOL (^FTKiwiCustomMatcherBlock)(id subject);
@interface FTKiwiCustomBlockMatcher : KWMatcher
// Your custom matcher block will receive the expectation ‘subject’ and must
// return `YES` if the expaction passes or `NO` if it fails.
- (void)be:(FTKiwiCustomMatcherBlock)block;
@shepting
shepting / YMKeyboardLayoutHelperView.m
Last active March 22, 2016 02:50
A great little helper for handling keyboard animations nicely. Just put this view at the bottom vertically of your views and it will move everything else up and down for you.
//
// YMKeyboardLayoutHelperView.m
// ios-chat
//
// Created by Steven Hepting on 7/17/13.
// Copyright (c) 2013 Yammer. All rights reserved.
//
#import "YMKeyboardLayoutHelperView.h"
#import "UIView+LayoutAdditions.h"
/**
Provides the ability to verify key paths at compile time.
If "keyPath" does not exist, a compile-time error will be generated.
Example:
// Verifies "isFinished" exists on "operation".
NSString *key = SQKeyPath(operation, isFinished);
// Verifies "isFinished" exists on self.
// http://stackoverflow.com/a/19277383
//
- (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) {
// We are at the bottom of the visible text and introduced a line feed, scroll down (iOS 7 does not do it)
@nicklockwood
nicklockwood / gist:9605636
Last active December 11, 2019 15:17
Singleton Category implementation
Singleton.h
-------------
@protocol Singleton
@optional
+ (instancetype)sharedInstance;
@end