Skip to content

Instantly share code, notes, and snippets.

View gfontenot's full-sized avatar
football

Gordon Fontenot gfontenot

football
View GitHub Profile
@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
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 {
@nicklockwood
nicklockwood / gist:9605636
Last active December 11, 2019 15:17
Singleton Category implementation
Singleton.h
-------------
@protocol Singleton
@optional
+ (instancetype)sharedInstance;
@end
// 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)
/**
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.
@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"
@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;
@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
@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' | \

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>