- Open Sublime Text 3
- Go To
Preferences > Browse Packages...
- Add a file named
Swift.sublime-build
insidePackages
directory. - Copy the following script in
Swift.sublime-build
file.
{
"shell_cmd": "xcrun swift \"$file\"",
extension DateFormatter { | |
static let iso8601Full: DateFormatter = { | |
let formatter = DateFormatter() | |
formatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ" | |
formatter.calendar = Calendar(identifier: .iso8601) | |
formatter.timeZone = TimeZone(secondsFromGMT: 0) | |
formatter.locale = Locale(identifier: "en_US_POSIX") | |
return formatter | |
}() |
git config --global alias.trim '!f() { git branch | grep -v "\*" | xargs -n 1 git branch -D; }; f' |
// | |
// Glob.swift | |
// | |
// Created by Brad Grzesiak on 6/25/15. | |
// Copyright © 2015 Bendyworks Inc. | |
// Released under the Apache v2 License. | |
// | |
import Darwin |
// A test to determine performance difference between two String.length implementations in Swift. | |
import Foundation | |
// String with 1,000 characters | |
var testString = "1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456 |
#!/usr/bin/env xcrun swift | |
/* | |
/r/DailyProgrammer Challenge # 193 | |
Reddit - http://www.reddit.com/r/dailyprogrammer/ | |
Blake Merryman | |
Github - https://github.com/blakemerryman | |
Challenge Description: | |
An international shipping company is trying to figure out how to manufacture various types of containers. Given a volume they want to figure out the dimensions of various shapes that would all hold the same volume. | |
Input: |
#!/usr/bin/env xcrun swift | |
/* | |
/r/DailyProgrammer Challenge # 193 | |
Reddit" : "http://www.reddit.com/r/dailyprogrammer/ | |
Blake Merryman | |
Github" : "https://github.com/blakemerryman | |
Notes: |
public extension NSData { | |
// Calculates the number of packets it should be broken down into based on Core Bluetooth spec of 20 Bytes/Packet | |
var packetCount : Int { return Int( ceil( Double(self.length) / 20.0 ) ) } | |
} |
public extension NSMutableData { | |
func insertBytes(bytes: UnsafePointer<Void>, withLength length: Int, atIndex index: Int) -> NSMutableData { | |
if index > self.length { | |
return NSMutableData() | |
} | |
var data = self // Holds self for modification | |
public extension String { | |
var length : Int { return countElements(self) } | |
} |