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) |
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
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
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
#!/usr/bin/env sh | |
# From http://collectiveidea.com/blog/archives/2014/02/18/a-simple-pair-programming-setup-with-ssh-and-tmux/ | |
set -eu | |
HELP=false | |
for flag in "$@"; do | |
case "$flag" in | |
-h|--help) HELP=true;; | |
esac | |
done |
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 click | |
def set_global_domain(ctx, param, value): | |
if value: | |
ctx.params["domain"] = "NSGlobalDomain" | |
return value | |
@click.group() | |
def cli(): | |
pass |
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 <Foundation/Foundation.h> | |
int main() { | |
NSNumber *a = @1; | |
NSNumber *b = @2; | |
NSNumber *c = @200; | |
NSLog(@"%d", a < b); // Prints 1 (true) | |
NSLog(@"%d", a < c); // Prints 1 (true) | |
} |
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 Foundation | |
import Mapper | |
protocol Archivable: Mappable { | |
func encode(archive: Archiver) | |
} | |
final class Archiver { | |
private var mapping: [String: AnyObject] = [:] | |
required init(_ object: Archivable) { |
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 Nimble | |
import Quick | |
import SwiftCheck | |
final class StringTransformSpec: QuickSpec { | |
override func spec() { | |
describe("chopPrefix<Int>") { | |
it("should remove prefix of given length") { | |
property("result is of expected length") <- forAll { (string: String) in |
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
// | |
// ArbitraryExtensions.swift | |
// InstaShopper | |
// | |
// Created by Michael Sanders on 6/18/16. | |
// Copyright © 2016 Instacart. All rights reserved. | |
// | |
import Curry | |
import Mockingjay |
OlderNewer