- Install Docker Desktop for Mac
- Download the
unifi-controller
container.
docker pull linuxserver/unifi-controller
// Create a dictionary with the key the index of each item in the array. | |
// The value is the difference between the array's value and the target. | |
// Now if we want to find the first solution that contains sum, just loop | |
// through the array and check the dictionary for other numbers who match the difference. | |
class Solution { | |
func twoSum(_ nums: [Int], _ target: Int) -> [Int] { | |
var dict = [Int:Int]() | |
for (i, val) in nums.enumerated() { |
//https://leetcode.com/problems/number-of-recent-calls/ | |
// Tried for loop, etc. While loop was the best when dealing with 10000 requests | |
// Write a class RecentCounter to count recent requests. | |
// It has only one method: ping(int t), where t represents some time in milliseconds. | |
// Return the number of pings that have been made from 3000 milliseconds ago until now. | |
// Any ping with time in [t - 3000, t] will count, including the current ping. | |
// It is guaranteed that every call to ping uses a strictly larger value of t than before. | |
class RecentCounter { |
// When you rotate a screen, prevent animations and just snap into place | |
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { | |
coordinator.animate(alongsideTransition: nil) { _ in | |
UIView.setAnimationsEnabled(true) | |
} | |
UIView.setAnimationsEnabled(false) | |
super.viewWillTransition(to: size, with: coordinator) | |
} |
(lldb) expr CATransaction.flush() | |
// This simple command will update your UI on your device while you are at a breakpoint. |
extension UIViewController { | |
func topPresentedViewController() -> UIViewController? { | |
var topViewController: UIViewController? = self | |
while true { | |
if topViewController?.presentedViewController != nil { | |
topViewController = topViewController?.presentedViewController | |
} else { | |
return topViewController | |
} | |
} |
import Foundation | |
import UIKit | |
let json = """ | |
[{ | |
"first_name": "Shakti", | |
"last_name": "prakash", | |
"age":25, | |
"address":"Cuttack,Odisha,India" | |
}, |
extension Date { | |
func timeAgoSinceDate() -> String { | |
// From Time | |
let fromDate = self | |
// To Time | |
let toDate = Date() | |
let time = Calendar.current.dateComponents([.month, .day, .hour, .minute, .second], from: fromDate, to: toDate) |
Medium post with a ton of resources | |
https://medium.com/swlh/5-tools-to-speed-up-your-app-development-6979d0e49e34 | |
Repo full of awesome swift projects | |
https://github.com/vsouza/awesome-ios | |
Cool UIKit designs | |
https://www.invisionapp.com/inside-design/design-resources/now/ | |
https://www.invisionapp.com/inside-design/design-resources/tethr/ | |
https://www.sketchappsources.com/free-source/attachment-1722-phoenix-ui-kit-sketch-freebie-resource-img2.html |
//Modified from: | |
//http://swiftquickstart.blogspot.com/2016/10/adding-done-button-to-keyboard.html | |
extension UITextField { | |
func addKeyboardDoneButton() { | |
let keyboardToolBar = UIToolbar() | |
keyboardToolBar.sizeToFit() | |
let flexibleSpace = UIBarButtonItem(barButtonSystemItem: | |
UIBarButtonItem.SystemItem.flexibleSpace, target: nil, action: nil) | |
let doneButton = UIBarButtonItem(barButtonSystemItem: |
unifi-controller
container.docker pull linuxserver/unifi-controller