Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000| import Foundation | |
| typealias CompletionHandler = (() -> Void) | |
| class DynamicValue<T> { | |
| var value : T { | |
| didSet { | |
| self.notify() | |
| } | |
| } |
| -- Remove the history from | |
| rm -rf .git | |
| -- recreate the repos from the current content only | |
| git init | |
| git add . | |
| git commit -m "Initial commit" | |
| -- push to the github remote repos ensuring you overwrite history | |
| git remote add origin git@github.com:<YOUR ACCOUNT>/<YOUR REPOS>.git |
Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.
$ python -m SimpleHTTPServer 8000| @objc protocol Refreshable | |
| { | |
| /// The refresh control | |
| var refreshControl: UIRefreshControl? { get set } | |
| /// The table view | |
| var tableView: UITableView! { get set } | |
| /// the function to call when the user pulls down to refresh | |
| @objc func handleRefresh(_ sender: Any); |
| FIRDatabase.database().reference().child("conversations").child(location).observe(.value, with: { (snapshot) in | |
| if(snapshot.childrenCount > 1) { | |
| var removeCount = Int(snapshot.childrenCount) - 1 | |
| let enumerator = snapshot.children | |
| while let rest = enumerator.nextObject() as? FIRDataSnapshot { | |
| rest.ref.removeValue() | |
| removeCount -= 1 | |
| if(removeCount == 0) { |
| import Foundation | |
| func bubbleSort(inout numbers: [Int]) -> () { | |
| let numbersLength = numbers.count | |
| for i in 0 ..< numbersLength { | |
| for j in 1 ..< numbersLength-i { | |
| if numbers[j-1] > numbers[j] { | |
| let swap = numbers[j-1] | |
| numbers[j-1] = numbers[j] |
| func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { | |
| window = UIWindow(frame: UIScreen.mainScreen().bounds) | |
| let viewModel = LoginViewModel(provider: GitHubProvider) | |
| let loginViewController = R.storyboard.main.loginViewController! | |
| loginViewController.viewModel = viewModel | |
| if let window = window { | |
| window.rootViewController = loginViewController | |
| window.makeKeyAndVisible() |
| GitHubProvider.request(.UserRepositories(username), completion: { result in | |
| var success = true | |
| var message = "Unable to fetch from GitHub" | |
| switch result { | |
| case let .Success(response): | |
| do { | |
| let json: NSArray? = try response.mapJSON() as? NSArray | |
| if let json = json { |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| class Brew { | |
| var temp: Float = 0.0 | |
| } | |
| class BrewViewModel : NSObject { | |
| var brew = Brew() | |
| dynamic var temp: Float = 0.0 { | |
| didSet { | |
| self.brew.temp = temp | |
| } |