Skip to content

Instantly share code, notes, and snippets.

View roz0n's full-sized avatar
🏁

Arnold Rozon roz0n

🏁
View GitHub Profile
@roz0n
roz0n / compile_swift_steps.sh
Created April 10, 2024 05:16
Automates the process of transforming a Swift file through the various stages of compilation: from Swift code to SIL, from SIL to LLVM IR, and finally to assembly.
#!/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%.*}
@roz0n
roz0n / mongodb_cheat_sheet.md
Created December 6, 2022 19:58 — forked from bradtraversy/mongodb_cheat_sheet.md
MongoDB Cheat Sheet

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

@roz0n
roz0n / routes.swift
Last active September 19, 2021 23:23
RC Database Server (Swift/Vapor)
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.
@roz0n
roz0n / remove-prev-vc.swift
Created April 16, 2021 01:10
Remove Previous ViewController in UINavigationController
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)
@roz0n
roz0n / FillOther.swift
Last active April 10, 2021 08:08
UIView fillOther
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)
])
}
@roz0n
roz0n / detached-vc-solution.swift
Created February 22, 2021 06:13
Presenting from detached view controllers in Swift
// 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) {
@roz0n
roz0n / programmatic-ui.swift
Created February 21, 2021 18:59
iOS SceneDelegate Programmatic UI Setup
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()
@roz0n
roz0n / guap-country-currency-data.js
Last active February 13, 2021 02:04
Combine ExchangeRate API currency codes, ISO codes, and full country names
// ExchangeRate API Supported Currencies
const currencies = {
"AED": {
"FIELD2": "UAE Dirham",
"FIELD3": "United Arab Emirates"
},
"AFN": {
"FIELD2": "Afghan Afghani",
"FIELD3": "Afghanistan"
},
@roz0n
roz0n / iac-docker-node-ecr.md
Created February 1, 2021 20:40
Containerizing a Node App & Creating an Image Repo on ECR

Containerizing a Node App & Creating an Image Repo on ECR

What and Why

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.

Creating node-test

You should already know how to create a simple Node app with a single endpoint, but if you don't...

@roz0n
roz0n / iac-terraform-ec2.md
Created February 1, 2021 20:40
IAC with Terraform

IAC with Terraform

What and Why

  • 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
  • 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