Skip to content

Instantly share code, notes, and snippets.

Avatar

Erik Price erikprice

View GitHub Profile
View producer_consumer.clj
(use 'clojure.core.async)
(def output (atom []))
(defn producer [ctrl k]
(go (loop [i 0]
(when-let [c (<! ctrl)]
(>! c [k i])
(>! ctrl c)
(recur (inc i))))))
View keybase.md

Keybase proof

I hereby claim:

  • I am erikprice on github.
  • I am erik_price (https://keybase.io/erik_price) on keybase.
  • I have a public key whose fingerprint is 12E5 0EFF CEA1 BD87 DE0A E362 7DF0 A230 7331 5642

To claim this, I am signing this object:

@erikprice
erikprice / gist:9360897
Created Mar 5, 2014
Graham Scan in Haskell
View gist:9360897
grahamScan :: [Point] -> [Point]
grahamScan pts
| length pts < 3 = error "Not a polygon"
| otherwise = reverse $ scan rest (b:[a])
where (a:b:rest) = pts
scan [] acc = acc
scan pts acc = case d of
TurnsRight _ _ _ -> scan ps (c:a:stack)
_ -> scan ps (c:b:a:stack)
where (c:ps) = sortBy sortByYThenX pts
View CPPViewController.m
//
// CPPViewController.m
// Catalog Playlist Playback
//
// Created by Robert Crooks on 10/2/13.
// Copyright (c) 2013 Brightcove. All rights reserved.
//
#import "CPPViewController.h"
View CPPViewController.h
//
// CPPViewController.h
// Catalog Playlist Playback
//
// Created by Robert Crooks on 10/9/13.
// Copyright (c) 2013 Brightcove. All rights reserved.
//
#import <UIKit/UIKit.h>
View cue-point-usage-view-contoller-header.h
//
// CPUViewController.h
// Cue Point Usage
//
// Created by Robert Crooks on 11/14/13.
// Copyright (c) 2013 Robert Crooks. All rights reserved.
//
#import <UIKit/UIKit.h>
// import the SDK master header
View cue-point-usage-view-controller-implementation
//
// CPUViewController.m
// Cue Point Usage
//
// Created by Robert Crooks on 11/14/13.
// Copyright (c) 2013 Robert Crooks. All rights reserved.
//
#import "CPUViewController.h"
// import the SDK master header and RAC EXTScope header
@erikprice
erikprice / DisposeSignalUpstreamOfMerge.m
Created Nov 17, 2013
Test to verify that in a RACSignal subscription chain, the completed event on a signal downstream of a `+merge:` invokes the disposable of an upstream signal. (ReactiveCocoa)
View DisposeSignalUpstreamOfMerge.m
it(@"should propagate disposal to signals upstream of a +merge: to which it is subscribed when it completes", ^{
__block BOOL disposed1 = NO;
__block BOOL disposed2 = NO;
RACSignal *upstream1 = [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> _) {
return [RACDisposable disposableWithBlock:^{
disposed1 = YES;
}];
}];
RACSignal *upstream2 = [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> _) {
return [RACDisposable disposableWithBlock:^{
@erikprice
erikprice / 2.0-development_ReactiveCocoa.podspec
Created Jul 30, 2013
Interim podspec for the `2.0-development` branch of ReactiveCocoa. To use this podspec: 1. Fork the ReactiveCocoa project, clone it locally, and tag the 2.0-development branch as `v2.0-development` (note the leading `v`, it's important). 2. Copy this gist into a file called `ReactiveCocoa.podspec` and place it in the root of your local clone of …
View 2.0-development_ReactiveCocoa.podspec
Pod::Spec.new do |s|
s.name = "ReactiveCocoa"
s.version = "2.0-development"
s.summary = "A framework for composing and transforming sequences of values."
s.homepage = "https://github.com/ReactiveCocoa/ReactiveCocoa"
s.author = { "Josh Abernathy" => "josh@github.com" }
s.source = { :git => "https://github.com/YOUR_GITHUB_NAME/ReactiveCocoa.git", :tag => "v#{s.version}" }
s.license = 'Simplified BSD License'
s.description = "ReactiveCocoa offers:\n" \
"1. The ability to compose operations on future data.\n" \
View gist:5664273
// 1.
// “Safe” but retain cycle.
[self setCompletionBlock:^{
NSLog(@"1: %@", self->_foo);
}];
// 2.
// Unsafe. Could dereference nil.
__weak BCThing *weakSelf = self;
You can’t perform that action at this time.