Skip to content

Instantly share code, notes, and snippets.

View sebastiangrail's full-sized avatar

Sebastian Grail sebastiangrail

  • Canva
  • Sydney, Australia
View GitHub Profile

Keybase proof

I hereby claim:

  • I am sebastiangrail on github.
  • I am sebastiangrail (https://keybase.io/sebastiangrail) on keybase.
  • I have a public key ASB09g2HFioYWPCK_gbnKOpv-zQ8mYNxdxk6uTB3Yx80_go

To claim this, I am signing this object:

@sebastiangrail
sebastiangrail / rac_serial_requests.swift
Last active May 8, 2016 23:59 — forked from tomj/rac_serial_requests.swift
Make 2 serial network requests with ReactiveCocoa in an Xcode Playground
import Result
import ReactiveCocoa
import Foundation
import XCPlayground
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
let producer1 = SignalProducer<AnyObject, NSError> { observer, disposable in
let task1 = NSURLSession.sharedSession().dataTaskWithURL(NSURL(string:"http://jsonplaceholder.typicode.com/posts/1")!, completionHandler: { (data, response, error) in
if error != nil {
@implementation RACSignal (Animate)
- (RACSignal*)animateWithDuration:(NSTimeInterval)duration {
return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
return [self subscribeNext:^(id x) {
[UIView animateWithDuration:duration animations:^{
[subscriber sendNext:RACTuplePack(x, nil)];
} completion:^(BOOL finished) {
[subscriber sendNext:RACTuplePack(x, @(finished))];
}];
@sebastiangrail
sebastiangrail / RACSignal+Animate.m
Created September 2, 2015 23:41
RACSignal UIView animation
@interface RACSignal (Animate)
@end
@implementation RACSignal (Animate)
- (RACSignal*)animateWithDuration:(NSTimeInterval)duration {
return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
return [self subscribeNext:^(id x) {
[UIView animateWithDuration:duration animations:^{
[subscriber sendNext:x];
@sebastiangrail
sebastiangrail / gist:828c2ad63a3ec581bf6e
Created May 31, 2015 06:05
Monoids on a Sunday afternoon
protocol Monoid {
static func zero () -> Self
static func append (Self, Self) -> Self
}
protocol NumberType {
func add(other: Self) -> Self
func subtract(other: Self) -> Self
func multiplyWith(other: Self) -> Self
static func zero () -> Self
// make strings appendable
extension String {
func append (other: String) -> String {
return self + " " + other
}
}
// Chainable with append method. Note that strings aren't mutated
"Hi,"
.append("how")