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>
@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;
// 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)
@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"
@nicklockwood
nicklockwood / gist:9605636
Last active December 11, 2019 15:17
Singleton Category implementation
Singleton.h
-------------
@protocol Singleton
@optional
+ (instancetype)sharedInstance;
@end
enum Either<A, B> {
case Left(A)
case Right(B)
}
func isLeft<A,B>(it : Either<A,B>) -> Bool {
switch it { case .Left: return true; case .Right: return false }
}
func isRight<A,B>(it : Either<A,B>) -> Bool {
@tkersey
tkersey / xcbuild-debugging-tricks.md
Created February 3, 2018 23:10 — forked from ddunbar/xcbuild-debugging-tricks.md
Xcode new build system debugging tricks

New Build System Tricks

Command Line

# enable internal menu
defaults write com.apple.dt.Xcode ShowDVTDebugMenu -bool YES

alias xcbuild=$(xcode-select -p)/../SharedFrameworks/XCBuild.framework/Versions/A/Support/xcbuild
/**
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.