This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The basics | |
[[self.connection fetch:@"the-answer"] subscribeNext:^(NSNumber *x) { | |
NSLog(@"The answer is %@", x); | |
}]; | |
[[self.connection writeObject:@42 forKey:@"the-answer"] subscribeCompleted:^{ | |
NSLog(@"Wrote it."); | |
}]; | |
// Signal for changes to the object at a key |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// FGOManagedObjectContextStack.h | |
// | |
// Created by Indragie Karunaratne on 2012-12-23. | |
// | |
#import <Foundation/Foundation.h> | |
typedef void (^FGOConfigurationBlock)(id); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- implements an option type as a tagged union | |
local option = {} | |
local mt = { __index = option } | |
local function isoption(t) | |
return getmetatable(t) == mt | |
end | |
function option.some(a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CGFloat max = [[numbersArray.rac_sequence foldLeftWithStart:@(FLT_MIN) combine:^id(id accumulator, id value) { | |
if (value == [NSNull null]) return accumulator; | |
if ([accumulator floatValue] < [value floatValue]) return value; | |
else return accumulator; | |
}] floatValue]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// "Semantic issue - Unsequences modification and access to '_cmd'" | |
// Expanded from macro 'NSParameterAssert' | |
// Expanded from macro 'NSAssert' | |
// Expanded from macro 'self' | |
@implementation _ModelClass | |
+ (id)insertInManagedObjectContext:(NSManagedObjectContext*)moc_ { | |
NSParameterAssert(moc_); | |
return [NSEntityDescription insertNewObjectForEntityForName:@"Model" inManagedObjectContext:moc_]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Only let input Observable fire every 'n' seconds at most | |
// but unlike Throttle, items fire immediately when they aren't | |
// rate-limited. | |
public IObservable<T> RateLimit<T>(this IObservable<T> This, TimeSpan interval, IScheduler scheduler) | |
{ | |
var slot = default(IObservable<Unit>); | |
var input = This.Publish().RefCount(); | |
return input.Window(input, _ => { | |
if (slot != null) return slot; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data PreExp exp = Val Int | |
| Add exp exp | |
newtype Exp = Exp (PreExp Exp) -- this is just a normal expression | |
data AttrExp = AttrExp Attr (PreExp AttrExp) -- an attributed expression | |
data Attr = ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef RACSignal *(^RACSignalKleisliBlock)(id input); | |
@interface RACSignalKleisli : NSObject | |
- (id)initWithSignalBlock:(RACSignalKleisliBlock)block; | |
- (instancetype)compose:(RACSignalKleisli *)kleisli; | |
- (RACSignal *)execute:(id)input; | |
@end | |
@implementation RACSignalKleisli { | |
RACSignalBlock _signalBlock; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RACCommand *example = [[RACCommand alloc] initWithSignalBlock:^(id input) { | |
return [RACSignal createWithBlock:^(id<RACSubscriber> subscriber){ | |
[subscriber sendCompleted]; | |
return nil; | |
}]; | |
]; | |
// Now, how will I know when each task has completed? | |
// I certainly cannot tell from `example.executionSignals.flatten`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function remove_dir () { | |
rm -rf "$1_" | |
if [ -d "$1" ] | |
then | |
mv "$1" "$1_" | |
fi | |
} |