This file contains hidden or 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
| /* | |
| * coalesce takes in a list of optional values | |
| * and returns the first one that is not nil | |
| */ | |
| func coalesce<T>(all: @autoclosure () -> T? ...) -> T? { | |
| for f: () -> T? in all { | |
| if let x = f() { return x } | |
| } | |
| return nil |
This file contains hidden or 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 Security | |
| public class Keychain | |
| { | |
| public class func set(key: String, value: String) -> Bool | |
| { | |
| if let data = value.dataUsingEncoding(NSUTF8StringEncoding) | |
| { | |
| return set(key, value: data) | |
| } |
This file contains hidden or 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 | |
| # Bonjour name ending in .local | |
| scutil --set LocalHostName "My-iMac" | |
| # Friendly name shown in System Preferences > Sharing | |
| scutil --set ComputerName "My-iMac" | |
| # The name recognized by the hostname command | |
| scutil --set HostName "My-iMac" | |
| # Save the computer's serial number in a variable so it can be used in the next command. | |
| serialNum=$(ioreg -l | awk '/IOPlatformSerialNumber/ { split($0, line, "\""); printf("%s\n", line[4]); }') | |
| # Set the NetBIOS name as the serial number |
This document is research for the selection of a communication platform for robot-net.
The purpose of this component is to enable rapid, reliable, and elegant communication between the various nodes of the network, including controllers, sensors, and actuators (robot drivers). It will act as the core of robot-net to create a standardized infrastructure for robot control.
Requirements:
This file contains hidden or 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
| extension NSTimer { | |
| /** | |
| Creates and schedules a one-time `NSTimer` instance. | |
| - Parameters: | |
| - delay: The delay before execution. | |
| - handler: A closure to execute after `delay`. | |
| - Returns: The newly-created `NSTimer` instance. | |
| */ |
This file contains hidden or 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 ImageIO | |
| infix operator >>= { associativity left } | |
| func >>=<A,B>(l: A?, r: A -> B?) -> B? { | |
| if let x = l { | |
| return r(x) | |
| } | |
| return nil |
This file contains hidden or 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
| public protocol CountableCollectionType: CollectionType { | |
| var count: Int { get } | |
| } | |
| extension Array: CountableCollectionType {} | |
| public protocol CollectionViewCellFactoryType { | |
| typealias Item | |
| typealias Cell: UICollectionViewCell | |
| func cellForItem(item: Item, inCollectionView collectionView: UICollectionView, atIndexPath indexPath: NSIndexPath) -> Cell |
A checklist for designing and developing internet scale services, inspired by James Hamilton's 2007 paper "On Desgining and Deploying Internet-Scale Services."
- Does the design expect failures to happen regularly and handle them gracefully?
- Have we kept things as simple as possible?