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 | |
extension NSDate: Comparable { | |
func isLessThanDate(date: NSDate) -> Bool { | |
var result = false | |
if self.compare(date) == NSComparisonResult.OrderedAscending { | |
result = true | |
} | |
return result | |
} |
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 XCPlayground | |
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true | |
class UnownedTester { | |
private static let testQueue = dispatch_queue_create("playground.unowned.tester", DISPATCH_QUEUE_SERIAL) | |
private static var instance: UnownedTester? = UnownedTester() |
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
#!/bin/bash | |
################################################## | |
################################################## | |
# A template to use for writing new bash scripts. | |
# Includes argument parsing, verbose flag, and | |
# that's it. | |
################################################## | |
# SCRIPT METADATA |
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 ruby | |
class AppShell | |
require "logger" | |
require "optparse" | |
@@BANNER = "A shell with app boilerplate & option parsing, suitable for subclassing" | |
@@VERSION = [0, 0, 1] | |
LOG_LEVELS = [ Logger::WARN, Logger::INFO, Logger::DEBUG ] |
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 | |
class Node<T: Comparable> { | |
let value: T | |
var left: Node? | |
var right: Node? | |
init(value: T, left: Node? = nil, right: Node? = nil) { | |
self.value = value | |
self.left = left |
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
/* @flow */ | |
type EnumName = string; | |
type EnumProperties = {[key: any]: any}; | |
/// An abstract class that defines semantics for typesafe `enum` style implementations in JavaScript. | |
/// Relies on ES6 extensions to support static properties, and is therefore not suitable for all | |
/// projects. | |
/// | |
/// Usage: |
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
// @flow | |
function doAsyncWork(shouldSucceed: boolean): Promise<number> { | |
let p = new Promise(function asyncWorker(resolve, reject) { | |
setTimeout(function() { | |
if (shouldSucceed) { | |
resolve(42); | |
} else { | |
let error = new Error("rejected"); | |
reject(error); |
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 Person { | |
name: string; | |
friends: Array<Person>; | |
constructor(name: string) { | |
this.name = name; | |
this.friends = []; | |
} | |
addFriends(friends: Array<Person>) { |
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 | |
protocol TestClassFactory { | |
static func make() -> TestClass | |
} | |
protocol TestClass { | |
var testValue: String { get set } | |
} |
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
// Copy this into an Xcode Playground | |
import Foundation | |
import Combine | |
import PlaygroundSupport | |
PlaygroundPage.current.needsIndefiniteExecution = true | |
let odds = PassthroughSubject<Int, Never>() | |
let evens = PassthroughSubject<Int, Never>() |
OlderNewer