├── .gitignore ├── guides ├── java.pdf ├── exceptions.pdf ├── technical_interviews.pdf ├── google-compute-engine-vm-guide.pdf ├── google-compute-engine-vm-guide-BoUoW.pdf ├── google-compute-engine-vm-guide-windows.pdf ├── deployment │ └── Create-Preconfigured-Google-Compute-Engine-Virtual-Machines.docx ├── README.md ├── setup-google-vm.md ├── postgres.md ├── git.md ├── static-webpage-hosting.md └── google-cloud-node-deployment.md ├── lecture-notes ├── lecture_slides_01.pdf ├── lecture_slides_02.pdf ├── lecture_slides_03.pdf ├── lecture_slides_04.pdf ├── lecture_slides_06.pdf ├── lecture_slides_07.pdf ├── 00.1_2016-06-28 │ └── summer_01.pdf ├── 00.2_2016-07-12 │ ├── homework_02.md │ ├── nvm.md │ └── javascript-basics.md ├── 02 │ └── class-notes.md └── README.md ├── lab-notes ├── lab-1 │ ├── linked_lists_handout.pdf │ ├── lab1_harness.java │ └── lab1_solution.java ├── lab-2 │ ├── lab2_harness.java │ ├── lab2_solution.java │ └── stacks_queues_sets_handout.md ├── lab-4 │ ├── lab4_harness.java │ └── trees_handout.md ├── lab-3 │ ├── lab3_harness.java │ ├── searching_and_sorting_handout.md │ └── lab3_solution.java ├── readme.md └── lab-5 │ └── hashing_handout.md ├── docs ├── CUNY_Tech_Prep_Syllabus_Fall_2016.pdf ├── CTP_16-17_Professional_Skills_Curriculum.pdf ├── CUNY_Tech_Prep_Summer_Course_Overview_06.28.16.pdf └── readme.md ├── project_assignments ├── demo_project_proposal_1.pdf ├── team_demo_project_proposal_1.pdf ├── project_progress_presentation_template.pdf └── readme.md └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_STORE 2 | 3 | -------------------------------------------------------------------------------- /guides/java.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/guides/java.pdf -------------------------------------------------------------------------------- /guides/exceptions.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/guides/exceptions.pdf -------------------------------------------------------------------------------- /guides/technical_interviews.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/guides/technical_interviews.pdf -------------------------------------------------------------------------------- /lecture-notes/lecture_slides_01.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/lecture-notes/lecture_slides_01.pdf -------------------------------------------------------------------------------- /lecture-notes/lecture_slides_02.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/lecture-notes/lecture_slides_02.pdf -------------------------------------------------------------------------------- /lecture-notes/lecture_slides_03.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/lecture-notes/lecture_slides_03.pdf -------------------------------------------------------------------------------- /lecture-notes/lecture_slides_04.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/lecture-notes/lecture_slides_04.pdf -------------------------------------------------------------------------------- /lecture-notes/lecture_slides_06.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/lecture-notes/lecture_slides_06.pdf -------------------------------------------------------------------------------- /lecture-notes/lecture_slides_07.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/lecture-notes/lecture_slides_07.pdf -------------------------------------------------------------------------------- /lab-notes/lab-1/linked_lists_handout.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/lab-notes/lab-1/linked_lists_handout.pdf -------------------------------------------------------------------------------- /docs/CUNY_Tech_Prep_Syllabus_Fall_2016.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/docs/CUNY_Tech_Prep_Syllabus_Fall_2016.pdf -------------------------------------------------------------------------------- /guides/google-compute-engine-vm-guide.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/guides/google-compute-engine-vm-guide.pdf -------------------------------------------------------------------------------- /lecture-notes/00.1_2016-06-28/summer_01.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/lecture-notes/00.1_2016-06-28/summer_01.pdf -------------------------------------------------------------------------------- /guides/google-compute-engine-vm-guide-BoUoW.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/guides/google-compute-engine-vm-guide-BoUoW.pdf -------------------------------------------------------------------------------- /project_assignments/demo_project_proposal_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/project_assignments/demo_project_proposal_1.pdf -------------------------------------------------------------------------------- /docs/CTP_16-17_Professional_Skills_Curriculum.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/docs/CTP_16-17_Professional_Skills_Curriculum.pdf -------------------------------------------------------------------------------- /guides/google-compute-engine-vm-guide-windows.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/guides/google-compute-engine-vm-guide-windows.pdf -------------------------------------------------------------------------------- /project_assignments/team_demo_project_proposal_1.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/project_assignments/team_demo_project_proposal_1.pdf -------------------------------------------------------------------------------- /docs/CUNY_Tech_Prep_Summer_Course_Overview_06.28.16.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/docs/CUNY_Tech_Prep_Summer_Course_Overview_06.28.16.pdf -------------------------------------------------------------------------------- /project_assignments/project_progress_presentation_template.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/project_assignments/project_progress_presentation_template.pdf -------------------------------------------------------------------------------- /guides/deployment/Create-Preconfigured-Google-Compute-Engine-Virtual-Machines.docx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/medgardo/ctp2016/HEAD/guides/deployment/Create-Preconfigured-Google-Compute-Engine-Virtual-Machines.docx -------------------------------------------------------------------------------- /docs/readme.md: -------------------------------------------------------------------------------- 1 | **CUNY Tech Prep 2016-2017** 2 | 3 | # Program Documents 4 | 5 | * [Technical Curriculum Syllabus](CUNY_Tech_Prep_Syllabus_Fall_2016.pdf) 6 | * [Professional Skills Curriculum](CTP_16-17_Professional_Skills_Curriculum.pdf) 7 | * [Private Shared Folder](https://www.dropbox.com/sh/k03g0tihuocg57x/AADnKKS_9mdz4ZNBgt2lcyYUa?dl=0) 8 | - This folder contains additional documents. 9 | -------------------------------------------------------------------------------- /guides/README.md: -------------------------------------------------------------------------------- 1 | **CUNY Tech Prep 2016-2017** 2 | # Guides and Resources 3 | 4 | 5 | * [Preparing for the Technical Interview](technical_interviews.pdf) 6 | * [Learn/Review Java Programming](java.pdf) 7 | * [Learn Exceptions in Java and JavaScript](exceptions.pdf) 8 | * [Learn to use Git](git.md) 9 | * [Setup Google Compute Engine VM](setup-google-vm.md) 10 | * [Static Webpage Hosting](static-webpage-hosting.md) 11 | -------------------------------------------------------------------------------- /lab-notes/lab-2/lab2_harness.java: -------------------------------------------------------------------------------- 1 | // Lab 2 Solution 2 | import java.util.*; 3 | import java.util.Scanner; 4 | 5 | 6 | /*********************************************************************/ 7 | // Write your code here 8 | 9 | 10 | 11 | // Write your solution above 12 | /*********************************************************************/ 13 | 14 | class Solution{ 15 | 16 | public static void main(String []argh) 17 | { 18 | Parser X=new Parser(); 19 | Scanner in = new Scanner(System.in); 20 | 21 | while (in.hasNext()) { 22 | System.out.println(X.checkParenthesesBalance(in.next())); 23 | } 24 | 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /lab-notes/lab-4/lab4_harness.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | public class Solution { 8 | /* 9 | * Complete the function below. 10 | */ 11 | 12 | static void createBST(int[] keys) { 13 | 14 | 15 | } 16 | 17 | 18 | 19 | public static void main(String[] args){ 20 | Scanner in = new Scanner(System.in); 21 | 22 | int _keys_size = 0; 23 | _keys_size = Integer.parseInt(in.nextLine().trim()); 24 | int[] _keys = new int[_keys_size]; 25 | int _keys_item; 26 | for(int _keys_i = 0; _keys_i < _keys_size; _keys_i++) { 27 | _keys_item = Integer.parseInt(in.nextLine().trim()); 28 | _keys[_keys_i] = _keys_item; 29 | } 30 | 31 | createBST(_keys); 32 | 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /lecture-notes/00.2_2016-07-12/homework_02.md: -------------------------------------------------------------------------------- 1 | # Homework 2 (Due July 29, 2016) 2 | 3 | 1. Build a personal (professional) webpage. Follow the following criteria 4 | * Use HTML5, CSS, Bootstrap 5 | - You can use exisiting themes (i.e. http://bootswatch.com/) 6 | * For the content: 7 | - Introduce yourself 8 | - Post projects you have done 9 | - Education/Professional Experience, Relevant Skills 10 | - List any technology or blog links you recommend 11 | - Post a "blog" entry about a technology you have used, or school topic 12 | - Include at least one image (project related, you, or related picture) 13 | * Examples: 14 | - http://ccvcl.org/~molina/ 15 | - http://www.crockford.com/ 16 | - http://david.heinemeierhansson.com/ 17 | - Don't copy these, DO BETTER! 18 | 2. Complete the Codecademy courses on JavaScript and HTML&CSS 19 | 3. Self-paced JQuery Class 20 | * https://www.codecademy.com/learn/jquery 21 | * Complete all units (can skip PRO sections) 22 | 23 | 24 | -------------------------------------------------------------------------------- /lab-notes/lab-3/lab3_harness.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | public class Solution { 8 | 9 | 10 | /*********************************************************************/ 11 | // Write your code here 12 | 13 | 14 | /* 15 | * Complete the function below. 16 | */ 17 | 18 | static void customSort(int[] arr) { 19 | 20 | 21 | } 22 | 23 | // Write your solution above 24 | /*********************************************************************/ 25 | 26 | public static void main(String[] args){ 27 | Scanner in = new Scanner(System.in); 28 | 29 | int _arr_size = 0; 30 | _arr_size = Integer.parseInt(in.nextLine().trim()); 31 | int[] _arr = new int[_arr_size]; 32 | int _arr_item; 33 | for(int _arr_i = 0; _arr_i < _arr_size; _arr_i++) { 34 | _arr_item = Integer.parseInt(in.nextLine().trim()); 35 | _arr[_arr_i] = _arr_item; 36 | } 37 | 38 | customSort(_arr); 39 | 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lecture-notes/00.2_2016-07-12/nvm.md: -------------------------------------------------------------------------------- 1 | # Setting up Node.js 2 | Node.js is very frequently being updated. As a result, certain applications become dependent on a specific version. Developers may need to install multiple versions to support different projects. This can get messy, so we use a version manager to install multiple node.js versions and switch between them. 'nvm' is the node version manager I recommend. 3 | 4 | ## Install nvm 5 | ```bash 6 | # Install nvm 7 | sudo apt-get update 8 | sudo apt-get install build-essential libssl-dev curl 9 | curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.31.2/install.sh | bash 10 | source ~/.profile 11 | 12 | # check that nvm is available 13 | command -v nvm 14 | 15 | # Install node.js version 16 | nvm install 6.2.2 17 | 18 | # Verify that it is installed 19 | nvm ls 20 | 21 | # check the node version 22 | node -v 23 | 24 | # Run node repl (read-eval-print loop) 25 | node 26 | ``` 27 | 28 | 29 | ## Installing other versions 30 | You can look up other available versions by running `nvm ls-remote` 31 | and switch among installed versions with the command `nvm use 5.x` 32 | 33 | # About nvm 34 | https://github.com/creationix/nvm 35 | 36 | # Node versions and reading the changelog 37 | https://nodejs.org/en/ 38 | https://github.com/nodejs/node/blob/master/doc/changelogs/CHANGELOG_V6.md#6.3.0 39 | 40 | -------------------------------------------------------------------------------- /guides/setup-google-vm.md: -------------------------------------------------------------------------------- 1 | # Setup Google Compute Engine VM 2 | 3 | We will be using Google Cloud Platform services to deploy our webpages and applications throughout the semester. Through the Google Education program, we have received $50 credits for each of you to use the rest of the semester. (_Note: You do not need a credit card to claim the credits_) 4 | 5 | To setup your Compute Engine VM, you will have to: 6 | 7 | 1. Claim your credit (using your edu emails) 8 | 2. Create a project and link your credit for billing 9 | 3. Create SSH keys 10 | 4. Create a Compute Engine VM 11 | - **IMPORTANT:** Make sure you create a Micro VM, that costs **under $5 per month**. If you create a larger VM, you will spend your credit too quickly, and wont be able to do a demo at the end of the program! 12 | 5. Verify you can login to your VM from your local machine 13 | 6. Publish your personal webpage to your new VM using the ["Static Webpage Hosting guide"](static-webpage-hosting.md) 14 | 15 | Guides for steps 1-5 for Mac, Windows, and Linux were created by your fellow classmates (Thanks Ammad Khan, Robinson Collado, and Jean Peña): 16 | 17 | * General Guide (all platforms): [google-compute-engine-vm-guide.pdf](google-compute-engine-vm-guide.pdf) 18 | * With Windows screenshots: [google-compute-engine-vm-guide-windows.pdf](google-compute-engine-vm-guide-windows.pdf) 19 | * [Advanced Windows Users] Learn about Bash on Ubuntu on Windows: [google-compute-engine-vm-guide-BoUoW.pdf](google-compute-engine-vm-guide-BoUoW.pdf) 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /lab-notes/lab-3/searching_and_sorting_handout.md: -------------------------------------------------------------------------------- 1 | **CUNY Tech Prep 2016-2017** 2 | 3 | # Lab 3 Handout: Searching and Sorting Algorithms 4 | 5 | ## Definitions 6 | 7 | * [Searching](https://en.wikipedia.org/wiki/Search_algorithm) 8 | - A search algorithm is an algorithm that _retrieves_ information stored within some data structure. 9 | * [Sorting](https://en.wikipedia.org/wiki/Sorting_algorithm) 10 | - A sorting algorithm is an algorithm that _puts_ elements of a list in a certain _order_. 11 | 12 | 13 | ## Review Materials 14 | 15 | *Videos:* 16 | 17 | * [Binary Search, High-level description](https://www.youtube.com/watch?v=JQhciTuD3E8) (7min) 18 | * [Binary Search, Recursive Java Code](https://www.youtube.com/watch?v=8y_rX89Yzf4) (20min) 19 | * [Java Sorting algorithms, by Derek Banas](https://www.youtube.com/watch?v=JUOyKSZScW0) (19min) 20 | 21 | 22 | *Textbook:* 23 | 24 | * [Searching and Sorting](http://math.hws.edu/javanotes/c7/s4.html) 25 | * [Sorting Algorithms](http://www.brpreiss.com/books/opus5/html/page478.html#SECTION0016000000000000000000) 26 | * [Sorting Algorithms, Chapter 11](http://opendatastructures.org/ods-java.pdf) 27 | 28 | 29 | *Additional Resources:* 30 | 31 | * [Binary Search, Bubble and Selection Sorts (MIT course in python)](https://www.youtube.com/watch?v=RONUdefYb1k) (45min) 32 | 33 | ### Questions to consider 34 | 35 | * Searching Algorithms 36 | - What is the run-time? 37 | - Can I efficiently search un-sorted data? 38 | * Sorting Algorithms 39 | - What is an in-place sorting algorithm? 40 | - What are the benefits of in-place algorithms? 41 | - What is a stable sorting algorithm? 42 | - When would I prefer a stable sorting algorithm? 43 | -------------------------------------------------------------------------------- /lab-notes/lab-2/lab2_solution.java: -------------------------------------------------------------------------------- 1 | // Lab 2 Solution 2 | import java.util.*; 3 | import java.util.Scanner; 4 | 5 | 6 | /*********************************************************************/ 7 | // Write your code here 8 | 9 | class Parser { 10 | 11 | public Parser() {} 12 | 13 | private boolean isOpen(char c) { 14 | return (c == '(' || c == '{'); 15 | } 16 | 17 | private boolean isClose(char c) { 18 | return (c == ')' || c == '}'); 19 | } 20 | 21 | private boolean isMatch(char a, char z) { 22 | if (a == '{' && z == '}') 23 | return true; 24 | if (a == '(' && z == ')') 25 | return true; 26 | 27 | return false; 28 | } 29 | 30 | public boolean checkParenthesesBalance(String str) { 31 | Stack s = new Stack(); 32 | 33 | for(char c: str.toCharArray()) { 34 | if( isOpen(c) ) { 35 | s.push(c); 36 | } else if( isClose(c)) { 37 | if (s.empty()) 38 | return false; 39 | char t = (char)s.pop(); 40 | if (!isMatch(t,c)) 41 | return false; 42 | } 43 | } 44 | 45 | if(s.empty()) 46 | return true; 47 | else 48 | return false; 49 | } 50 | } 51 | 52 | // Write your solution above 53 | /*********************************************************************/ 54 | 55 | class Solution{ 56 | 57 | public static void main(String []argh) 58 | { 59 | Parser X=new Parser(); 60 | Scanner in = new Scanner(System.in); 61 | 62 | while (in.hasNext()) { 63 | System.out.println(X.checkParenthesesBalance(in.next())); 64 | } 65 | 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /lab-notes/readme.md: -------------------------------------------------------------------------------- 1 | **CUNY Tech Prep 2016-2017** 2 | 3 | # Lab Notes 4 | 5 | _Latest lab material at the bottom_ 6 | 7 | You can access all Coding Challenge questions and some test inputs in the [private shared folder](https://www.dropbox.com/sh/k03g0tihuocg57x/AADnKKS_9mdz4ZNBgt2lcyYUa?dl=0) 8 | 9 | ## Lab 1 10 | **September 6-9, 2016** 11 | 12 | ### Coding Challenge: Linked Lists 13 | 14 | * *Name:* CTP Lab 1 15 | * *Due date:* September 6, 2016 16 | * [Review Handout 1](lab-1/linked_lists_handout.pdf) 17 | * [Harness Code](lab-1/lab1_harness.java) 18 | * [Solution](lab-1/lab1_solution.java) 19 | 20 | ### In Lab Work 21 | 22 | * Group Formation 23 | * Development Environment Debugging 24 | 25 | 26 | ## Lab 2 27 | **September 20-23, 2016** 28 | 29 | ### Coding Challenge: Stacks 30 | 31 | * *Name:* CTP Lab 2 32 | * *Due date:* September 20, 2016 by Noon 33 | * [Review Handout 2](lab-2/stacks_queues_sets_handout.md) 34 | * [Harness Code](lab-2/lab2_harness.java) 35 | * [Solution](lab-2/lab2_solution.java) 36 | 37 | 38 | ## Lab 3 39 | **October 5-14, 2016** 40 | 41 | ### Coding Challenge: Sorting 42 | 43 | * *Name:* CTP Lab 3 44 | * *Due date:* October 5, 2016 by Noon 45 | * [Review Handout 3](lab-3/searching_and_sorting_handout.md) 46 | * [Harness Code](lab-3/lab3_harness.java) 47 | * [Solution](lab-3/lab3_solution.java) 48 | 49 | 50 | ## Lab 4 51 | **October 28 - November 7, 2016** 52 | 53 | ### Coding Challenge: Binary Search Trees 54 | 55 | * *Name:* CTP Lab 4 56 | * *Due date:* November 7, 2016 by Noon 57 | * [Review Handout 4](lab-4/trees_handout.md) 58 | * [Harness Code](lab-4/lab4_harness.java) 59 | 60 | 61 | ## Lab 5 62 | **November 11 - November 28, 2016** 63 | 64 | ### Coding Challenge: Hashing 65 | 66 | * *Name:* CTP Lab 5 67 | * *Due date:* November 28, 2016 by Noon 68 | * Challenge has 3 separate questions (easy, medium, hard) and timed separately. 69 | * [Review Handout 5](lab-5/hashing_handout.md) 70 | 71 | -------------------------------------------------------------------------------- /lab-notes/lab-4/trees_handout.md: -------------------------------------------------------------------------------- 1 | **CUNY Tech Prep 2016-2017** 2 | 3 | # Lab 4 Handout: Trees and Binary Search Trees 4 | 5 | ## Definitions 6 | 7 | * [Tree](https://en.wikipedia.org/wiki/Tree_(data_structure)) 8 | - A tree is a hierarchical data structure for storing information _items_ and linking between them. Items are stored in _nodes_ and each node can link to 0 or more subtrees. 9 | - The most common trees are _rooted trees_, although they don't have to be. 10 | * [Binary Search Tree](https://en.wikipedia.org/wiki/Binary_search_tree) 11 | - A binary search tree is a rooted binary tree, that maintains linked subtrees in order. 12 | - A binary tree, is a tree in which nodes have _at most_ two subtrees. 13 | 14 | 15 | ## Review Materials 16 | 17 | *Videos:* 18 | 19 | * [Heaps and Trees (_Good Intro_)](https://www.youtube.com/watch?v=cqoGE1GPqU8) (32min) 20 | * [Binary Search Trees, Part 1, by Derek Banas](https://www.youtube.com/watch?v=M6lYob8STMI) (14min) 21 | * [Binary Search Trees, Part 2, by Derek Banas](https://www.youtube.com/watch?v=UcOxGmj45AA) (14min) 22 | 23 | 24 | *Textbook:* 25 | 26 | * [Binary Trees](http://math.hws.edu/javanotes/c9/s4.html) 27 | * [Trees](http://www.brpreiss.com/books/opus5/html/page252.html#SECTION0010000000000000000000) 28 | * [Search Trees](http://www.brpreiss.com/books/opus5/html/page298.html#SECTION0011000000000000000000) 29 | * [Binary Trees, Chapter 6 (Advanced Ch. 7, 8, 9)](http://opendatastructures.org/ods-java.pdf) 30 | 31 | 32 | *Additional Resources:* 33 | 34 | * [Binary Search Trees (MIT course: Theory)](https://www.youtube.com/watch?v=9Jry5-82I68) (53min) 35 | 36 | ### Questions to consider 37 | 38 | * Tree Operations 39 | - How do you insert, find, and remove items in a tree? 40 | - How do you perform _pre-order_, _in-order_, and _post-order_ traversals? 41 | * Unbalanced Trees 42 | - Can you insert data such that you produce a worst case BST? 43 | - How does an unbalanced tree affect tree operation runtime complexities? 44 | - How can you produce balanced BST? 45 | * When are _Heaps_ useful? 46 | 47 | 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CUNY Tech Prep 2016-2017 2 | 3 | _This repository contains program materials for the technical curriculum of the CUNY Tech Prep program._ 4 | 5 | [CUNY Tech Prep](http://cunytechprep.nyc/) is a [NYC Tech Talent Pipeline](http://www.techtalentpipeline.nyc/) program designed to provide exceptional Computer Science students in the CUNY senior college system with in-demand software development and professional skills. 6 | 7 | * [Technical Curriculum Syllabus](docs/CUNY_Tech_Prep_Syllabus_Fall_2016.pdf) 8 | * [Professional Skills Curriculum](docs/CTP_16-17_Professional_Skills_Curriculum.pdf) 9 | 10 | ## CUNY Tech Prep Team: 11 | 12 | - Lead Instructor: Edgardo Molina ([@molina](https://ctp2016.slack.com/messages/@molina/)) 13 | - Instructor: Donato Cruz ([@donato](https://ctp2016.slack.com/messages/@donato/)) 14 | - Lab Instructors: 15 | + Ameya Pednekar ([@ameya](https://ctp2016.slack.com/messages/@ameya/)) 16 | + Tom Lin ([@tlin](https://ctp2016.slack.com/messages/@tlin/)) 17 | + Elise Harris ([@elise9876](https://ctp2016.slack.com/messages/@elise9876/)) 18 | - Program Manager: Jonathan Tze ([@pm_jtze](https://ctp2016.slack.com/messages/@pm_jtze/)) 19 | - Program Assistant: Dariela Estrella ([@dariela.estrella](https://ctp2016.slack.com/messages/@dariela.estrella/)) 20 | - Career Coach: Rachel Fogel ([@rachelfogel](https://ctp2016.slack.com/messages/@rachelfogel/)) 21 | - Career Coach: Jonathan Crepeau ([@jtcrepeau](https://ctp2016.slack.com/messages/@jtcrepeau/)) 22 | 23 | --- 24 | 25 | The following is a brief overview of the contents of this repository. 26 | 27 | [`README.md`](README.md) 28 | 29 | > This file. 30 | 31 | [`/docs/`](docs) 32 | 33 | > This directory contains program Syllabus and other documents. 34 | 35 | [`/guides/`](guides) 36 | 37 | > This directory contains various guides and resources for self-learning topics and technologies we will not have time to dive into in lecture. 38 | 39 | [`/lab-notes/`](lab-notes) 40 | 41 | > This directory contains all of the lab materials including coding challenges for each lab module of the technical curriculum. 42 | 43 | [`/lecture-notes/`](lecture-notes) 44 | 45 | > This directory contains all of the lecture materials for each module of the technical curriculum 46 | 47 | [`/project_assignments/`](project_assignments) 48 | 49 | > This directory contains all of the materials and assignments related to your project assignments. 50 | 51 | -------------------------------------------------------------------------------- /lab-notes/lab-2/stacks_queues_sets_handout.md: -------------------------------------------------------------------------------- 1 | **CUNY Tech Prep 2016-2017** 2 | 3 | # Lab 2 Handout: Stacks, Queues, and Sets 4 | 5 | ## Definitions 6 | 7 | * [Stacks](https://en.wikipedia.org/wiki/Stack_(abstract_data_type)) 8 | - are an abstract data type that serves as an _ordered_ collection of elements. It provides two primary operations, `push(x)` to insert elements into the collection, and `pop()` to remove the most recently inserted element from the collection. This a **LIFO** (Last In, First Out) collection data type. 9 | * [Queues](https://en.wikipedia.org/wiki/Queue_(abstract_data_type)) 10 | - are an abstract data type that serves as an _ordered_ collection of elements. It provides two primary operations, `add(x)` to insert elements into the collection, and `remove()` to remove the first-most inserted element from the collection. This a **FIFO** (First In, First Out) collection data type. 11 | * [Sets](https://en.wikipedia.org/wiki/Set_(abstract_data_type)) 12 | - are an abstract data type that serves as an _unordered_ collection of elements. It provides two primary operations, `add(x)` to insert elements into the collection, and `remove(x)` to remove specific elements. The collection keeps only unique element values, discarding duplicate entries. 13 | 14 | ## Review Materials 15 | 16 | *Videos:* 17 | 18 | * [Stacks and Queues, by DerekBanas](https://www.youtube.com/watch?v=JvGZh_BdF-8&index=3&list=PLGLfVvz_LVvReUrWr94U-ZMgjYTQ538nT) (16min) 19 | * [Stacks and Queues, by BlondieBytes](https://www.youtube.com/watch?v=fOHLom4hZME) (27min) 20 | 21 | *Textbook:* 22 | 23 | * [Stacks, Queues, and Deques](http://www.brpreiss.com/books/opus5/html/page130.html#SECTION007000000000000000000) 24 | * [Basic Sets](http://www.brpreiss.com/books/opus5/html/page385.html#SECTION0013000000000000000000) 25 | * [Stacks and Queues](http://math.hws.edu/javanotes/c9/s3.html) 26 | 27 | *Additional Resources:* 28 | 29 | * [Test your knowledge, including Big-O](http://pages.cs.wisc.edu/~vernon/cs367/notes/5.STACKS-AND-QUEUES.html) 30 | 31 | ### Questions to consider 32 | 33 | * When do you use a _Stack_ vs a _Queue_? 34 | * Stacks and Queues are simply interfaces to abstract concepts. Both Stacks and Queues can be implemented with either Arrays or LinkedLists. In each case, there are pros and cons. For each, the stack and queue, compare the pros and cons of implementing it with Arrays vs LinkedLists. 35 | * What are the different ways we can implement a _Set_? 36 | -------------------------------------------------------------------------------- /lab-notes/lab-3/lab3_solution.java: -------------------------------------------------------------------------------- 1 | import java.io.*; 2 | import java.util.*; 3 | import java.text.*; 4 | import java.math.*; 5 | import java.util.regex.*; 6 | 7 | public class Solution { 8 | 9 | 10 | /*********************************************************************/ 11 | // Write your code here 12 | 13 | 14 | /* 15 | * Complete the function below. 16 | */ 17 | 18 | static void customSort(int[] arr) { 19 | // Sum frequencies (as values) of each value in arr[] (as keys). 20 | Map freq = new TreeMap(); 21 | 22 | for (int i : arr) { 23 | if(freq.get(i) != null) { 24 | freq.put(i, freq.get(i)+1); 25 | } else { 26 | freq.put(i, 1); 27 | } 28 | } 29 | 30 | // Create a new map, swapping freq's values and keys. Since there can be multiple keys per 31 | // frequency value, we collect them in an arraylist. 32 | Map> sorted_freq = new TreeMap>(); 33 | 34 | for(int key : freq.keySet()) { 35 | int val = freq.get(key); 36 | 37 | ArrayList kl; 38 | 39 | if(sorted_freq.get(val) != null) { 40 | kl = sorted_freq.get(val); 41 | } else { 42 | kl = new ArrayList(); 43 | } 44 | 45 | kl.add(key); 46 | sorted_freq.put(val, kl); 47 | } 48 | 49 | 50 | // Print all entries in sorted order. 51 | for( Map.Entry> e : sorted_freq.entrySet()) { 52 | ArrayList list = e.getValue(); 53 | for(int i: list) { 54 | // Print each value the number of times it appeared in arr[] 55 | for(int times=0; times x) { 49 | list = list.next; 50 | } 51 | 52 | // If the list is empty, or we removed all items, then return 53 | // the empty list 54 | if( list == null ) 55 | return list; 56 | 57 | // Use cur to traverse the list 58 | cur = list; 59 | 60 | // At this point, cur.val is valid. So I need to check cur.next.val 61 | while(cur.next != null) { 62 | if (cur.next.val > x) { 63 | cur.next = cur.next.next; // skip the node 64 | } else { 65 | cur = cur.next; // don't skip, just update cur 66 | } 67 | } 68 | 69 | return list; // return the head of the list 70 | } 71 | 72 | // Another alternative implementation is to create a second list which 73 | // inserts nodes less than or equal to x. Then return the head of that list. 74 | 75 | 76 | /*********************************************************************/ 77 | 78 | 79 | public static void main(String[] args) throws IOException{ 80 | Scanner in = new Scanner(System.in); 81 | final String fileName = System.getenv("OUTPUT_PATH"); 82 | BufferedWriter bw = new BufferedWriter(new FileWriter(fileName)); 83 | LinkedListNode res; 84 | 85 | int _list_size = 0; 86 | _list_size = Integer.parseInt(in.nextLine()); 87 | int _list_i; 88 | int _list_item; 89 | LinkedListNode _list = null; 90 | LinkedListNode _list_tail = null; 91 | for(_list_i = 0; _list_i < _list_size; _list_i++) { 92 | _list_item = Integer.parseInt(in.nextLine().trim()); 93 | if(_list_i == 0) { 94 | _list = _insert_node_into_singlylinkedlist(_list, _list_tail, _list_item); 95 | _list_tail = _list; 96 | } 97 | else { 98 | _list_tail = _insert_node_into_singlylinkedlist(_list, _list_tail, _list_item); 99 | } 100 | } 101 | 102 | int _x; 103 | _x = Integer.parseInt(in.nextLine().trim()); 104 | 105 | res = removeNodes(_list, _x); 106 | while (res != null) { 107 | bw.write(String.valueOf(res.val)); 108 | bw.newLine(); 109 | res = res.next; 110 | } 111 | 112 | bw.close(); 113 | } 114 | } 115 | 116 | -------------------------------------------------------------------------------- /guides/static-webpage-hosting.md: -------------------------------------------------------------------------------- 1 | # Static Webpage Hosting 2 | 3 | _This guide will show you the basic steps to host your static personal webpages on your Google Compute Engine VM (Or any other Ubuntu machine)_ 4 | 5 | ## Step 1: Setup your Google Compute Engine VM 6 | 7 | Make sure you have gone through the ["Setup Google Compute Engine"](setup-google-vm.md) guide first. 8 | 9 | ## Step 2: Install Apache HTTP Server 10 | 11 | Once you have your Google Cloud VM setup, you should login to your Compute Engine VM and run the following commands to install Apache, git, and curl: 12 | 13 | ```bash 14 | sudo apt-get update 15 | sudo apt-get install git curl apache2 16 | ``` 17 | 18 | Then, you should open a web browser and visit your Compute Engine VM's **external IP** on your web browser: http://111.222.333.444 (just an example, use your own external IP) 19 | 20 | If you see the "_Apache Ubuntu Default Page_" proceed to the next step. Otherwise report your issue on Slack. 21 | 22 | ## Step 3: Publish your webpage 23 | 24 | Assuming your static personal webpage code is in a Github repository (_where it should be!_), you can publish it with the following commands: 25 | 26 | ```bash 27 | cd /var/www/html 28 | sudo mv index.html ~/index.html.bak 29 | sudo sh -c 'curl -sL https://github.com/USERNAME/REPO_NAME/archive/master.tar.gz | tar -xzv --strip 1' 30 | ``` 31 | 32 | In the last command, **replace** `USERNAME` with your own github username, and `REPO_NAME` with the name of the repo you gave your personal webpage. 33 | 34 | > **NOTE:** _If you want to deploy a BRANCH other than *master*, replace master with the branch name (i.e. if your webpage code is in the `gh-pages` branch)_ 35 | 36 | ## Done! Reload your browser and you should see your webpage 37 | 38 |
39 | 40 |
41 | 42 | ## Explanation and Additional Resources 43 | 44 | ### What did we just do? 45 | 46 | We just installed the Apache software, which is an open source HTTP web server, which also happens to be the most popular in the world. It's primary functionality is to serve files over port 80 of your machines IP address, to other computers on the network. For machines connected to the internet, like our Google Compute Engine VM, that means our files are accessible to all other machines on the internet. 47 | 48 | By default, Apache serves all of the files it finds in the `/var/www/html/` directory. We removed the default Ubuntu page and we copied our own webpage files from our Github repository. Use [explainshell.com](http://explainshell.com) to learn about the commands. 49 | 50 | Apache is not the only available webserver, Nginx is a modern open source web server gaining a lot of traction. There are also commercial web servers like Microsoft's IIS web server. 51 | 52 | > Aside: Although I am using the term Apache to refer to the HTTP Web Server, you should be aware that the Apache Foundation now supports many, many more open source projects besides the HTTP Web Server software. 53 | 54 | ### Security Considerations 55 | 56 | HTTP Web Servers are very complex, and Apache itself is very flexible in how it can be configured. These instructions are only meant for static pages that do not contain any private information at risk of exposure. 57 | 58 | ### Resources 59 | 60 | Apache HTTP Server: [http://httpd.apache.org/](http://httpd.apache.org/) 61 | 62 | Apache Foundation: [http://www.apache.org/](http://www.apache.org/) 63 | 64 | Nginx (Open Source version): [http://nginx.org/](http://nginx.org/) 65 | 66 | [N/A] Web Server Survey: [http://news.netcraft.com/archives/2016/02/22/february-2016-web-server-survey.html](http://news.netcraft.com/archives/2016/02/22/february-2016-web-server-survey.html) 67 | 68 | [Advanced] Apache vs. Nginx: Practical Considerations [https://www.digitalocean.com/community/tutorials/apache-vs-nginx-practical-considerations](https://www.digitalocean.com/community/tutorials/apache-vs-nginx-practical-considerations) 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /lecture-notes/README.md: -------------------------------------------------------------------------------- 1 | **CUNY Tech Prep 2016-2017** 2 | # Lecture Notes 3 | 4 | _Latest lecture material at the bottom_ 5 | 6 | ## Summer Session 1 7 | **June 28-29, 2016** 8 | 9 | [Slides](00.1_2016-06-28/summer_01.pdf) 10 | 11 | Topics: 12 | 13 | * Program Orientation 14 | * Development Environment and Tooling 15 | 16 | 17 | ## Summer Session 2 18 | **July 12-13, 2016** 19 | 20 | [HTML/CSS slides](00.2_2016-07-12/HTML_CSS_Slides.html) | 21 | [Notes](00.2_2016-07-12/javascript-basics.md) 22 | 23 | Topics: 24 | 25 | * Review of HTML/CSS 26 | * Coding Challenge Solutions 27 | * JavaScript Programming 28 | 29 | 30 | ## Summer Pre-Work 31 | 32 | ### Codecademy Courses: 33 | 34 | * Learn JavaScript ([link](https://www.codecademy.com/learn/javascript)) 35 | * Learn HTML & CSS ([link](https://www.codecademy.com/learn/web)) 36 | * Learn jQuery ([link](https://www.codecademy.com/learn/jquery)) 37 | * Learn Git ([link](../guides/git.md)) 38 | * Learn/Review Java ([link](../guides/java.pdf)) 39 | 40 | ### HackerRank Coding Challenges: 41 | 42 | Invitations for four coding challenges were sent out: 43 | 44 | * CUNY JavaScript Basics (Due 7/12) 45 | * CUNY HTML/CSS/JQuery Basics (Due 8/10) 46 | * CUNY Java Basics (Due 8/22) 47 | * CUNY Java OOP Basics (Due 8/29) 48 | 49 | 50 | 51 | ## Lecture 1 52 | **Week of 8/23-8/26** 53 | 54 | [Slides](lecture_slides_01.pdf) 55 | 56 | 57 | Topics: 58 | 59 | * Course Overview 60 | * Programming Languages, Paradigms, and Patterns 61 | * Labs Overview 62 | * Getting the Microblog App 63 | 64 | 65 | ## Lecture 2 66 | **Week of 8/30-9/02** 67 | 68 | [Slides](lecture_slides_02.pdf) | 69 | [Notes](02/class-notes.md) 70 | 71 | Topics: 72 | 73 | * Client-Server Communications 74 | * URL's 75 | * Understanding the HTTP Request-Response 76 | * Designing the Microblog 77 | * Overview of the Microblog code 78 | 79 | ## Lecture 3 80 | **Week of 9/13-9/16** 81 | 82 | [Slides](lecture_slides_03.pdf) | 83 | [Lecture Code](https://github.com/medgardo/ctp-lecture-code/tree/master/module-03) 84 | 85 | Topics: 86 | 87 | * Building an App in Express.js from Scratch 88 | - Introduction to the Express.js Framework 89 | - The Model-View-Controller (MVC) Architecture 90 | - RESTful Routing (GET, POST, PUT, DELETE) 91 | - Intro to Testing with Mocha/Chai 92 | 93 | 94 | ## Lecture 4 95 | **Week of 9/27 - 9/30** 96 | 97 | [Slides](lecture_slides_04.pdf) | 98 | [Lecture Code](https://github.com/medgardo/ctp-lecture-code/tree/master/module-04) 99 | 100 | Topics: 101 | 102 | * Relational Databases 103 | - Data Normalization 104 | - Relations (_1-to-1_, _1-to-Many_, _Many-to-Many_) 105 | * ORM's (Object-Relational Mapping) 106 | - Sequelize.js 107 | * Views and Templates 108 | - Handlebars 109 | 110 | ## Lecture 5 111 | **Week of 10/18 - 10/21** 112 | 113 | [Lecture Code](https://github.com/medgardo/ctp-lecture-code/tree/master/module-05) 114 | 115 | Topics: 116 | 117 | * Views with Handlebars 118 | * HTML Forms and POST requests 119 | * Unit Tests 120 | * Model validations 121 | 122 | ## Lecture 6 123 | **Week of 11/1 - 11/4** 124 | 125 | [Slides](lecture_slides_06.pdf) 126 | 127 | Topics: 128 | 129 | * Best Practices 130 | - `.gitignore` 131 | - `node_modules` 132 | - credential management 133 | - Modules 134 | * More Frontend Topics 135 | - Static Files 136 | - Partials 137 | - HTML Escaping 138 | - Flash Messages 139 | * More Backend Topics 140 | - Middleware 141 | - Cookies 142 | - Sessions 143 | - Authentication 144 | 145 | ## Lecture 7 146 | **Week of 12/12 - 12/16** 147 | 148 | [Slides](lecture_slides_07.pdf) | 149 | [Lecture Code](https://github.com/medgardo/ctp-lecture-code/tree/master/module-07) 150 | 151 | Topics: 152 | 153 | * API's 154 | - What are they? 155 | - Using a Web API 156 | - Building a Web API 157 | * What is Ajax? 158 | * Web Application Architectures 159 | 160 | -------------------------------------------------------------------------------- /lecture-notes/00.2_2016-07-12/javascript-basics.md: -------------------------------------------------------------------------------- 1 | # Hacker Rank Review 2 | 3 | ## Question 8: Merge strings 4 | ```javascript 5 | function mergeStrings(a, b) { 6 | var shortlen = (a.length < b.length) ? a.length : b.length; 7 | var res = ''; 8 | 9 | for(var i=0; i a-b); // ES6 && in-place modification of list 29 | for(var i in a) { 30 | if(a[i] === b) { 31 | b *= 2; 32 | } 33 | } 34 | return b; 35 | } 36 | ``` 37 | 38 | ## Question 10: Sum them all 39 | ```javascript 40 | function sum(numbers) { 41 | var sum = 0; 42 | for(var i in numbers) { 43 | sum += numbers[i]; 44 | } 45 | return sum; 46 | } 47 | ``` 48 | 49 | 50 | 51 | 52 | # JavaScript 53 | 54 | ## About JavaScript (ECMAScript, abbreviated ES) 55 | JavaScript (JS) is a rapidly evolving language and today's applications depend on it. JavaScript is the only programming language supported across all modern web browsers. But since the release of Node.js, it has gained wide adoption as a general and server-side language as well. 56 | 57 | The "JavaScript" name is trademarked by Oracle Corporation. 58 | 59 | 60 | ## Some terms and acronyms to know 61 | 62 | **ES6** and **ES2015** 63 | both refer to the latest published standard of the language (in 2015). It added many new features and syntax that are not present in previous versions. Complete **ES6** support is still in progress as vendors update their software. Currently Chrome, Firefox, and Node are all close to 100% support. 64 | 65 | **ES5** 66 | is the version currently *FULLY* supported by all major web browsers. It was published in 2009. Many older resources will refer to an ES5 style of writing JavaScript code. ES6 has changed a few of the preferred conventions. ES6 code can be transpiled to ES5 via compilers/transpilers such as *Babel.js*. 67 | 68 | **Core JavaScript** 69 | refers to the syntax, expressions, statements, control flow, loops, the data types, and typing system for computing. This includes how to define objects and functions and their use. It does not refer to any API's or host environments for accessing inputs and producing outputs. The host environments determines which inputs a JS program is allowed to receive, and what outputs it is allowed. The two primary JS host environments we will work with are the Web Browser (client-side) and in Node.js (server-side). 70 | 71 | **Client-Side JavaScript** 72 | refers to JS programs that run within a Web Browser window. In this mode, the browser only provides API's for the language to access the document within the window (through the DOM: Document Object Model) and resources related to the document such as cookies. It does not allow programs to access other browser windows or any hardware resources on the computer. 73 | 74 | **Server-Side JavaScript** 75 | refers to JS programs that run within a runtime that provides programs API's to access hardware and file resources on the computer such as the filesystem, networking sockets, keyboard, sound, cameras, etc. For this reason, runtime's like Node.js have become very popular for Web Application development as well as development on IoT devices and microprocessors such as Arduino's. 76 | 77 | **V8 (JavaScript) Engine** 78 | an open source JavaScript engine developed by google to speed up JS performance, by compiling JS code into native machine code. It is used by various JS runtimes (such as the Chrome Browser, Node.js, MongoDB, etc.). The runtime adds the environment API's that JS programs are given access to. 79 | 80 | 81 | 82 | ## Resources and Documentation 83 | https://developer.mozilla.org/en-US/docs/Web/JavaScript 84 | Mozilla Documentation (Core language and Client-Side (Web Browser) API's) 85 | **Very Useful** (ES5 and ES6) 86 | - Hint: search for "mdn javascript" 87 | 88 | https://nodejs.org/en/docs/ 89 | Node Documentation (Server-Side Node.js API's) 90 | **Very Useful** 91 | 92 | http://www.ecmascript.org/ 93 | Links to the standards bodies and publications. 94 | 95 | ## ES6 (ES2015) Specific Resources 96 | https://babeljs.io/docs/learn-es2015/ 97 | Great resource to learn new ES6 features 98 | 99 | https://babeljs.io/ 100 | An ES6 to ES5 compiler (or transpiler). Allows us to use ES6 syntax/features today. 101 | - Try the Online REPL: https://babeljs.io/repl/ 102 | 103 | https://kangax.github.io/compat-table/es6/ 104 | http://node.green/ 105 | ES6 Browser and Server compatability tables 106 | 107 | 108 | 109 | 110 | # Common JavaScript Gotchas 111 | 112 | ## identifiers (variable, funtion, or property names) 113 | - Can only contain alphanumeric characters [a-zA-Z0-9] and '$' and '_' 114 | - But CANNOT begin with a digit [0-9]. 115 | - Are case sensitive 116 | 117 | ## Semicolons ';' 118 | - ALWAYS USE THEM 119 | - They are optional, but ommission can lead to very nasty bugs 120 | 121 | ## Always use Blocks '{ }' 122 | - It is a best practice to use {} around conditional and loop code. 123 | 124 | ## var 125 | - Always use *var* 126 | - Anytime you do not use **var**, the variable is scoped globally. Globals can lead to bugs. 127 | 128 | 129 | ## Coercion 130 | JavaScript tries its best to do what you ask for and avoid errors, converting types, sometimes not what you expect. Learn the pecularities. 131 | 132 | Example: Adding and Subtracting strings and numbers. In addition numbers are coerced into strings. For subtraction, strings are coerced into numbers. 133 | ```javascript 134 | x = "The answer is " + 42 // "The answer is 42" 135 | y = 42 + " is the answer" // "42 is the answer" 136 | 137 | "37" - 7 // 30 138 | "37" + 7 // "377" 139 | 140 | "1.1" + "1.1" = "1.11.1" 141 | (+"1.1") + (+"1.1") = 2.2 142 | 143 | parseInt("23") + 4 // 27 144 | "23" + 4 // "234" 145 | (+"23") + 4 // 27 146 | ``` 147 | 148 | 149 | ## Avoid "new Array()" 150 | Use the [] syntax instead 151 | ```javascript 152 | var aList = []; 153 | var bList = [2, 44, 6]; 154 | ``` 155 | 156 | 157 | ## Equal (==) vs Strict Equal (===) 158 | Use Strict Equal (===), it's probably what you mean. 159 | '===' ensures that values and types match 160 | '==' applies coercion, such that (3 == '3') will result in true. 161 | 162 | 163 | ## Other topics to look into 164 | Scoping: this, variable hoisting 165 | Anonymous functions 166 | switch 167 | 168 | 169 | ## JavaScript Style Guides and Gotchas 170 | https://github.com/airbnb/javascript 171 | https://github.com/airbnb/javascript/tree/master/es5 172 | Airbnb's JavaScript style guides for ES6 and ES5. 173 | - Follow these! 174 | 175 | http://www.adequatelygood.com/JavaScript-Scoping-and-Hoisting.html 176 | **Variable Hoisting** article 177 | 178 | https://github.com/stevekwan/best-practices/blob/master/javascript/gotchas.md 179 | **Common Gotchas** 180 | 181 | 182 | 183 | 184 | -------------------------------------------------------------------------------- /guides/google-cloud-node-deployment.md: -------------------------------------------------------------------------------- 1 | # Instructions for Deploying Node/Express Projects to a Google Cloud Server 2 | 3 | The following instructions will guide you through process of deploying your projects to a Google cloud server. Note, that these instructions will work for most application configurations. If your project differed from our class configurations you may have to modify some of these steps. 4 | 5 | ## 1 - Create and launch a Google VM from a Preconfigured Image 6 | 7 | Download and Follow the instructions here: [Create-Preconfigured-Google-Compute-Engine-Virtual-Machines.docx](deployment/Create-Preconfigured-Google-Compute-Engine-Virtual-Machines.docx) 8 | 9 | **IMPORTANT:** Some of the following steps should be run on the server and some will run on your local machine. 10 | 11 | ## 2 - Create your Postgres User and Database 12 | 13 | _Note: Do these steps if you are using Postgres database. Skip if you are using MongoDB._ 14 | 15 | Log into your Google VM and create your Postgres User and Database with the following commands: 16 | 17 | ``` 18 | $ sudo su - postgres 19 | # createuser -P -s -e PG_USERNAME 20 | # createdb MYAPPNAME_development 21 | # exit 22 | ``` 23 | 24 | Replace `PG_USERNAME` and `MYAPPNAME_development` with your projects corresponding configuration. 25 | 26 | ## 3 - Sync your code onto the Google cloud server 27 | 28 | These instructions will allow you to upload your latest code changes to your Google VM Instance. 29 | 30 | _Note: you should run this on your local machine in your code directory. You can run this multiple times on your local machine to sync new changes to the server._ 31 | 32 | ### Instructions 33 | 34 | 1. Ensure you're able to SSH into your Google VM Instance 35 | 2. Ensure that you have **created the directory** in your Google VM instance in which you want store your files. 36 | - For example: `/opt/apps/ctp` 37 | 3. Fill in this command with your unique credentials/values: 38 | 39 | ``` 40 | rsync -avz -e "ssh -i /PATH/TO/THE/SSH/KEY/ON/YOUR/MACHINE" --rsync-path="sudo rsync" --delete [source] [destination] 41 | ``` 42 | 43 | Replace the following: 44 | - `PATH/TO/THE/SSH/KEY/ON/YOUR/MACHINE`: With your Google Compute Engine SSH Key (_Note, this should be the full path or it can use the `$HOME` env var instead of `~`_) 45 | - `source`: The directory which you want to sync. 46 | - `destination`: Where in the remote server you want to store your files. 47 | - It should follow the following format: 48 | - `[user]@[remote server]:[remote path]` 49 | 50 | Your end command should look similar to this: 51 | ``` 52 | rsync -avz -e "ssh -i $HOME/.ssh/my_google_key" --rsync-path="sudo rsync" --delete ./ google-vm-username@remote-address:/opt/apps/ctp 53 | ``` 54 | 55 | ### If you are using Sequelize Migrations: 56 | 57 | If you are using Sequelize and Migrations, login to the google cloud server, and run your migrations. You should also do this everytime you rsync your code and new migrations have been added. 58 | 59 | ``` 60 | $ cd /opt/apps/PROJECT_DIRECTORY 61 | $ sequelize db:migrate 62 | ``` 63 | 64 | ## 4 - Setup NGINX configuration file 65 | 66 | The NGINX configuration file will allow NGINX to proxy incoming requests and send them to your web applications. 67 | 68 | ### Things to note: 69 | 70 | 1. Your `NGINX configuration` file should be stored inside of `/etc/nginx/sites-available` 71 | 2. You must link the configuration in `/etc/nginx/sites-available` to `/etc/nginx/sites-enabled` 72 | 3. You can use the following command to do so: 73 | 74 | ``` 75 | ln -s /etc/nginx/sites-available/FILE-NAME-HERE /etc/nginx/sites-enabled/SAME-FILE-NAME-HERE 76 | ``` 77 | 78 | 4. Everything that has the comment: ` # LOOK BELOW FOR ADDITIONAL NOTES` is unique to every project. 79 | 80 | ### Sample Configuration File: 81 | 82 | ```nginx 83 | server { 84 | listen 80; 85 | 86 | access_log {{ log_root }}/nginx.access.log; # LOOK BELOW FOR ADDITIONAL NOTES 87 | error_log {{ log_root }}/nginx.error.log error; # LOOK BELOW FOR ADDITIONAL NOTES 88 | 89 | client_max_body_size 20M; 90 | 91 | location ~ ^/(assets/|images/|img/|javascript/|js/|css/|stylesheets/|flash/|media/|static/|robots.txt|humans.txt|favicon.ico) { 92 | root {{ source_root }}/public; # LOOK BELOW FOR ADDITIONAL NOTES 93 | access_log off; 94 | expires 24h; 95 | } 96 | 97 | location / { 98 | proxy_set_header X-Real-IP $remote_addr; 99 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 100 | proxy_set_header Host $host; 101 | proxy_set_header X-NginX-Proxy true; 102 | proxy_pass http://localhost:{{ app_port }}; # LOOK BELOW FOR ADDITIONAL NOTES 103 | proxy_redirect off; 104 | proxy_http_version 1.1; 105 | proxy_set_header Upgrade $http_upgrade; 106 | proxy_set_header Connection "upgrade"; 107 | 108 | proxy_redirect off; 109 | proxy_set_header X-Forwarded-Proto $scheme; 110 | proxy_cache_key sfs$request_uri$scheme; 111 | } 112 | } 113 | ``` 114 | 115 | ### Changes Needed To Be Made: 116 | 117 | 1. `access_log {{ log_root }}/nginx.access.log;` 118 | - This line is responsible for telling NGINX where to log all information in regards to requests trying to access the server. 119 | - `{{ log_root }}` can be a directory of your choosing. Personally, I create a log directory inside of my project and use that. 120 | - **You need to replace this line with your information. For example:** 121 | ``` 122 | access_log /opt/apps/blog/log/nginx.access.log; 123 | ``` 124 | 2. `error_log {{ log_root }}/nginx.error.log error;` 125 | - This line is responsible for telling NGINX where to log all errors when making requests to your server. 126 | - `{{ log_root }}` can be a directory of your choosing. Personally, I create a log directory inside of my project and use that. 127 | - The error at the end of the line tells NGINX to `only` log errors. 128 | - **You need to replace this line with your information. For example:** 129 | ``` 130 | access_log /opt/apps/blog/log/nginx.error.log error; 131 | ``` 132 | 3. `root {{ source_root }}/public;` 133 | - This code block is responsible to telling NGINX where to look for static files (JavaScript, CSS, Images, etc.) 134 | - If you followed the blog file structure then you should already be storing this information in your public directory. 135 | - `{{ source_root }}` Is the absolute path to the directory in which your project is stored. 136 | - **You need to replace this line with your information. For example:** 137 | ``` 138 | root /opt/apps/blog/public; 139 | ``` 140 | 4. `proxy_pass http://localhost:{{ app_port }};` 141 | - This line is responsible for telling NGINX where to pass the request to. In this case, we want to pass the request to our application so it can respond to the request. 142 | - `3000` We're running our app on port `3000`. You should change this value if you're running your application on a different port. 143 | - **You need to replace this line with your port number. For example:** 144 | ``` 145 | proxy_pass http://localhost:3000; 146 | ``` 147 | 5. After all of these changes run the following command: 148 | ``` 149 | sudo service nginx restart 150 | ``` 151 | 152 | 6. Now enter your VM External IP address on your browser and you should see your project if your application is running. 153 | 154 | ## 5 - Run your application with PM2 155 | 156 | The last thing left to do is to run our application on the server. Since this is a server, we need to use a process manager to launch the application and not close when we exit the terminal. We will use the PM2 process manager to do this for us. PM2 is already installed on the server. 157 | 158 | Launch your app on the google cloud server like this: 159 | 160 | ``` 161 | $ cd /opt/apps/PROJECT_DIRECTORY 162 | $ pm2 start app.js --watch 163 | ``` 164 | 165 | _Note: the `--watch` is typically not something you want in production environments, but if you don't use it, you will need to restart the process everytime you rsync new changes to the server._ 166 | 167 | ### Make sure it always gets launched even if the server is restarted: 168 | 169 | Run: 170 | 171 | ``` 172 | $ pm2 start ubuntu 173 | ``` 174 | 175 | Copy the command it gives you and run it on the cloud server. 176 | 177 | --------------------------------------------------------------------------------