Skip to content

Instantly share code, notes, and snippets.

Avatar

Sebastian Grail sebastiangrail

  • Canva
  • Sydney, Australia
View GitHub Profile
View keybase.md

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 — forked from tomj/rac_serial_requests.swift
Make 2 serial network requests with ReactiveCocoa in an Xcode Playground
View rac_serial_requests.swift
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 {
View RACSignal+AnimateHidden.,
@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 Sep 2, 2015
RACSignal UIView animation
View RACSignal+Animate.m
@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
Monoids on a Sunday afternoon
View gist:828c2ad63a3ec581bf6e
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
View Pipe Forward example
// 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")