Skip to content

Instantly share code, notes, and snippets.

View robertjpayne's full-sized avatar

Robert Payne robertjpayne

View GitHub Profile
@robertjpayne
robertjpayne / Uncrustify Config
Created August 18, 2011 20:33
Xcode Run Uncrustify
#
# uncrustify config file for objective-c and objective-c++
#
indent_with_tabs = 2 # 1=indent to level only, 2=indent with tabs
output_tab_size = 4 # new tab size
indent_columns = output_tab_size
indent_label = 2 # pos: absolute col, neg: relative column
indent_align_assign = FALSE
@robertjpayne
robertjpayne / NSManagedObjectArchiving.h
Created October 29, 2011 10:28
NSManagedObject Archiving and Unarchiving
#import <Foundation/Foundation.h>
@interface NSManagedObjectArchiver : NSObject
/*
* Takes a NSManagedObject and converts it to a NSData archive - it traverses all relationships ( including circular ) and archives it
*/
+ (NSData *)archivedDataWithRootObject:(NSManagedObject *)pObject;
@end
@robertjpayne
robertjpayne / DNRBoxBlur.h
Created October 1, 2013 07:54
Speedup ios-realtimeblur
//
// DRNBoxBlur.h
// LiveBlur
//
// Created by Robert Payne on 1/10/13.
// Copyright (c) 2013 Zwopple Limited. All rights reserved.
//
#import <Foundation/Foundation.h>
require File.expand_path('../websocket_handler.rb', __FILE__)
class Server < Reel::Server
include Celluloid::Logger
def initialize(host = '0.0.0.0', port = (ENV['PORT'] || 5000).to_i)
super(host, port, &method(:on_connection))
end
def on_connection(connection)
@robertjpayne
robertjpayne / example.rb
Created December 29, 2013 15:40
Make redis-rb play nice with Celluloid
require 'celluloid'
require 'celluloid/io'
require 'celluloid/redis'
class CelluloidRedisClient < ::Redis::Client
def initialize(opts={})
@terminated = false
super
end
@robertjpayne
robertjpayne / UIView+MasonryTagging.h
Created April 25, 2014 01:55
Tagging system for Masonry
#import <UIKit/UIKit.h>
#import <Masonry/Masonry.h>
@interface UIView (MasonryTagging)
- (void)prepareConstraintsWithTag:(NSString *)tag block:(void (^)(MASConstraintMaker *make))block;
- (void)removePreparedConstraintsWithTag:(NSString *)tag;
- (void)installConstraintsWithTag:(NSString *)tag;
- (void)installConstraintsWithTag:(NSString *)tag recursive:(BOOL)recursive;
- (void)uninstallConstraintsWithTag:(NSString *)tag;
@robertjpayne
robertjpayne / SwiftStaticCompile.rb
Last active April 23, 2017 15:40
A ruby function to generate a static library + clang module from a single Swift source file
require "Subprocess"
require "tmpdir"
#
# Currently will only convert a single swift code file into a static library
# and cannot include any Objective-C code.
#
# Usage: generate("/path/to/MyCode.swift", :ios)
#
def generate(file, platform, dst=nil)
@robertjpayne
robertjpayne / RCTSwiftBridgeModule.h
Last active January 17, 2024 11:43
React Native - Swift Native Modules
#import <Foundation/Foundation.h>
#import "RCTBridgeModule.h"
#define RCT_EXTERN_MODULE(objc_name, objc_supername) \
RCT_EXTERN_REMAP_MODULE(objc_name, objc_name, objc_supername)
#define RCT_EXTERN_REMAP_MODULE(js_name, objc_name, objc_supername) \
objc_name : objc_supername \
@end \
@interface objc_name (RCTExternModule) <RCTBridgeModule> \
@robertjpayne
robertjpayne / Example.scs
Last active August 29, 2015 14:20
SnapKit Constraint Sheets
@loginViewController {
@formView {
width == ^ - 32.0
centerX == ^
centerY == ^ + 16.0
bottom <= ^ - 16.0
@emailField {
top.left.right == ^
@robertjpayne
robertjpayne / AppDelegate.swift
Last active August 29, 2015 14:21
Media Query Kit
//
// AppDelegate.swift
// MediaQueryKit
//
// Created by Robert Payne on 21/05/15.
// Copyright (c) 2015 Zwopple Limited. All rights reserved.
//
import UIKit