This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Promise<X> { | |
map<B>(onValue: (x: X) => B): Promise<B> { | |
AS.assertParameter(onValue, "onValue"); | |
return new Promise<B>((resolve, reject) => { | |
this.parsePromise.then(x => { | |
resolve(onValue(x)); | |
}, e => { | |
reject(e); | |
return Parse.Promise.as(); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static fromPromise<S>(promise: Parse.Promise<S>): Parse.Promise<Maybe<S>> { | |
return promise.then(x => Maybe.fromValue(x)); | |
} | |
// Example | |
Maybe.fromPromise( | |
this.stack.moment.tz(today, timezone).isoWeekday() === 1 ? generateWeeklyDigest(today) : Parse.Promise.as() | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import autopy | |
import math | |
import random | |
import time | |
# The autopy.mouse.smooth_move() function implemented in Python instead of C. | |
def smoothly_move_mouse(dst_x, dst_y): | |
''' | |
Smoothly moves the cursor to the given (x, y) coordinate in a | |
straight line. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// NSColor+CGColor.m | |
// | |
// Created by Michael Sanders on 11/19/10. | |
// | |
#import "NSColor+CGColor.h" | |
@implementation NSColor (CGColor) |
NewerOlder