Skip to content

Instantly share code, notes, and snippets.

View robertjpayne's full-sized avatar

Robert Payne robertjpayne

View GitHub Profile
let _name = Observable<String>("Hello")
var name: ObservableOf<String> {
return ObservableOf(self._name)
}
var scope: NSString? = "Yeehaw"
self.name.observe { (oldValue, newValue) -> Void in
print("\(oldValue) => \(newValue)")
}.scopeTo(scope!)
self._name.value = "Payne"
@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
@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 / 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 / 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 / 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 / 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
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 / 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>
@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