Skip to content

Instantly share code, notes, and snippets.

View alexpaul's full-sized avatar
:octocat:

Alex Paul alexpaul

:octocat:
View GitHub Profile
@alexpaul
alexpaul / SwiftUIDismissModalView.swift
Last active April 17, 2024 10:22
SwiftUI dismiss modal view presentation
// Works on Xcode 11 GM as of 09/12/19
// Presenting view
// make sure the .sheet modifier is tied to the root View
import SwiftUI
struct ContentView: View {
@State private var showingModalView = false
@alexpaul
alexpaul / subway-stops.json
Created November 11, 2021 22:47
Subway Stops - JSON
{
"00ac": {
"id": "00ac",
"location": [
40.829521,
-73.874516
],
"name": "Morrison Av- Sound View",
"stops": {
"610": [
@alexpaul
alexpaul / Bash.md
Last active February 26, 2024 10:36
Creating a Bash Profile

Bash

What is a bash_profile

There is a hidden file in your Mac’s user directory named .bash_profile. This file is loaded before Terminal loads your shell environment and contains all the startup configuration and preferences for your command line interface. Within it you can change your terminal prompt, change the colors of text, add aliases to functions you use all the time, and so much more.

Creating a .bash_profile

If you run the open ~/.bash_profile command and do not have a current .bash_profile, follow these steps to create one:

  1. Open Terminal
@alexpaul
alexpaul / AccessToRootViewController.swift
Last active January 3, 2024 03:47
Getting access to the SceneDelegate window object in Xcode 11. SceneDelegate. Reset application window. Reset window. Reset rootviewcontroller. Root view controller. Scene delegate.
// accessing the window and changing the root view controller property
override func viewDidLoad() {
super.viewDidLoad()
// getting access to the window object from SceneDelegate
guard let windowScene = UIApplication.shared.connectedScenes.first as? UIWindowScene,
let sceneDelegate = windowScene.delegate as? SceneDelegate
else {
return
}
let viewcontroller = UIViewController()
@alexpaul
alexpaul / DSA-Rubric.md
Last active November 21, 2023 01:17
Rubric. Mock Interview. Technical Interview.

DSA Whiteboarding Rubric

 
// Summary of steps
/*
0. understand the prompt (question)
1. clarifying questions (ask at least 2 clarification questions)
2. pseudo code 
3. test your pseudo code 
4. ask the interviewer if you can start coding after testing your pseudocode
@alexpaul
alexpaul / Date.swift
Last active October 22, 2023 06:33
Using Date in Swift, using ISO8601DateFormatter() and DateFormatter()
// Date extension
extension Date {
static func getStringFromDate(date: Date) -> String {
let dateFormatter = DateFormatter()
dateFormatter.dateFormat = "EEEE, MMM d, yyyy"
let dateString = dateFormatter.string(from: date)
return dateString
}
static func getDateFromString(dateString: String) -> Date? {
let formatter = ISO8601DateFormatter()
@alexpaul
alexpaul / ScrollView.swift
Last active October 4, 2023 12:45
ScrollView programmatically. UIScrollView.
import UIKit
final class DetailView: UIView {
// setting up a scroll view
// 1. add scrollview
// 2. add content view
// 3. add subviews to content view
// Note: must set high priority of content view to low, default is 1000
@alexpaul
alexpaul / HackerRank-Questions.md
Last active July 28, 2023 05:34
HackerRank Practice Questions

HackerRank Questions / Solutions

Swift Solution

// https://www.hackerrank.com/challenges/missing-numbers/problem
@alexpaul
alexpaul / CoreData-Saving-Array.md
Last active June 16, 2023 12:23
Core Data saving an array.

Core Data (Saving an array)

While saving an array to Core Data is supported, one of the first questions you will want to ask, if this array should be a relationship to another entity instead? It the answer is no, then continue reading on....

1. Core Data Model (Graphical Interface)

Set the attribute, in this case, the type you want to save as an array to Core Data supported type Binary Data

Example
attribute is hobbies

@alexpaul
alexpaul / Git-Branch.md
Last active June 2, 2023 17:18
Getting started with branches in git.

Branching Instructions

Branches allow for experimentation, team collaboration and working on features in git. By default a repository comes with one branch, that being the master branch. As you need to refactor code, test out other features on a project you can create a new branch. This new branch will be created from the history and commits from an existing branch e.g master and will have all the commit history of the branch.

Create a new branch

git branch feature-branch

Checkout a specific branch

In order to checkout a specific branch using Terminal