(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| #import <Foundation/Foundation.h> | |
| #define TGR_RUNLOOP_INTERVAL 0.05 | |
| #define TGR_TIMEOUT_INTERVAL 1.0 | |
| #define TGR_RUNLOOP_COUNT TGR_TIMEOUT_INTERVAL / TGR_RUNLOOP_INTERVAL | |
| #define TGR_CAT(x, y) x ## y | |
| #define TGR_TOKCAT(x, y) TGR_CAT(x, y) | |
| #define __runLoopCount TGR_TOKCAT(__runLoopCount,__LINE__) |
| class FileManager { | |
| struct StaticInstance { | |
| static var instance = FileManager() | |
| } | |
| class var defaultManager : FileManager { | |
| return StaticInstance.instance | |
| } | |
| } |
| // F#'s "pipe-forward" |> operator | |
| // | |
| // Also "Optional-chaining" operators |>! and |>& | |
| // | |
| // And adapters for standard library map/filter/sorted | |
| infix operator |> { precedence 50 associativity left } | |
| infix operator |>! { precedence 50 associativity left } | |
| infix operator |>& { precedence 50 associativity left } | |
| infix operator |>* { precedence 50 associativity left } |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| // Protocol for a type that supports a fromRaw(Int) conversion | |
| // (such as "enum Foo: Int { ... }") | |
| protocol ConvertibleFromRawInt { | |
| class func fromRaw(raw: Int) -> Self? | |
| } | |
| // Note: Tried to use Swift's standard RawRepresentable protocol rather | |
| // than ConvertibleFromRawInt, but couldn't get it to compile. | |
| // Don't know whether it is a Swift bug or something I was doing wrong. |
Based on http://jjyap.wordpress.com/2014/02/21/installing-opencv-2-4-8-on-mac-osx-with-python-support/
.bashrc or .bash_profile to include: export PATH="/Library/Frameworks/Python.framework/Versions/Current/bin:/Library/Python/2.7/site-packages/:$PATH"brew updatebrew tap homebrew/sciencebrew install opencvcd /Library/Python/2.7/site-packages/ln -s /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv.py cv.pyln -s /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv2.so cv2.soIn this article, I'm going to explore a way that we can create views that implement custom Core Animation property animations in a natural way.
As we know, layers in iOS come in two flavours: Backing layers and hosted layers. The only difference between them is that the view acts as the layer delegate for its backing layer, but not for any hosted sublayers.
In order to implement the UIView transactional animation blocks, UIView disables all animations by default and then re-enables them individually as required. It does this using the actionForLayer:forKey: method.
Somewhat strangely, UIView doesn't enable animations for every property that CALayer does by default. A notable example is the layer.contents property, which is animatable by default for a hosted layer, but cannot be animated using a UIView animation block.
| Copyright 2015 Chris Eidhof | |
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | |
| The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | |
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHE |
| // lets define Applicative Functor for (->)r type (function of function) | |
| // tip: similar to Reader monad. | |
| infix operator <*> { associativity left precedence 150 } | |
| func <*> <A, B, C> (f : A -> B -> C, g : A -> B)(x : A) -> C { | |
| return f (x) (g(x)) | |
| } | |
| infix operator <|> { associativity left precedence 150 } | |
| func <|> <A, B, C> (f : A -> B -> C, g : C -> A) -> C -> B -> C { | |
| return pure(f) <*> g |
I've moved this gist to https://github.com/phynet/iOS-Schemes please check it there ;)