Skip to content

Instantly share code, notes, and snippets.

View almostintuitive's full-sized avatar

Mark Aron Szulyovszky almostintuitive

View GitHub Profile
Date,signal_VIX
2017-01-03 09:00:00,0.003
2017-01-03 10:00:00,0.027
2017-01-03 11:00:00,0.029
2017-01-03 12:00:00,0.023
2017-01-03 13:00:00,0.04
2017-01-03 14:00:00,0.037
2017-01-03 15:00:00,0.032
2017-01-03 16:00:00,0.065
2017-01-04 09:00:00,0.026
date,signal_SPX
2017-01-03 03:00:00,0.06
2017-01-03 04:00:00,0.049
2017-01-03 05:00:00,0.057
2017-01-03 06:00:00,0.061
2017-01-03 07:00:00,0.065
2017-01-03 08:00:00,0.07
2017-01-03 09:00:00,0.048
2017-01-03 10:00:00,0.023
2017-01-03 11:00:00,0.005
This file has been truncated, but you can view the full file.
date,signal
2017-01-23 12:00:00,0.0025290647147308038
2017-01-23 13:00:00,0.01792521634432801
2017-01-23 14:00:00,0.03949901312436061
2017-01-23 15:00:00,0.06883784290493286
2017-01-23 16:00:00,0.08510666337189783
2017-01-24 03:00:00,0.08234855713144512
2017-01-24 04:00:00,0.07838499653023315
2017-01-24 05:00:00,0.08982481729935515
2017-01-24 06:00:00,0.08654481760879715
let pan = UIPanGestureRecognizer()
let pinch = UIPinchGestureRecognizer()
let panStarted = pan.rx_event.filter { $0.state == .Began }
let panEnded = pan.rx_event.filter { $0.state == .Ended }
let pinchStarted = pinch.rx_event.filter { $0.state == .Began }
let pinchEnded = pinch.rx_event.filter { $0.state == .Ended }
// condition: when both pan and pinch ended
var panPresent = false
var pinchPresent = false
var gestureTimer: NSTimer?
var secondsLeft = 3
func handlePan(panGesture: UIPanGestureRecognizer) {
if panGesture.state == .Began && self.panPresent == false {
self.panPresent = true
self.checkIfBothGesturesPresent()
} else if panGesture.state == .Ended {
let pan = UIPanGestureRecognizer()
let pinch = UIPinchGestureRecognizer()
// Here, we want to create a signal that emits an event when the
// gesture has started.
// We can call .rx_event on UIPangestureRecognizer, and
// transform it's output into a signal, which then
// We can use filter to discard all other events!
@almostintuitive
almostintuitive / gist:0534e7e8329a7f9b3ca0
Created November 28, 2015 20:12
Imperative vs. FRP swift performance
func test1Imperative() {
class Counter {
var count: Int = 0 {
didSet {
realCount = count+1
}
}
var realCount: Int = 0
}
@almostintuitive
almostintuitive / NSHashTable+SequenceType.swift
Created September 19, 2015 18:33
Use NSHashTable with for .. in .. style enumeration with Swift2 (safely)
extension NSHashTable: SequenceType {
public func generate() -> AnyGenerator<AnyObject> {
var array = self.allObjects
var nextIndex = array.count-1
return anyGenerator {
if (nextIndex < 0) {
return nil
@almostintuitive
almostintuitive / SwipeToPeepCell-5.m
Created August 30, 2014 13:23
SwipeToPeepCell-5.m
- (void)changeBackgroundColorBasedOnProgress:(float)progress {
self.interactiveBackground.alpha = progress;
}
- (void)didMoveToSuperview {
self.interactiveBackground = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, self.bounds.size.height)];
self.interactiveBackground.backgroundColor = [UIColor flatGrayColor];
self.interactiveBackground.alpha = 0;
[self insertSubview:self.interactiveBackground atIndex:0];
@almostintuitive
almostintuitive / ViewController-5.m
Created August 30, 2014 13:23
ViewController-5.m
- (void)adjustViewBasedOnSwipeProgress:(float)progress {
self.tableView.spring.alpha = progress;
self.tableView.spring.center = CGPointMake(self.view.center.x*progress, self.view.center.y);
self.postWebView.spring.center = CGPointMake(self.view.center.x+(self.view.bounds.size.width*progress), self.view.center.y);
}