View gist:5d19ba0ab24862cbdcb4
1
http://www.holeintheceiling.com/blog/2012/08/14/mountain-lion-and-ssh/
View CLLocationManager+getLocation.swift
1 2 3 4 5 6 7 8 9 10
import CoreLocation
 
extension CLLocationManager {
class func getLocation(accuracy: CLLocationAccuracy, distanceFilter: CLLocationDistance) -> Promise<CLLocation> {
class GetLocationDelegate: NSObject, CLLocationManagerDelegate {
var holdSelf: GetLocationDelegate?
let locationManager = CLLocationManager()
let promise: Promise<CLLocation>
let resolve: CLLocation -> ()
View invitation.md

Dear Developer,

Thank you for your interest in developing for Amazon Echo. We would like to invite you to participate in our Amazon Echo Developer Program. As an early adopter developer, we would value your feedback on the Amazon Echo developer experience.

If you are interested in participating in the Amazon Echo Developer Program, please complete the following steps by Wednesday, March 18, 2015 as space is limited:

  1. Register for the Amazon Appstore (if you’ve not already done so);
  2. Review the Nondisclosure Agreement (NDA) included below;
  3. Reply to this e-mail (alexa-echo-developers@amazon.com) and make sure the original message is included below your response. It’s important the text of the NDA be included in your reply.
    • Write the following in the text of your e-mail: “I hereby agree to the nondisclosure agreement included below. [Your full name here], [City, State, Country]”
View Generator.swift
1 2 3 4 5 6 7 8 9 10
import Foundation
 
class Generator<T>: GeneratorType, SequenceType {
var val: T? = nil
let yieldSemaphore = dispatch_semaphore_create(0)
let valueSemaphore = dispatch_semaphore_create(0)
init(f: ((T) -> ()) -> ()) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0)) {
View Promise.swift
1 2 3 4 5 6 7 8 9 10
import Foundation
 
private class PromiseHandlers<T> {
var resolved: [T -> ()] = []
var rejected: [NSError -> ()] = []
}
 
private enum PromiseState<T> {
case Pending(PromiseHandlers<T>)
case Resolved(() -> T) // Plain T isn't supported by Swift yet
View resolveWithTimeout.swift
1 2 3 4 5 6 7 8 9 10
extension NSNetService {
func resolveWithTimeout(timeout: NSTimeInterval, success: () -> ()) {
class NetServiceDelegate: NSObject, NSNetServiceDelegate {
let oldDelegate: NSNetServiceDelegate?
let netService: NSNetService
let success: () -> ()
var holdSelf: NetServiceDelegate?
init(netService: NSNetService, success: () -> ()) {
self.oldDelegate = netService.delegate
View covered.html
1 2 3 4 5 6 7 8 9 10
<!DOCTYPE html>
<style>
html {
font: 18px "Helvetica Neue", Helvetica, Arial, sans-serif;
}
.covered {
position: relative;
overflow: hidden;
View curried.js
1 2 3 4 5 6 7 8 9 10
function curried(fn) {
function curry() {
if (arguments.length >= fn.length) {
return fn.apply(this, arguments);
}
var args = arguments;
return function() {
return curry.apply(
null, Array.prototype.concat.apply(
Array.prototype.slice.call(args), arguments)
View showAlert.swift
1 2 3 4 5 6 7 8 9 10
import UIKit
 
// Notes:
// - You must explicitly weak link to UIKit to support iOS 7
// - Action sheets on iOS 7 only show a title
 
func showAlert(viewController: UIViewController, style: UIAlertControllerStyle = .Alert, title: String? = nil, message: String? = nil, sourceView: UIView? = nil, completion: (() -> ())? = nil, buttons: (UIAlertActionStyle, String, (() -> ())?)...) {
if (NSClassFromString("UIAlertController") != nil) {
// iOS 8+
Something went wrong with that request. Please try again.