Skip to content

Instantly share code, notes, and snippets.

View alexpaul's full-sized avatar
:octocat:

Alex Paul alexpaul

:octocat:
View GitHub Profile
{
"results": [
{
"gender": "male",
"name": {
"title": "Monsieur",
"first": "Alfonso",
"last": "Rolland"
},
"location": {
@alexpaul
alexpaul / Swift-Fundamental-Topics.md
Created October 13, 2020 18:08
Swift Language Fundamental Topics.

Swift Fundamental Topics

  • The Basics: assertions (only in dev), preconditions (in dev and prod)
  • Basic Operators (+, -, *, /, ==, >=, <=, ||, &&, ..., ..<)
  • Strings and Characters
  • Colleciton Types (Array, Sets, Dictionaries, KeyValuePairs)
  • Control Flow
  • Functions: defer, inout, subscript
  • Closures: callbacks
  • Enumerations
@alexpaul
alexpaul / Stack-In-class-notes.swift
Last active October 7, 2020 09:41
Stack notes - incomplete implementation [MARKED FOR DELETION]
//
// main.swift
// Stack
//
// Created by Alex Paul on 10/6/20.
//
import Foundation
struct Stack<T> {
@alexpaul
alexpaul / ReverseLinkedList.swift
Created September 16, 2020 16:37
Reverse a Linked List
// Created by Alex Paul on 9/16/20.
// Copyright © 2020 Alex Paul. All rights reserved.
//
import Foundation
// Reverse a singly linked list.
class Node {
var value: Int
@alexpaul
alexpaul / Using-readLine.md
Last active September 10, 2020 02:18
Using `readLine()` to take in STDIN (input) from the user or command line and printing to the console (STDOUT).
import Foundation 

func add(a: Int, b: Int) -> Int {
  return a + b 
}

while true {
  print("enter a")
 let a = Int(readLine() ?? "") ?? 0
@alexpaul
alexpaul / MakingSectionsFromArray.swift
Last active August 26, 2020 23:25
Making sections for a 2D array to be used in a CollectionView or TableView. [Fellow] => [[Fellow]]
// Making sections for a 2D array to be used in a CollectionView or TableView. [Fellow] => [[Fellow]]
import Foundation
struct Fellow {
let name: String
let cohort: String
static func allFellows() -> [Fellow] {
return [
@alexpaul
alexpaul / Publishers-Subscribers.swift
Created August 5, 2020 11:04
Publishers and Subscribers in Combine.
import Foundation
import Combine
let publisherArr = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0].publisher
// publisher is of type Publishers.Sequence<[Double], Never>
// the generic type here takes two arguments <Output, Failure>
// in this case the our publisherArr will "Never" fail.
@alexpaul
alexpaul / SwiftUI-Animate-Button.swift
Created August 1, 2020 00:08
SwiftUI. Animate Button.
import SwiftUI
struct ContentView: View {
@State private var scale: CGFloat = 1
var body: some View {
Button(action: {
withAnimation(.easeIn(duration: 1)) {
self.scale += 20
}
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
import Combine
class Event {
@Published var calendarYear = 2020 // initial value
}
let event = Event() // new instance of Event
event.$calendarYear
@alexpaul
alexpaul / JSONCheatSheet.md
Last active July 28, 2020 17:35
Working with JSON. Multiple dictionary JSON. Heterogeneous JSON.

JSON Cheatsheet

1. Working with JSON where the root level is ONE dictionary

let jsonDict = """
{
 "results": [
   {
     "firstName": "John",