Skip to content

Instantly share code, notes, and snippets.

View swizzlr's full-sized avatar

Thomas Catterall swizzlr

View GitHub Profile
@swizzlr
swizzlr / Button.swift
Created January 30, 2015 15:23
Statically typed alternatives to delegates, using the full power of Swift
struct Touch { }
struct Image { }
public final class Button {
public enum State { case Enabled, Disabled, Pressed }
public struct DynamicButtonConfiguration {
let buttonWasPressed: (button: Button, touch: Touch) -> ()
let imageForButtonState: (buttonState: State) -> (Image)
}
@swizzlr
swizzlr / CommonWarnings.xcconfig
Last active August 29, 2015 14:19
Pixable Warnings and Errors
// Warnings
WARNING_CFLAGS = -Weverything -Wno-error-auto-import -Wno-error-documentation-unknown-command -Wno-error-super-class-method-mismatch -Wno-error-incomplete-module -Wno-objc-missing-property-synthesis -Wno-gnu -Wno-error-undef -Wno-error-receiver-is-weak -Wno-error-missing-variable-declarations -Wno-error-objc-interface-ivars -Wno-error-documentation
GCC_WARN_PEDANTIC = YES
GCC_TREAT_WARNINGS_AS_ERRORS = YES
CLANG_WARN_DOCUMENTATION_COMMENTS = YES
CLANG_WARN_EMPTY_BODY = YES
GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES
GCC_WARN_SHADOW = YES
CLANG_WARN_BOOL_CONVERSION = YES
@swizzlr
swizzlr / moya-patch.diff
Created August 22, 2015 22:02
Small patch for Moya in Swift 2.
diff --git a/vendor/Moya/Moya/ReactiveCocoa/RACSignal+Moya.swift b/vendor/Moya/Moya/ReactiveCocoa/RACSignal+Moya.swift
index faabbf4..55d0420 100755
--- a/vendor/Moya/Moya/ReactiveCocoa/RACSignal+Moya.swift
+++ b/vendor/Moya/Moya/ReactiveCocoa/RACSignal+Moya.swift
@@ -67,21 +67,20 @@ public extension RACSignal {
/// Maps data received from the signal into a JSON object. If the conversion fails, the signal errors.
public func mapJSON() -> RACSignal {
- return tryMap({ (object, error) -> AnyObject! in
+ return tryMap({ (object, retError) -> AnyObject! in
@swizzlr
swizzlr / TestRealm.swift
Created September 2, 2015 14:40
Isolate those realms
// Creates a new in memory realm for testing
internal func NewTestRealm() -> Realm {
let idString = NSUUID().UUIDString
let config = Realm.Configuration(inMemoryIdentifier: idString)
return try! Realm(configuration: config)
}
import RealmSwift
import Foundation
@swizzlr
swizzlr / literalcolor.swift
Created October 14, 2015 13:26
Literal Colors from hex values
public final class LiteralColor: UIColor, IntegerLiteralConvertible {
public typealias IntegerLiteralType = Int
public init(integerLiteral value: Int) {
let netHex = value
let red = (netHex >> 16) & 0xff
let green = (netHex >> 8) & 0xff
let blue = netHex & 0xff
assert(red >= 0 && red <= 255, "Invalid red component")
assert(green >= 0 && green <= 255, "Invalid green component")
assert(blue >= 0 && blue <= 255, "Invalid blue component")
@swizzlr
swizzlr / gist:5384259
Created April 14, 2013 21:22
libpebble.a, hex dumped. Interesting stuff here.
!<arch>
/ 1365768839 0 0 0 5378 `
≈òòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòòanimation_initanimation_set_delayanimation_set_durationanimation_set_curveanimation_set_handlersanimation_set_implementationanimation_get_contextanimation_sc
@swizzlr
swizzlr / AFHTTPRequestOperation+JLPOperationDidSucceed.h
Created July 12, 2013 16:02
Convenient keypath for finding whether a request completed successfully.
//
// AFHTTPRequestOperation+JLPOperationDidSucceed.h
//
// Created by @swizzlr on 11/07/2013.
// BSD two clause license
//
@class AFHTTPRequestOperation;
@interface AFHTTPRequestOperation (JLPOperationDidSucceed)
//Do whatever you want with this except apply a GPL license to it.
//credit to @mattt for the below ifndef
//make sure you only give it things that respond to "Frame" and return a CGRect
@class NSArray;
#ifndef NS_ENUM
#define NS_ENUM(_type, _name) enum _name : _type _name; enum _name : _type

Hi there,

So you want to try out my sweet new change to Cocoapods?

You need to go to a working directory to clone my fork:

git clone https://github.com/swizzlr/CocoaPods.git

and cd CocoaPods. Then

#!!! last updated 11/12/2013. git 1.8.5, BBEdit 10.5, OS 10.9, ruby 2, Xcode 5 !!!#

#Long Operations ##Dropbox and Sync https://www.dropbox.com/downloading

##Homebrew (req for RVM)

ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go/install)"