show dbs
This file contains 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
#!/bin/bash | |
# Check if an argument (Swift file name) was provided | |
if [ "$#" -ne 1 ]; then | |
echo "Usage: $0 <Swift File>" | |
exit 1 | |
fi | |
SWIFT_FILE=$1 | |
BASE_NAME=${SWIFT_FILE%.*} |
This file contains 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 Vapor | |
import RediStack | |
/** | |
The following is a routes file for a Vapor server that exposes two routes, "get" and "set", both of which accept query params. | |
The "get" route returns the value of a given key if it exists, while the "set" route stores each provided key/value pair in a Redis cache. | |
As per Vapor's conventions, the Redis configuration exists in the `Sources/App/Controllers/configure.swift` file which is not included in this Gist. | |
This file contains 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
fileprivate func removePreviousViewController() { | |
guard let navigationController = self.navigationController else { return } | |
let controllerToRemove = "ConfirmationViewController" | |
var allControllers = navigationController.viewControllers | |
for (index, controller) in allControllers.enumerated() { | |
let name = String(describing: type(of: controller)) | |
if name == controllerToRemove { | |
allControllers.remove(at: index) |
This file contains 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 fillOther(view: UIView) { | |
NSLayoutConstraint.activate([ | |
leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor), | |
trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor), | |
topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), | |
bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor) | |
]) | |
} |
This file contains 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
// UIViewController extension to get root VC | |
func getRootViewController(of nestedViewController: UIViewController) -> UIViewController? { | |
return nestedViewController.view.window?.rootViewController | |
} | |
// In use inside non-root VC | |
let vc = UINavigationController(rootViewController: CurrencySelectorViewController(type: type)) | |
vc.modalPresentationStyle = .overFullScreen | |
if let root = getRootViewController(of: self) { |
This file contains 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 scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { | |
guard let scene = (scene as? UIWindowScene) else { return } | |
let vc = ViewController() | |
let nc = UINavigationController(rootViewController: vc) | |
window = UIWindow(frame: scene.coordinateSpace.bounds) | |
window?.windowScene = scene | |
window?.rootViewController = nc | |
window?.makeKeyAndVisible() |
This file contains 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
// ExchangeRate API Supported Currencies | |
const currencies = { | |
"AED": { | |
"FIELD2": "UAE Dirham", | |
"FIELD3": "United Arab Emirates" | |
}, | |
"AFN": { | |
"FIELD2": "Afghan Afghani", | |
"FIELD3": "Afghanistan" | |
}, |
This document assumes you already have Docker installed and likewise are familiar with its use-cases. In essence, Docker is used to package our applications as standardized executable components (containers) that combine application source code with all the operating system libraries and dependencies required to run the code in any (typically cloud) environment(s).
There are many benefits to this, and there are likewise many caveats. Refer to Google to learn more.
You should already know how to create a simple Node app with a single endpoint, but if you don't...
- Terraform is a tool used for building, changing, and versioning infrastructure safely and efficiently
- It supports many service providers, likewise one could roll their own custom or in-house solutions
- IAC is defined using high-level languages
HCL
and good ol'JSON
- We'll start with
HCL
later on as it's more commonly used for these purposes
- We'll start with
- Sysadmins used to purchase hardware, set up servers with network and software, and also maintain/modify them manually
- Repetitive and time consuming
- By definition, IAC is the process of managing and provisioning infrastructure through code instead of physical hardware configuration and interactive configuration tools
NewerOlder