tmux new [-s name] [cmd](:new) - new session
tmux ls(:ls) - list sessionstmux switch [-t name](:switch) - switches to an existing session
| { | |
| "todo" : { | |
| "1": "Watch that movie", | |
| "2": "Write that code", | |
| "3": "Read that book", | |
| "4": "Call them", | |
| "5": "Get some sleep" | |
| } | |
| } |
| let url = URL(string: "https://api.themoviedb.org/3/discover/tv?" + | |
| "include_null_first_air_dates=false&timezone=America%2FNew_York" + | |
| "&page=1&sort_by=popularity.desc&language=en-US" + | |
| "&api_key=<api_key>") | |
| var request = URLRequest(url: url!, cachePolicy: .useProtocolCachePolicy, timeoutInterval: 10.0) | |
| request.httpMethod = "GET" | |
| request.setValue("application/json; charset=utf-8", forHTTPHeaderField: "Content-Type") | |
| let session = URLSession.shared | |
| let dataTask = session.dataTask(with: request, completionHandler: { (data, response, error) -> Void in | |
| if (error != nil) { |
| import UIKit | |
| // Function as a argument. | |
| /* | |
| Reference: https://www.youtube.com/channel/UC-d1NWv5IWtIkfH47ux4dWA, The Swift Guy | |
| */ | |
| func animorphs(getMutation: (_ sugar: String, _ spice: String) -> String, humanSays: String, animalSays: String) -> String { | |
| return getMutation(humanSays, animalSays) |
| import UIKit | |
| // Function returns another function. | |
| /* | |
| Reference: https://www.youtube.com/channel/UC-d1NWv5IWtIkfH47ux4dWA, The Swift Guy | |
| */ | |
| func shouldVerify(_ chooseAction: Bool) -> (String, String) -> String { | |
| import UIKit | |
| // Stack implementation in Swift 3.1 | |
| class Node { | |
| let value: Int | |
| var nextNode: Node? | |
| init(value: Int) { | |
| self.value = value |
| import UIKit | |
| // Stack and Generics implementation in Swift 3.1 | |
| class Node<T> { | |
| let value: T | |
| var nextNode: Node<T>? | |
| var prevNode: Node<T>? | |
| init(value: T) { |
| [ | |
| {"name":"Israel","dial_code":"+972","code":"IL"}, | |
| {"name":"Afghanistan","dial_code":"+93","code":"AF"}, | |
| {"name":"Albania","dial_code":"+355","code":"AL"}, | |
| {"name":"Algeria","dial_code":"+213","code":"DZ"}, | |
| {"name":"AmericanSamoa","dial_code":"+1 684","code":"AS"}, | |
| {"name":"Andorra","dial_code":"+376","code":"AD"}, | |
| {"name":"Angola","dial_code":"+244","code":"AO"}, | |
| {"name":"Anguilla","dial_code":"+1 264","code":"AI"}, | |
| {"name":"Antigua and Barbuda","dial_code":"+1 268","code":"AG"}, |
| func timeAgoSinceDate(date:NSDate, numericDates:Bool) -> String { | |
| let calendar = NSCalendar.currentCalendar() | |
| let unitFlags = NSCalendarUnit.CalendarUnitMinute | NSCalendarUnit.CalendarUnitHour | NSCalendarUnit.CalendarUnitDay | NSCalendarUnit.CalendarUnitWeekOfYear | NSCalendarUnit.CalendarUnitMonth | NSCalendarUnit.CalendarUnitYear | NSCalendarUnit.CalendarUnitSecond | |
| let now = NSDate() | |
| let earliest = now.earlierDate(date) | |
| let latest = (earliest == now) ? date : now | |
| let components:NSDateComponents = calendar.components(unitFlags, fromDate: earliest, toDate: latest, options: nil) | |
| if (components.year >= 2) { | |
| return "\(components.year) years ago" |
| import UIKit | |
| let numbers = [1,2,3,4,5,6,7,8,9] | |
| struct Person { | |
| let name: String | |
| let age: Int | |
| init(name: String, age: Int) { | |
| self.name = name |