Skip to content

Instantly share code, notes, and snippets.

View felixvisee's full-sized avatar

Felix Visée felixvisee

View GitHub Profile
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
import Combine
import Dispatch
import Foundation
(1...10)
.publisher()
.handleEvents(receiveOutput: { print("publisher sent \($0)") })
import PlaygroundSupport
PlaygroundPage.current.needsIndefiniteExecution = true
import Combine
import Dispatch
/// Returns a subscriber that buffers up to `size` values before calling the given `handler`. The
/// subscriber will request more values from the upstream publisher once the `completion` closure
/// given to the `handler` is called.
func subscriber<Output, Failure>(size: Int, handler: @escaping (_ values: [Output], _ completion: @escaping () -> ()) -> ()) -> AnySubscriber<Output, Failure> {

Keybase proof

I hereby claim:

  • I am felixjendrusch on github.
  • I am felixjendrusch (https://keybase.io/felixjendrusch) on keybase.
  • I have a public key whose fingerprint is 1D06 12E2 3CB9 76AB 3EDB 7982 4176 262E 7197 C6D3

To claim this, I am signing this object:

import CoreGraphics
public struct Interpolation<Value> {
private let interpolateFunc: (from: Value, to: Value, at: CGFloat) -> Value
public init(interpolate interpolateFunc: (from: Value, to: Value, at: CGFloat) -> Value) {
self.interpolateFunc = interpolateFunc
}
public func interpolate(from: Value, to: Value, at: CGFloat) -> Value {
@felixvisee
felixvisee / Example.swift
Created July 9, 2015 14:03
A `Box`-like struct returning a value based on the current traits of a view.
public class View: UIView {
public override var traitCollection: UITraitCollection {
return UITraitCollection(traitsFromCollections: [
UITraitCollection(horizontalSizeClass: .Compact),
UITraitCollection(verticalSizeClass: .Compact)
])
}
}
let view = View()
#import <Foundation/Foundation.h>
#import <JazzHands/IFTTTJazzHands.h>
@interface MyCustomValue : NSValue <IFTTTInterpolatable>
@property (nonatomic, assign, readonly) CGPoint controlPoint1;
@property (nonatomic, assign, readonly) CGPoint controlPoint2;
- (instancetype)initWithCGRect:(CGRect)rect controlPoint1:(CGPoint)controlPoint1 controlPoint2:(CGPoint)controlPoint2;
struct Value {
var property: Int = 0
mutating func change() {
property++
}
func changed() -> Value {
var copy = self
copy.property++
//
// AdapativeConstraintGroup.swift
// CartographyDemo
//
// Created by Felix Jendrusch on 2/3/15.
// Copyright (c) 2015 Felix Jendrusch. All rights reserved.
//
import Cartography
@felixvisee
felixvisee / example.js
Created July 4, 2013 16:16
promisify functions with `successCallback`/`errorCallback` arguments using https://github.com/slightlyoff/Promises
var service = ...; // webinos file api service
promisify(service.requestFileSystem, service)(null, null)
.then(function (filesystem) {
return filesystem.root;
})
.then(function (root) {
return promisify(root.getFile, root)("test", { create : true });
})
.then(function (file) {
@felixvisee
felixvisee / example.js
Created July 4, 2013 16:00
Jasmine promise-returning spec wrapper function, example with https://github.com/slightlyoff/Promises
describe("Something", function () {
it("should promise", promising(function () {
return Promise.reject("Ouch!");
}));
});