Skip to content

Instantly share code, notes, and snippets.

View jspahrsummers's full-sized avatar

Justin Spahr-Summers jspahrsummers

View GitHub Profile
@jspahrsummers
jspahrsummers / errors.txt
Last active August 29, 2015 14:13
swiftc error “Global is external, but doesn't have external or weak linkage!”
CompileSwift normal x86_64 /Users/justin/GitHub/Mac/Carthage.checkout/ReactiveCocoa/ReactiveCocoa/Swift/Property.swift
cd /Users/justin/GitHub/Mac/Carthage.checkout/ReactiveCocoa
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift -frontend -c /Users/justin/GitHub/Mac/Carthage.checkout/ReactiveCocoa/ReactiveCocoa/Swift/Identity.swift /Users/justin/GitHub/Mac/Carthage.checkout/ReactiveCocoa/ReactiveCocoa/Swift/TupleExtensions.swift /Users/justin/GitHub/Mac/Carthage.checkout/ReactiveCocoa/ReactiveCocoa/Swift/OptionalExtensions.swift /Users/justin/GitHub/Mac/Carthage.checkout/ReactiveCocoa/ReactiveCocoa/Swift/Errors.swift /Users/justin/GitHub/Mac/Carthage.checkout/ReactiveCocoa/ReactiveCocoa/Swift/Event.swift /Users/justin/GitHub/Mac/Carthage.checkout/ReactiveCocoa/ReactiveCocoa/Swift/Disposable.swift /Users/justin/GitHub/Mac/Carthage.checkout/ReactiveCocoa/ReactiveCocoa/Swift/FoundationExtensions.swift /Users/justin/GitHub/Mac/Carthage.checkout/ReactiveCocoa/Reac
@jspahrsummers
jspahrsummers / iflet.m
Last active August 29, 2015 14:16 — forked from cdzombak/iflet.m
#import <Foundation/Foundation.h>
#define iflet(LHS, RHS) \
for (id obj_ = (RHS); obj_ != nil;) \
for (LHS = (obj_ ?: (RHS)); obj_ != nil; obj_ = nil)
int main(int argc, char *argv[]) {
@autoreleasepool {
NSString *x = nil;
NSString *y = @"y";
@jspahrsummers
jspahrsummers / transcript.md
Last active September 12, 2015 15:14
Excerpt from https://reactivex.slack.com about API design, especially as it relates to RAC

carlossless [09:50] So anyone used RxSwift? I’m wondering what are your thoughts and opinions vs RAC3.

jspahrsummers [10:00] @carlossless: https://github.com/ReactiveCocoa/ReactiveCocoa/blob/07813339d3c44aa02fb1b71777baa4ede0f0f77a/README.md#how-does-reactivecocoa-relate-to-rx

carlossless [10:13] Yeah, I was looking for a more practical point of view but even so. RxSwift has UI bindings, it follows the haskell naming for most transformation and composition functions ​map​, ​filter​ etc. rather than ​select​, ​where​.

carlossless [10:14]

data Tuple a b c d =
OneTuple a |
TwoTuple a b |
ThreeTuple a b c |
FourTuple a b c d
tuple1 :: Tuple a b c d -> Maybe a
tuple1 (OneTuple a) = Just a
tuple1 (TwoTuple a b) = Just a
tuple1 (ThreeTuple a b c) = Just a
data List a =
Nil |
Cons a (List a)
listLength :: Num b => List a -> b
listLength Nil = 0
listLength (Cons x xs) = 1 + listLength xs
listHead :: List a -> a
listHead (Cons x xs) = x
@jspahrsummers
jspahrsummers / gist:947835
Created April 29, 2011 04:27
Clang ivar write -O0
.section __TEXT,__text,regular,pure_instructions
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
.section __TEXT,__const_coal,coalesced
.section __TEXT,__picsymbolstub4,symbol_stubs,none,16
.section __TEXT,__StaticInit,regular,pure_instructions
.syntax unified
.section __TEXT,__text,regular,pure_instructions
.align 2
.code 16
@jspahrsummers
jspahrsummers / gist:947836
Created April 29, 2011 04:28
Clang ivar write -Os
.section __TEXT,__text,regular,pure_instructions
.section __TEXT,__textcoal_nt,coalesced,pure_instructions
.section __TEXT,__const_coal,coalesced
.section __TEXT,__picsymbolstub4,symbol_stubs,none,16
.section __TEXT,__StaticInit,regular,pure_instructions
.syntax unified
.section __TEXT,__text,regular,pure_instructions
.align 2
.code 16
.thumb_func "-[IvarWriteAppDelegate application:didFinishLaunchingWithOptions:]"
@jspahrsummers
jspahrsummers / gist:947838
Created April 29, 2011 04:29
Clang ivar write source code
@synthesize window=_window;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
asm("#before");
_window = nil;
asm("#after");
// Override point for customization after application launch.
[self.window makeKeyAndVisible];
@jspahrsummers
jspahrsummers / scope.m
Created May 5, 2011 05:07
Following this behavior, how would you want to write it naturally?
- (NSString *)myMethod {
NSString *str = nil;
scope {
NSAutoreleasePool *pool = [NSAutoreleasePool new];
scope(exit)
[pool drain];
str = [[NSMutableString alloc] initWithFormat:@"%i", 42];
@jspahrsummers
jspahrsummers / releaseOnExit.m
Created May 9, 2011 01:59
I don't think I'll actually do this, but it was fun to come up with.
// syntactic sugar for @onExit
#define releaseOnExit \
ext_saveSelf]; @onExit { [ext_releaseObj release]; }; [(id)nil self
NSMutableString *str = [[@"foo" mutableCopy] releaseOnExit];