Skip to content

Instantly share code, notes, and snippets.

Ryan Maxwell ryanmaxwell

  • Auckland, New Zealand
Block or report user

Report or block ryanmaxwell

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ryanmaxwell
ryanmaxwell / ryan-objc.cfg
Last active Jun 26, 2019
Objective-C Uncrustify Config
View ryan-objc.cfg
#
# Uncrustify Configuration File
# File Created With UncrustifyX 0.2 (140)
#
# Alignment
# ---------
## Alignment
@ryanmaxwell
ryanmaxwell / blinds.lua
Last active Apr 30, 2019
Fibaro HC2 Scene for dimmer S2 switch button to trigger open/close/pause of multiple blinds in a room
View blinds.lua
--[[
%% properties
378 sceneActivation
%% weather
%% events
%% globals
--]]
function anyBlindIsClosed(blindIDs)
for index, blindID in ipairs(blindIDs) do
@ryanmaxwell
ryanmaxwell / TXLocation.h
Last active Dec 23, 2015
Mantle JSON Mapping Example
View TXLocation.h
@interface TXLocation : MTLModel <MTLJSONSerializing>
@property (strong, nonatomic, readonly) NSString *status;
@property (strong, nonatomic, readonly) NSNumber *sector;
@property (strong, nonatomic, readonly) NSString *macAddress;
@property (strong, nonatomic, readonly) NSNumber *facilityId;
@property (strong, nonatomic, readonly) NSNumber *departmentId;
@property (strong, nonatomic, readonly) NSNumber *mapId;
@property (strong, nonatomic, readonly) NSNumber *mapVersion;
@ryanmaxwell
ryanmaxwell / gist:6227531
Last active Dec 21, 2015
Useful utility method to get the most appropriate image resource from the main bundle for the device based on filename. Fills a need until the new asset packages in Xcode 5 is released.
View gist:6227531
+ (UIImage *)imageResource:(NSString *)name ofType:(NSString *)type {
NSString *systemVersion = UIDevice.currentDevice.systemVersion;
NSString *iOSMajorSystemVersion = (systemVersion.length) ? [NSString stringWithFormat:@"iOS%@", [systemVersion substringToIndex:1]] : @"iOS";
if (UIScreen.mainScreen.bounds.size.height == 568.0f) {
/* iPhone 5 */
NSString *iPhone5SystemVersionImageName = [NSString stringWithFormat:@"%@-%@-568h@2x", name, iOSMajorSystemVersion];
NSString *iPhone5SystemVersionImagePath = [NSBundle.mainBundle pathForResource:iPhone5SystemVersionImageName ofType:type];
View NSString+Comparisons.h
@interface NSString (Comparisons)
- (BOOL)containsString:(NSString *)substring;
- (BOOL)isSubstringOfString:(NSString *)string;
- (BOOL)isEqualToAnyOfStrings:(NSArray *)strings;
- (BOOL)isEqualToNoneOfStrings:(NSArray *)strings;
@end
@ryanmaxwell
ryanmaxwell / gist:4999567
Last active Dec 14, 2015
NSString+GroupedDelimitedString Category
View gist:4999567
#import <Foundation/Foundation.h>
@interface NSString (GroupedDelimitedString)
- (NSString *)stringByGroupingBySize:(NSInteger)groupSize withDelimiter:(NSString *)delimiter;
@end
@ryanmaxwell
ryanmaxwell / gist:1989630
Created Mar 6, 2012
Escape NSString so that it can be passed to webview
View gist:1989630
- (NSString *)stringByEscapingJSONReservedCharacters {
return [[[[[[[[self stringByReplacingOccurrencesOfString:@"\\\\" withString:@"☃"] /* \\ (single slash character) for snowman */
stringByReplacingOccurrencesOfString:@"\\n" withString:@"\\\\n"] /* \n for \\n */
stringByReplacingOccurrencesOfString:@"\\t" withString:@"\\\\t"] /* \t for \\t */
stringByReplacingOccurrencesOfString:@"\\b" withString:@"\\\\b"] /* \b for \\b */
stringByReplacingOccurrencesOfString:@"\\f" withString:@"\\\\f"] /* \f for \\f */
stringByReplacingOccurrencesOfString:@"\\r" withString:@"\\\\r"] /* \r for \\r */
stringByReplacingOccurrencesOfString:@"\\\"" withString:@"\\\\\""] /* \" for \\" */
stringByReplacingOccurrencesOfString:@"☃" withString:@"\\\\\\\\"]; /* snowman for \\\\ (single slash character) */
}
@ryanmaxwell
ryanmaxwell / gist:1983009
Created Mar 6, 2012
UIImage Resizing Utility Methods
View gist:1983009
+ (UIImage *)imageWithImage:(UIImage *)image scaledToSize:(CGSize)size {
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) {
UIGraphicsBeginImageContextWithOptions(size, NO, [[UIScreen mainScreen] scale]);
} else {
UIGraphicsBeginImageContext(size);
}
[image drawInRect:CGRectMake(0, 0, size.width, size.height)];
UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return newImage;
You can’t perform that action at this time.