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 CoreMotion | |
| let motionManager = CMMotionManager() | |
| var xAcceleration = CGFloat(0) | |
| func setupCoreMotion() { | |
| motionManager.accelerometerUpdateInterval = 0.2 | |
| let queue = NSOperationQueue() | |
| motionManager.startAccelerometerUpdatesToQueue(queue, withHandler: { | |
| accelerometerData, error in |
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 UIKit | |
| import XCPlayground | |
| func generateRandomCloud() -> UIImage { | |
| func randomInt(lower lower: Int, upper: Int) -> Int { | |
| assert(lower < upper) | |
| return lower + Int(arc4random_uniform(UInt32(upper - lower))) | |
| } |
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 UIKit | |
| import XCPlayground | |
| enum Edge { | |
| case Outie | |
| case Innie | |
| case Flat | |
| } | |
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
| var testRepo = new TestRepo(); | |
| //var start = DateTime.Now; | |
| var t1 = testRepo.Task1(); | |
| var t2 = testRepo.Task2(); | |
| int[] r = await Task.WhenAll(t1, t2); | |
| //var end = (DateTime.Now - start).Seconds; | |
| return new int[] { r[0], r[1] }; | |
| /***************************/ | |
| public class TestRepo |
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
| // Example how to explore a Character type | |
| echo ":type lookup Character" | swift | less |
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
| struct Resource<A> { | |
| let pathComponent: String | |
| let parse: AnyObject -> A? | |
| } | |
| extension Resource { | |
| func loadAsynchronous(callback: A? -> ()) { | |
| let session = NSURLSession.sharedSession() | |
| let resourceURL = webserviceURL.URLByAppendingPathComponent(pathComponent) | |
| session.dataTaskWithURL(resourceURL) { |
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
| UIApplication.sharedApplication().windows[0].rootViewController!.presentViewController(alert, animated: true, completion: 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
| using System.Diagnostics; | |
| private readonly Stopwatch stopwatch; | |
| // Initialize should be done in class constructor | |
| stopwatch = new Stopwatch(); | |
| // Usage | |
| stopwatch.Start(); | |
| // Metod/algoritm to execute | |
| stopwatch.Stop(); |
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
| for index in 0..<array.count { | |
| let red = CGFloat(Float(index) / Float(sortedResults.count)) | |
| let green = CGFloat(1.0 - (Float(index) / Float(sortedResults.count))) | |
| let color = NSColor(calibratedRed: red, green: green, blue: 0.0, alpha: 1.0) | |
| } |
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 HttpResponseMessage GetImage() | |
| { | |
| byte[] bytes = System.IO.File | |
| .ReadAllBytes | |
| ( | |
| HttpContext.Current.Server | |
| .MapPath("~/Images/default.jpg") | |
| ); | |
| var result = new HttpResponseMessage(HttpStatusCode.OK); | |
| result.Content = new ByteArrayContent(bytes); |
OlderNewer