Skip to content

Instantly share code, notes, and snippets.

@MattFoley
MattFoley / gist:cf49f4af2155aada6d52
Created July 25, 2014 15:47
Update CDM mapper to handle transformable core data attributes.
- (Class)expectedClassForObject:(NSManagedObject *)object andKey:(id)key
{
NSDictionary *attributes = [[object entity] attributesByName];
NSAttributeDescription *attributeDescription = [attributes valueForKey:key];
NSString *className = [attributeDescription attributeValueClassName];
if (!className) {
const char *className = [[object.entity managedObjectClassName] cStringUsingEncoding:NSUTF8StringEncoding];
const char *propertyName = [key cStringUsingEncoding:NSUTF8StringEncoding];
Class managedObjectClass = objc_getClass(className);
@MattFoley
MattFoley / gist:267c26b0a1892d4802ce
Created October 2, 2014 17:13
Install rabbitmq 2.7.1
cd $(brew --prefix)
git checkout b3fd8f3 /usr/local/Library/Formula/rabbitmq.rb
brew install rabbitmq
@MattFoley
MattFoley / gist:f6af9cf9d87c996fb5a5
Last active August 29, 2015 14:21
React Native Information
//Rather than defining containerRow as multiple hard coded elements:
containerRow {
backgroundcolor: #ffffff,
opacity 90%,
dropshadow: 4px color: #000000,
corner-radius: 10pt,
}
//We define those one use elements as classes, very simple building blocks:
containerCornerRadiusPrimary: {
@MattFoley
MattFoley / .md
Last active August 29, 2015 14:26
Upgrade to React Native head

Steps to upgrade to React Native head

  1. Delete your Derived Data and node_modules folders

  2. Reboot your computer dangling symlink

  3. Install io.js.

    nvm install iojs nvm alias default iojs

  4. Update brew

//RN attempts this @ ln686 of RCTConvert.m, imageWithContentsOfFile fails to load the image.
(lldb) po [UIImage imageWithContentsOfFile:@"file:///Users/tfallon/Library/Developer/CoreSimulator/Devices/E2A18017-6069-45C6-BFB2-814E62A3F6DA/data/Containers/Data/Application/3A2FBAD8-BCC9-417E-8644-FAD4551A681C/tmp/genImageFile.png"]
nil
//Image is loaded when I attempt this at a breakpoint on the same line.
(lldb) po [UIImage imageWithContentsOfFile:@"Users/tfallon/Library/Developer/CoreSimulator/Devices/E2A18017-6069-45C6-BFB2-814E62A3F6DA/data/Containers/Data/Application/3A2FBAD8-BCC9-417E-8644-FAD4551A681C/tmp/genImageFile.png"]
<UIImage: 0x7f9f9a41cef0>, {90, 90}
@MattFoley
MattFoley / gist:4945666
Created February 13, 2013 16:08
Helpful PCH Macros.
#define screenHeight() ([UIScreen mainScreen].bounds.size.height)
#define isPhoneFive() (screenHeight() == 568)
#define isOS6() ([[[UIDevice currentDevice] systemVersion]intValue] > 5.2)
#define UIInterfaceIdiomIsPad() (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define UIColorFromRGB(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
@MattFoley
MattFoley / gist:5222512
Created March 22, 2013 16:06
Literal Syntax Magic: Not only can literal syntax do assignment, creation, and re-assignment; it can also do addObject:
NSMutableArray *objects = [@[] mutableCopy];
NSObject *someObject = [NSObject new];
objects[objects.count] = object;
@MattFoley
MattFoley / Remove Webviews
Created April 25, 2013 15:00
Removing Webview Shadows.
- (void)removeShadows
{
self.opaque = NO;
self.backgroundColor = [UIColor clearColor];
for(UIView *view in self.subviews){
if ([view isKindOfClass:[UIImageView class]]) {
[view removeFromSuperview];
}
if ([view isKindOfClass:[UIScrollView class]]) {
@MattFoley
MattFoley / gist:5601191
Created May 17, 2013 18:58
UIColorFromRGB, call like "UIColorFromRGB(0xFFFFFF)"
//Function to convert RGB values into Hexadecimal/Base16
#define UIColorFromRGB(rgbValue) [UIColor \
colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 \
green:((float)((rgbValue & 0xFF00) >> 8))/255.0 \
blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]