This also works as a short and out-of-the-box alternative:
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0 ) { /* */ }
Thanks to:
public func +(time: DispatchTime, seconds: Double) -> DispatchTime
import UIKit | |
class HomeCollectionViewFlowLayout: UICollectionViewFlowLayout { | |
var isSetUp = false | |
override func prepare() { | |
super.prepare() | |
setUpIfNeeded() |
def subsequences(count, seq = range(5, 40, 5), target = 100, partial = []): | |
if count == 0: | |
return | |
s = sum(partial) | |
if s >= target: | |
return | |
if s == target or (count == 1 and (target - s) in seq): |
// https://developer.apple.com/reference/uikit/uiviewcontrollertransitioningdelegate | |
class AnimationController: NSObject, UIViewControllerAnimatedTransitioning { | |
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval { | |
return 0.2 // The duration of the animation | |
} | |
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { | |
// Since you are presenting a new view controller, you primarily need the new view controller |
This also works as a short and out-of-the-box alternative:
DispatchQueue.main.asyncAfter(deadline: .now() + 5.0 ) { /* */ }
Thanks to:
public func +(time: DispatchTime, seconds: Double) -> DispatchTime
osascript -e 'tell application "Finder" to eject (every disk whose ejectable is true)' |
tell application "Finder" | |
eject (every disk whose ejectable is true) | |
end tell |
import Dispatch | |
func dispatch_async(queue: dispatch_queue_t = dispatch_get_main_queue(), block: dispatch_block_t) { | |
Dispatch.dispatch_async(queue, block) | |
} | |
dispatch_async { | |
// Update the UI | |
} |
SELECT t.alias, p.token | |
FROM ts_parse('default', 'http://www.postgresql.org/docs/9.4/static/textsearch-parsers.html') AS p | |
NATURAL JOIN ts_token_type('default') AS t; | |
-- alias | token | |
-- ----------+------------------------------------------------------------ | |
-- protocol | http:// | |
-- url | www.postgresql.org/docs/9.4/static/textsearch-parsers.html | |
-- host | www.postgresql.org | |
-- url_path | /docs/9.4/static/textsearch-parsers.html |
Given #f7dd37
, this workflow will generate a line like this [UIColor colorWithRed:247.0 / 255.0 green:221.0 / 255.0 blue:55.0 / 255.0 alpha:1.0]
and paste it into the frontmost application.
OS X Mountain Lion ships with two new apps, Reminders and Notes, which are basically OS X counterparts of the standard iOS apps with the same names. One nice thing about these new apps is that they are scriptable.
This means that I was able to create two simple AppleScripts and thus an Alfred extensions to make a new reminder in the default list and to make a new note in the default folder.
You can view the sources of the AppleScripts below.