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
| "coreos-beta" | |
| "freebsd-10-1-x64" | |
| "fedora-23-x64" | |
| "centos-6-5-x32" | |
| "centos-6-5-x64" | |
| "debian-7-0-x32" | |
| "debian-7-0-x64" | |
| "fedora-24-x64" | |
| "debian-7-x32" | |
| "freebsd-10-3-x64-zfs" |
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 String { | |
| func size(withAttributes attrs: [String:AnyObject], constrainedTo box: NSSize) -> NSRect { | |
| let storage = NSTextStorage(string: self) | |
| let container = NSTextContainer(containerSize: NSSize(width: box.width, height: box.height)) | |
| let layout = NSLayoutManager() | |
| layout.addTextContainer(container) | |
| storage.addLayoutManager(layout) | |
| storage.addAttributes(attrs, range: NSMakeRange(0, storage.length)) | |
| container.lineFragmentPadding = 0.0 | |
| let _ = layout.glyphRangeForTextContainer(container) |
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
| private func example1() { | |
| let queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0) | |
| for i in 0..<10 { | |
| dispatch_async(queue) { | |
| NSLog("Start: \(i)") | |
| sleep(3) | |
| NSLog("End: \(i)") | |
| } | |
| } | |
| } |
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 | |
| // Dynamic swift! | |
| /* * * * * * * * * * * * * * * * * * * * * | |
| * Scroll to the bottom for sample code! * | |
| * * * * * * * * * * * * * * * * * * * * */ | |
| // Disclaimer: Any resemblance to JavaScript or any other shitty language is completely accidental. |
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
| Have you always wanted to define the sailboat operator in Swift? Well now you can! | |
| 3 ⛵4 == "sailboat" | |
| Swift 1.2 significantly increased the number of legal characters in custom operators. | |
| I've generated a list for ease of copy/paste below. | |
| Generated from reference here: http://apple.co/1EEXHDQ | |
| The characters |
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
| // NSScanner+Swift.swift | |
| // A set of Swift-idiomatic methods for NSScanner | |
| // | |
| // (c) 2015 Nate Cook, licensed under the MIT license | |
| import Foundation | |
| extension NSScanner { | |
| // MARK: Strings |
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
| // CalculatorView.swift | |
| // as seen in http://nshipster.com/ibinspectable-ibdesignable/ | |
| // | |
| // (c) 2015 Nate Cook, licensed under the MIT license | |
| /// The alignment for drawing an String inside a bounding rectangle. | |
| enum NCStringAlignment { | |
| case LeftTop | |
| case CenterTop | |
| case RightTop |
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
| func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { | |
| registerNotificationTypes() | |
| return true | |
| } | |
| func registerNotificationTypes() { | |
| let types: UIUserNotificationType = .Badge | .Sound | .Alert; |
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
| library(rvest) | |
| library(dypgraph) | |
| library(pipeR) | |
| library(magrittr) | |
| library(dplyr) | |
| options(viewer = NULL) | |
| url <- "http://www.feldgrau.com/stats.html" | |
| stats <- | |
| html(url) %>% |
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
| let mainQueueA = dispatch_get_global_queue(qos_class_main(), 0) | |
| let mainQueueB = dispatch_get_main_queue() | |
| // This works fine | |
| dispatch_apply(3, mainQueueA) { i in | |
| println("A: \(i)") | |
| } | |
| println("Yep") | |
| // This never calls the block and hangs the main thread |
NewerOlder