Skip to content

Instantly share code, notes, and snippets.

View jaredsinclair's full-sized avatar

Jared Sinclair jaredsinclair

View GitHub Profile
@jaredsinclair
jaredsinclair / gist:2204400
Created March 26, 2012 10:46 — forked from omz/gist:1102091
Creating arbitrarily-colored icons from a black-with-alpha master image (iOS)
// Usage example:
// input image: http://f.cl.ly/items/3v0S3w2B3N0p3e0I082d/Image%202011.07.22%2011:29:25%20PM.png
//
// UIImage *buttonImage = [UIImage ipMaskedImageNamed:@"UIButtonBarAction.png" color:[UIColor redColor]];
// .h
@interface UIImage (IPImageUtils)
+ (UIImage *)ipMaskedImageNamed:(NSString *)name color:(UIColor *)color;
@end
@jaredsinclair
jaredsinclair / gist:6b608ea1a557d81a4b8e
Created September 25, 2014 23:44 — forked from steipete/gist:d76549ec262430354e7c
Maximum Warning Overdrive
-Weverything -Wcast-align -Wmissing-declarations -Wmissing-prototypes -Woverlength-strings -Wshadow -Wundeclared-selector -Wunreachable-code -Wformat=2 -Woverriding-method-mismatch -Wno-objc-missing-property-synthesis -Wno-unused-parameter -Wno-covered-switch-default -Wno-direct-ivar-access -Wno-assign-enum -Wno-float-equal -Wno-switch-enum -Wno-implicit-retain-self -Wno-vla -Wno-pedantic -Wno-explicit-ownership-type -Wno-bad-function-cast -Wno-documentation-unknown-command -Wno-packed
@jaredsinclair
jaredsinclair / set-build-number.sh
Last active January 1, 2020 15:41
Git-friendly run script for automated build numbering in Xcode
# Set the build number to the current git commit count.
#
# Permanent home:
# https://gist.github.com/jaredsinclair/af6898f93674ee5923f3
#
# Based on: http://w3facility.info/question/how-do-i-force-xcode-to-rebuild-the-info-plist-file-in-my-project-every-time-i-build-the-project/
# Updated with dSYM handling from http://yellowfeather.co.uk/blog/auto-incrementing-build-number-in-xcode-revisited/
git=`sh /etc/profile; which git`
appBuild=`"$git" rev-list HEAD --count`
+ (NSString*)stringWithNewUUID {
CFUUIDRef uuidObj = CFUUIDCreate(nil);
NSString *newUUID = (__bridge_transfer NSString*)CFUUIDCreateString(nil, uuidObj);
CFRelease(uuidObj);
return newUUID;
}
@jaredsinclair
jaredsinclair / gist:7ec068ba302a8187c9a1
Last active August 29, 2015 14:17
Email Validation in Objective-C (based on emailregex.com)
static NSString * BLVFormFieldValidator_EmailRegex = @"(?i)(?:[a-z0-9!#$\%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$\%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)\\])";
@jaredsinclair
jaredsinclair / gist:fa72f0917c6a147b3c54
Last active August 29, 2015 14:22
Rough-n-dirty implementation of the unusual horizontal paging used by Twitter.app's inline promoted app cards.
typedef NS_ENUM(NSInteger, BLVScrollDirection) {
// These are by the content offset,
// not by the direction your finger moves.
BLVScrollDirection_RightToLeft,
BLVScrollDirection_LeftToRight
};
@interface BLVNonStandardPagingCalculation : NSObject
@property (nonatomic, assign) NSInteger centeredCardIndex; // Defaults to NSNotFound
@jaredsinclair
jaredsinclair / gist:4de506e108249f39b12d
Created August 22, 2015 16:41
Podfile post-install script for best-practice code signing settings.
post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if config.to_s == 'Beta'
config.build_settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] = 'iPhone Distribution'
elsif config.to_s == 'Release'
config.build_settings['CODE_SIGN_IDENTITY[sdk=iphoneos*]'] = 'iPhone Distribution'
end
end
end
@jaredsinclair
jaredsinclair / Warnings.xcconfig
Created July 5, 2016 04:34 — forked from steipete/Warnings.xcconfig
The warnings configuration we use in the PSPDFKit iOS framework - http://pspdfkit.com
//
// Warnings.xcconfig
//
// The list of warnings we (don’t) use, and the reasons why.
//
// :MARK: Warnings in use:
// :MARK: -everything
// We want the best possible diagnostics, so we simply enable everything that exists, and then opt–out of what doesn’t make sense for us.
//
// :MARK: - Warnings not to be promoted:
ACTION = build
AD_HOC_CODE_SIGNING_ALLOWED = NO
ALTERNATE_GROUP = staff
ALTERNATE_MODE = u+w,go-w,a+rX
ALTERNATE_OWNER = grantdavis
ALWAYS_SEARCH_USER_PATHS = NO
ALWAYS_USE_SEPARATE_HEADERMAPS = YES
APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer
APPLE_INTERNAL_DIR = /AppleInternal
APPLE_INTERNAL_DOCUMENTATION_DIR = /AppleInternal/Documentation
@jaredsinclair
jaredsinclair / NSString+HTML.swift
Created December 18, 2017 05:21
Convert HTML string to plain text (Swift version of MWFeedParser's utility)
/// Quick-n-dirty translation of MWFeedParser's algorithm from Objective-C to Swift
/// seealso: https://github.com/mwaterfall/MWFeedParser/blob/master/Classes/NSString%2BHTML.m
public extension NSString {
public func byConvertingHTMLToPlainText() -> String {
let stopCharacters = CharacterSet(charactersIn: "< \t\n\r\(0x0085)\(0x000C)\(0x2028)\(0x2029)")
let newLineAndWhitespaceCharacters = CharacterSet(charactersIn: " \t\n\r\(0x0085)\(0x000C)\(0x2028)\(0x2029)")
let tagNameCharacters = CharacterSet(charactersIn: "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ")