25 |
26 |
27 |
30 |
31 |
32 | ```
33 |
34 | * How many children does `header` have?
35 | * Name a direct child of the `p` element.
36 | * Name a direct parent of the `p` element
37 | * What is the parent of the `html` element?
38 |
39 | #### CSS Selector Challenge - [solutions](solutions.md)
40 | Please refer to [this google doc](https://docs.google.com/document/d/1sKbuZaSio1o65iRdkNpB03pwJfJj98GPHUJQsoKJmE4/edit?usp=sharing).
41 |
42 | For each page, come up with as many CSS Selectors as you can think of to select the html elments in **red**, and *only* the elements in red.
43 |
44 |
62 |
63 |
64 | # Exercise - Hack Github with jQuery!
65 |
66 | [Hack Github with jQuery Challenges](https://github.com/sf-wdi-27-28/hack-github-with-jquery) - [Solutions](https://github.com/sf-wdi-27-28/hack-github-with-jquery/blob/master/solutions.md)
67 |
--------------------------------------------------------------------------------
/01-front-end-basics/jquery-dom-manipulation/27-28/solutions.md:
--------------------------------------------------------------------------------
1 | # jQuery & DOM Exercises
2 |
3 | #### Nature Drawing 101: Draw a Tree!
4 | * How many children does `header` have?
5 | - just one: the `ul` element
6 | * Name a direct child of the `p` element.
7 | - the `a` elment
8 | * Name a direct parent of the `p` element
9 | - the `section` element
10 | * What is the parent of the `html` element?
11 | - Trick question! It turns out that `html` belongs to the `document` object, which lives inside your browser (not your html)!
12 |
13 | #### CSS Selector Challenge
14 | 1.
15 | * \#fancy
16 | * p#fancy
17 | * div p#fancy
18 | * .page #fancy
19 | * .page p#fancy
20 | * div.page p#fancy
21 |
22 | 2.
23 | * div .small
24 | * div a.small
25 | * .small
26 | * div.page a.small
27 |
28 | 3.
29 | * p a
30 | * div.page p a
31 | * .page p a
32 | * div p a
33 |
34 | 4.
35 | * .mad-favs li
36 | * ul.mad-favs li
37 | * div.page ul.mad-favs li
38 | * .page .mad-favs li
39 |
40 | 5.
41 | * .sparkles
42 | * p.sparkles
43 | * div p.sparkles
44 | * div.page p.sparkles
45 |
46 | 6.
47 | * p a.small
48 | * p .small
49 | * div p .small
50 | * div.page p a.small
51 |
52 |
64 |
65 | # Solutions - Hack Github with jQuery!
66 |
67 | ## Challenge 1 - Name Changer
68 |
69 | `$(".user-mention").text("anonymous")`
70 |
71 |
72 | ## Challenge 2 - Add some class!
73 |
74 | `$(".btn").addClass("btn-primary")`
75 |
76 | ## Challenge 3 - It's Shruggy!
77 |
78 | `$(".message").text("¯\\_(ツ)_/¯")`
79 |
80 |
81 | ## Challenge 4 - I'm the captain now.
82 |
83 | `$("#user-links").remove()`
84 |
85 | ## Challenge 5 - One big family
86 |
87 | `$(".social-count").text("∞")`
88 |
89 | ## Challenge 6 - JustinHub!
90 |
91 | `$(".header-logo-invertocat").html("")`
92 |
93 | ## Challenge 7 - Nuclear Option
94 |
95 | `$(".pagehead-actions").append("")`
96 |
97 | ## Challenge 8 - Ugh, script kiddies
98 |
99 | `$("h1.entry-title").append(" / H4X0R3D!")`
100 |
--------------------------------------------------------------------------------
/01-front-end-basics/jquery-event-binding/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/01-front-end-basics/jquery-event-binding/.gitkeep
--------------------------------------------------------------------------------
/01-front-end-basics/jquery-event-binding/25/exercises.md:
--------------------------------------------------------------------------------
1 | ## Exercises - jQuery Events
2 |
3 | #### Octocat & Mouse - [solution](solutions.md)
4 | Open you Chrome Developer Console on [Github](https://github.com/sf-wdi-25/notes).
5 |
6 | 1. Whenever you mouseover the octocat icon/logo in the top left corner, `console.log` "i gotchew mowsie!"
7 | 2. Does it also work for the ocotocat in the footer?
8 |
9 | #### Infinite Scroll - [solution](solutions.md)
10 | Open you Chrome Developer Console on [Github](https://github.com/sf-wdi-25/notes).
11 |
12 | 1. Can you capture the `scroll` event? (hint: you need to listen to the `window` object using `$(window)`)
13 | 2. Can you add `
to infinity... and beyond!
` to the bottom of the page every time the user scrolls?
14 |
15 | #### Hijack Click - [solution](solutions.md)
16 | Hijack the big red button on the [GA homepage](https://generalassemb.ly/)!
17 |
18 | When you click the button...
19 |
20 | 1. prevent the default link behavior, and print "Clicked!" to the console.
21 | 2. use `$(this)` to change the text of the link to say "1".
22 | 3. Display the number of times the link has been clicked. If I click it again it should say "2".
23 |
24 | #### Events Lab - [solution](https://github.com/sf-wdi-25/events_lab/tree/solutions)
25 | Please Fork & Clone the [Events Lab](https://github.com/sf-wdi-25/events_lab)
26 |
27 |
28 |
--------------------------------------------------------------------------------
/01-front-end-basics/jquery-event-binding/25/solutions.md:
--------------------------------------------------------------------------------
1 | ## Events
2 |
3 | #### Octocat & Mouse
4 |
5 | ``` javascript
6 | $(".mega-octicon").on("mouseover", function handleHover(){
7 | console.log("i gotchew mousie!");
8 | })
9 | ```
10 |
11 | #### Infinite Scroll
12 | ``` javascript
13 | $(window).on("scroll", function handleScroll(){
14 | $("body").append("
to infinity... and beyond!
");
15 | })
16 | ```
17 |
18 | #### Hijack Click
19 |
20 | ``` javascript
21 | var clickCount = 0;
22 | $("a#san-francisco_cta").on("click", function handleClick(event){
23 | event.preventDefault();
24 | console.log("Clicked!");
25 |
26 | clickCount = clickCount + 1;
27 | $(this).text( clickCount );
28 | })
29 | ```
30 |
31 | #### Events Lab
32 |
33 | Please see the `solutions` branch of the events_lab repo: https://github.com/sf-wdi-27-28/events_lab/tree/solutions
34 |
--------------------------------------------------------------------------------
/01-front-end-basics/jquery-event-binding/27-28/exercises.md:
--------------------------------------------------------------------------------
1 | ## Exercises - jQuery Events
2 |
3 | #### Octocat & Mouse - [solution](solutions.md)
4 | Open you Chrome Developer Console on [Github](https://github.com/sf-wdi-27-28).
5 |
6 | 1. Whenever you mouseover the octocat icon/logo in the top left corner, `console.log` "i gotchew mowsie!"
7 | 2. Does it also work for the ocotocat in the footer?
8 |
9 | #### Infinite Scroll - [solution](solutions.md)
10 | Open you Chrome Developer Console on [Github](https://github.com/sf-wdi-27-28).
11 |
12 | 1. Can you capture the `scroll` event? (hint: you need to listen to the `window` object using `$(window)`)
13 | 2. Can you add `
to infinity... and beyond!
` to the bottom of the page every time the user scrolls?
14 |
15 | #### Hijack Click - [solution](solutions.md)
16 | Hijack the big red button on the [GA homepage](https://generalassemb.ly/)!
17 |
18 | When you click the button...
19 |
20 | 1. prevent the default link behavior, and print "Clicked!" to the console.
21 | 2. use `$(this)` to change the text of the link to say "1".
22 | 3. Display the number of times the link has been clicked. If I click it again it should say "2".
23 |
24 | #### Events Lab - [solution](https://github.com/sf-wdi-27-28/events_lab/tree/solutions)
25 | Please Fork & Clone the [Events Lab](https://github.com/sf-wdi-27-28/events_lab)
26 |
27 |
28 |
--------------------------------------------------------------------------------
/01-front-end-basics/jquery-event-binding/27-28/logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/01-front-end-basics/jquery-event-binding/27-28/logo.png
--------------------------------------------------------------------------------
/01-front-end-basics/jquery-event-binding/27-28/solutions.md:
--------------------------------------------------------------------------------
1 | ## Events
2 |
3 | #### Octocat & Mouse
4 |
5 | ``` javascript
6 | $(".mega-octicon").on("mouseover", function handleHover(){
7 | console.log("i gotchew mousie!");
8 | })
9 | ```
10 |
11 | #### Infinite Scroll
12 | ``` javascript
13 | $(window).on("scroll", function handleScroll(){
14 | $("body").append("
12 | Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
13 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/01-front-end-basics/js-array-iterators/24/solutions.md:
--------------------------------------------------------------------------------
1 | # Solutions
2 |
3 |
4 | ## filter
5 | ```
6 |
7 | var array = [1,2,3,4,5,6,7,8,9,10];
8 |
9 | array = array.filter(function(val){
10 | return val < 5;
11 | });
12 | ```
13 |
14 | ## map
15 | ```
16 | var array = [1,2,3,4,5];
17 | array = array.map(function(val){
18 | return val * 5;
19 | });
20 | ```
21 |
22 | ## reduce
23 | ```
24 | var array = [4,5,6,7,8];
25 | var multiply = function(a,b){
26 | return a*b;
27 | };
28 | ```
29 |
--------------------------------------------------------------------------------
/01-front-end-basics/js-array-iterators/25/exercises_a.md:
--------------------------------------------------------------------------------
1 | ## Challenge set A: Array iterators ##
2 |
3 | ###Challenge 1 (maps)###
4 |
5 | Elaine the Etsy Merchant thinks her prices are scaring off customers. Subtracting one penny might help:
6 | Help her out:
7 |
8 | ```javascript
9 | var prices = [3.00,4.00,10.00,2.25,3.01];
10 | prices.map(callbackfn);
11 | //[2.99, 3.99, 9.99, 2.24, 3.00]
12 | ```
13 |
14 | More Challenges:
15 |
16 | - On second thought, Elaine only wants to subtract a penny if it changes the dollars place, e.g.: 10.00 --> 9.99
17 |
18 | - Prices are going up! Elaine needs to raise her prices by 5%.
19 |
20 |
21 | ###Challenge 2 (filter)###
22 | Is there an interesting trend in birthdays? Do people tend to be born more on even-numbered dates or odd-numbered dates? This is a great chance to do some serious science!
23 |
24 | ```javascript
25 | var birthDates = [1, 1, 2, 4, 7, 4, 12, 30,...];
26 | birthdates.filter(callbackfn);
27 | evenBirthdates = [2, 4, 4, 12, 30];
28 | ```
29 | - In an organized and semi-nonchaotic fashion, create a master list of all birthdates with every person in the class. We're only interested in the birthdate (1 - 31), we don't care about month or year.
30 |
31 | - Independently write a filter array function that creates an array for either odd or even birth dates.
32 |
33 | - Compare the results for even numbers with those for odd numbers. Write some code that reports the results. For example `6 out of 10 students were born on an even day. Evens are more common.` Or `60% of the class was born on an even-numbered day.`
34 |
35 | - Share your results with the class and bask in your great science!
36 |
37 | ###Challenge 3 (reduce)###
38 | Goyle has a lucrative dog walking business. He's made mucho moolah this summer. How much did he make?
39 |
40 | ```javascript
41 | var earnings = [20, 25, 60, 20, 85, 20];
42 | earnings.reduce(callbackfn);
43 | // 210
44 | ```
45 | Challenge:
46 |
47 | - Goyle already has $500 in the bank. How would you incorporate this into your method call? (YOU ARE NOT ALLOWED TO USE output + 500)
48 | - BONUS: Goyle's curious how many times he earned $20 this summer. (HINT: there's a method for this!)
49 |
--------------------------------------------------------------------------------
/01-front-end-basics/js-array-iterators/25/exercises_b.md:
--------------------------------------------------------------------------------
1 | ## Challenge set B: function building ##
2 |
3 | Work together in groups of 3 to solve the following:
4 |
5 | DO NOT USE ANY BUILT IN ITERATOR METHODS: `forEach`, `map`, `reduce`, etc.
6 |
7 | Be sure to verify that your functions are working before moving on to the next step. Each of these is designed to build on your results from the previous ones.
8 |
9 | **Warm Up Challenges:**
10 |
11 | * Create a function `hereYaGo`.
12 | * Input: an array.
13 | * Output: the same array.
14 | ```
15 | someArray === hereYaGo(someArray); // this should be true
16 | ```
17 | * Create a function `first`.
18 | * Input: an array.
19 | * Output: the first item in that array.
20 | ```
21 | first(["apple", "toast", "cheese"]);
22 | // "apple"
23 | ```
24 | * Create a function `last`.
25 | * Input: an array.
26 | * Output: the last item in that array.
27 | ```
28 | last(["apple", "toast", "cheese"]);
29 | // "cheese"
30 | ```
31 | * Create a function `printEach`:
32 | * Input: an array.
33 | * On each iteration, print the item to the console.
34 | * Output: undefined;
35 | * Modify the above to become `printEachPlus`:
36 | * Input: an array and **another function**. Use `function() { return "!" }` as the function.
37 | * On each iteration, print the item to the console concatenated with the output of the callback function.
38 | * Output: undefined;
39 | ```
40 | // example of printEachPlus definition
41 | function printEachPlus(arr, callback) {
42 | // your code here
43 | }
44 | // example of calling printEachPlus
45 | printEachPlus(["apple", "toast", "cheese"], function(){
46 | return "!"
47 | });
48 | // "apple!"
49 | // "toast!"
50 | // "cheese!"
51 | ```
52 | * Modify the above to become `printEachSuperPlus`:
53 | * Input: an array and a function. When calling use the function: `function(v){return v + "!"}`
54 | * On each iteration, print the output of calling the callback function with the current item **as an argument** to the callback function.
55 | * Output: undefined;
56 | ```
57 | printEachSuperPlus(["apple", "toast", "cheese"], function(item){
58 | return item + "!"
59 | });
60 | // "apple!"
61 | // "toast!"
62 | // "cheese!"
63 | ```
64 |
--------------------------------------------------------------------------------
/01-front-end-basics/js-array-iterators/25/solutions_b.js:
--------------------------------------------------------------------------------
1 | // ## Challenge set B: function building ##
2 |
3 |
4 | function hereYaGo(anArr) {
5 | return anArr;
6 | }
7 |
8 |
9 | function first(anArr) {
10 | return anArr[0];
11 | }
12 |
13 |
14 | function last(anArr) {
15 | return anArr[anArr.length-1];
16 | }
17 |
18 |
19 |
20 | function printEach(anArr) {
21 | for(var i=0; i 9.99
17 |
18 | - Prices are going up! Elaine needs to raise her prices by 5%.
19 |
20 |
21 | ### Challenge 2 (filter) ###
22 | Is there an interesting trend in birthdays? Do people tend to be born more on even-numbered dates or odd-numbered dates? This is a great chance to do some serious science!
23 |
24 | ```javascript
25 | var birthDates = [1, 1, 2, 4, 7, 4, 12, 30,...];
26 | var evenBirthdates = birthDates.filter(callbackfn);
27 | // evenBirthdates = [2, 4, 4, 12, 30];
28 | ```
29 | - In an organized and semi-nonchaotic fashion, create a master list of all birthdates with every person in the class. We're only interested in the birthdate (1 - 31), we don't care about month or year.
30 |
31 | - Independently write a filter array function that creates an array for either odd or even birth dates.
32 |
33 | - Compare the results for even numbers with those for odd numbers. Write some code that reports the results. For example `6 out of 10 students were born on an even day. Evens are more common.` Or `60% of the class was born on an even-numbered day.`
34 |
35 | - Share your results with the class and bask in your great science!
36 |
37 | ### Challenge 3 (reduce) ###
38 | Goyle has a lucrative dog walking business. He's made mucho moolah this summer. How much did he make?
39 |
40 | ```javascript
41 | var earnings = [20, 25, 60, 20, 85, 20];
42 | earnings.reduce(callbackfn);
43 | // returns: 230
44 | ```
45 | Challenge:
46 |
47 | - Goyle already has $500 in the bank. How would you incorporate this into your method call? (YOU ARE NOT ALLOWED TO USE output + 500)
48 | - BONUS: Goyle's curious how many times he earned $20 this summer. (HINT: there's a method for this!)
49 |
--------------------------------------------------------------------------------
/01-front-end-basics/js-array-iterators/28/exercises.md:
--------------------------------------------------------------------------------
1 | ## Exercises - Array iterators ##
2 |
3 | ### Challenge 1 (map) - [Solution](solutions.js)
4 |
5 | Elaine the Etsy Merchant thinks her prices are scaring off customers. Subtracting one penny might help:
6 | Help her out:
7 |
8 | ```javascript
9 | var prices = [3.00, 4.00, 10.00, 2.25, 3.01];
10 | prices.map(callbackfn);
11 | // returns: [2.99, 3.99, 9.99, 2.24, 3.00]
12 | ```
13 |
14 | More Challenges:
15 |
16 | - On second thought, Elaine only wants to subtract a penny if it changes the dollars place, e.g.: 10.00 --> 9.99
17 |
18 | - Prices are going up! Elaine needs to raise her prices by 5%.
19 |
20 |
21 | ### Challenge 2 (filter) - [Solution](solutions.js)
22 | Is there an interesting trend in birthdays? Do people tend to be born more on even-numbered dates or odd-numbered dates? This is a great chance to do some serious science!
23 |
24 | ```javascript
25 | var birthDates = [1, 1, 2, 4, 7, 4, 12, 30,...];
26 | birthdates.filter(callbackfn);
27 | evenBirthdates = [2, 4, 4, 12, 30];
28 | ```
29 | - In an organized and semi-nonchaotic fashion, create a master list of all birthdates with every person in the class. We're only interested in the birthdate (1 - 31), we don't care about month or year.
30 |
31 | - Independently write a filter array function that creates an array for either odd or even birth dates.
32 |
33 | - Compare the results for even numbers with those for odd numbers. Write some code that reports the results. For example `6 out of 10 students were born on an even day. Evens are more common.` Or `60% of the class was born on an even-numbered day.`
34 |
35 | - Share your results with the class and bask in your great science!
36 |
37 | ### Challenge 3 (reduce) - [Solution](solutions.js)
38 | Goyle has a lucrative dog walking business. He's made mucho moolah this summer. How much did he make?
39 |
40 | ```javascript
41 | var earnings = [20, 25, 60, 20, 85, 20];
42 | earnings.reduce(callbackfn);
43 | // 210
44 | ```
45 | Challenge:
46 |
47 | - Goyle already has $500 in the bank. How would you incorporate this into your method call? (YOU ARE NOT ALLOWED TO USE output + 500)
48 | - BONUS: Goyle's curious how many times he earned $20 this summer. (HINT: there's a method for this!)
49 |
--------------------------------------------------------------------------------
/01-front-end-basics/js-arrays/25/exercises.md:
--------------------------------------------------------------------------------
1 | #Exercises - Array Manipulation
2 |
3 | ## Challenge Set A ##
4 |
5 | ### Challenge 1 ###
6 |
7 | Use your chrome console `ctrl+opt+j` to perform the following activities.
8 | Each of the following tasks can be accomplished using a single Array method in 1 line of code.
9 |
10 | * create an array: `var cacti = ['barrel', 'columnar', 'hedgehog', 'cluster', 'prickly pear'];`
11 | * print out the 3rd element (hedgehog)
12 | * print out the length of the array
13 | * print out (console.log) the last element (prickly pear). Use a built-in array method. (Do not use `cacti[4]`)
14 | * put `epiphytic` on the end of the array
15 | * Use indexOf to find the index of 'columnar' and print it out.
16 | * remove 'barrel' (the first element) from the list
17 | * add 'barrel' back to the **front** of the list
18 | * remove the 4th element of the list (hint use splice)
19 |
20 | ### Challenge 2 ###
21 |
22 | Use `for` to print out each fruit from the list.
23 | ```js
24 | var fruits = ["Apple", "Banana", "Cherry", "Durian", "Elderberry",
25 | "Fig", "Guava", "Huckleberry", "Ice plant", "Jackfruit"];
26 | ```
27 |
28 | ### Challenge 3 ###
29 |
30 | Print the same list as above, in reverse order.
31 |
32 |
33 |
34 | **stop here until we reach the next exercise**
35 |
36 | ## Challenge Set B ##
37 |
38 | ### Challenge 1a (forEach)###
39 |
40 | ```js
41 | var dogs = ['Snoopy', 'Scooby', 'Pluto', 'Goofy', 'Astro', 'Mr. Peabody', 'Odie', "Santa's Little Helper", 'Brian'];
42 | ```
43 |
44 | Use `forEach` to print each character in the list of famous cartoon dogs.
45 |
46 |
47 | ###Challenge 1b (forEach)###
48 |
49 | Use `forEach` and `String.toUpperCase` method to convert the list of characters into all capitals. That is, you should replace each character in the array with an all UPPERCASE version of that character's name.
50 |
51 | Use `console.log(dogs)` to verify your solution has changed the `dogs` array.
52 |
53 |
54 | ###Challenge 1c (forEach)###
55 |
56 | *Curry up now* has a line wrapped around the truck! It takes about two minutes per delicious curry burrito. Output the customer's name & their expected wait time.
57 |
58 | ```javascript
59 | // warning the below is pseudo-code!
60 | var customers: Justin, Ilias, Nathan, Camilo, Vikash, Adam, Brianna, Sarah, Ali, Jessie, Cameron
61 | customers.forEach(fn);
62 |
63 |
64 | /* sample output:
65 | Justin: 2 minutes
66 | Ilias: 4 minutes
67 | Nathan: 6 minutes
68 | Camilo: 8 minutes
69 | Vikash: 10 minutes
70 | ...
71 | Cameron: 22 minutes
72 | */
73 | ```
74 |
--------------------------------------------------------------------------------
/01-front-end-basics/js-control-flow/22-23/exercises.md:
--------------------------------------------------------------------------------
1 | #Control Flow Exercises
2 |
3 | ## Boolean Expressions and Truthy Values
4 |
5 | 1. What is the outcome of the following expressions?
6 |
7 | * true || false
8 | * false && false
9 | * true && false
10 | * (false || true) && true
11 | * false && ((true || false) && (false || true))
12 |
13 | 1. Which of the following are truthy values? (hint: try `if("abc"){console.log("I'm truthy!")}` in the JS console)
14 | * 1
15 | * 0
16 | * 3.14159
17 | * "abc"
18 | * ""
19 | * Array
20 | * []
21 | * Object
22 | * {}
23 |
24 | 1. What is the outcome of the following expressions?
25 | * true && 6
26 | * 0 || "hi"
27 | * ["a","b","c"] || "123"
28 | * {"key":"value"} || false
29 |
30 | ## Conditionals!
31 |
32 | Remember, you can work in a file (like controlFlow.js) in Sublime Text to keep your code. Run it from the terminal by typing `node controlFlow.js`, or copy and paste sections into the Chrome developer console.
33 |
34 | Jimmy loves roller coasters, but there are a bunch of rules (ugh!) for riding:
35 |
36 | For starters, it costs 5 tokens. Here's how we might code that:
37 |
38 | ```
39 | var tokens = 3; // Jimmy's tokens
40 |
41 | // Can he ride?
42 | if ( tokens >= 5 ) {
43 | console.log("Step right up!");
44 | } else {
45 | console.log("Sorry, you can't ride")
46 | }
47 | ```
48 | Edit the code above to check the following additional Requirements:
49 |
50 | 1. Must be at least 4ft tall
51 | 2. Must be at least 12 years old
52 | 3. Replace the prevoius rule: now riders under 12 must be accompanied by an adult
53 | 4. (If the boss isn't looking, you can sneak in!)
54 | 5. Riders with a park pass get in free.
55 |
56 | ## Loops!
57 |
58 | 2. Log to the console "This is awesome!" 25 times.
59 |
60 | 1. Create a new variable that is an array of 4 phrases: `"Howdy there"`, `"OMG"`, `"javascript"`, and `"Pair Programming"`.
61 |
62 | 5. Loop over the array and log each phrase to the console.
63 |
64 |
--------------------------------------------------------------------------------
/01-front-end-basics/js-control-flow/22-23/lab/README.md:
--------------------------------------------------------------------------------
1 | # Control Flow Lab
2 |
3 | ## Instructions
4 |
5 | 1. Create a new file for each exercise.
6 | 1. Test your code for exercise 1 by running the file with `node sing.js` or by copying and pasting your code into the Chrome dev console.
7 | 1. Test your code for the exercises that require `prompt` in the browser, since the `prompt` method is only available in the browser!
8 |
9 | ##Exercise 1: Sing!
10 |
11 | Hint: Be mindful of infinite loops. They will crash your browser!
12 |
13 | 2. Write code that console logs the "Bottles of beer on the wall" song:
14 |
15 | 5 bottles of beer on the wall,
16 | 5 bottles of beer!
17 | Take one down and pass it around,
18 | 4 bottles of beer on the wall!
19 |
20 |
21 | * How would you fix "1 bottles of beer"?
22 | * How would you change "0" to "No more"?
23 | * Use a JavaScript `prompt` to ask the user how many verses they want to hear.
24 |
25 | ###Exercise 2: Login
26 |
27 | 4. Create a `userLogin` object with one key for a user's name and one key for the user's password. Just make up a user name and password. Write code that prompts the user for their password with a message customized to the user. For example, if the user name you created is `octocat_rules`, the message should be `"Enter password for user octocat_rules."`
28 |
29 | 5. Extend your previous code to check whether the password the user gives matches the password in the `userLogin` object. The code should communicate whether the passwords matched to the user with console logs or JavaScript `alert`.
30 |
31 | Bonus: Modify your user login to give the user three chances to enter the correct password.
32 |
33 | ###Stretch Exercise: Security Questions
34 |
35 | 1. Create an array called `securityQuestions`. Each element of `securityQuestions` will be an object with two keys: `question` and `expectedAnswer`.
36 |
37 | 1. Populate (fill) `securityQuestions` with at least three such objects. Feel free to just make them up. For example, one security question object might be:
38 | ```
39 | { question: "What was your first pet's name?", expectedAnswer: "FlufferNutter" }
40 | ```
41 |
42 |
43 | 1. Write code that goes through each of the security questions doing the following:
44 | * prompt the user with the question
45 | * check whether the user's input matches the expected answer
46 | * if the answer does match, ask the next question
47 | * if the answer doesn't match, stop asking questions and pop up an alert message.
48 |
--------------------------------------------------------------------------------
/01-front-end-basics/js-control-flow/22-23/lab/solutions/login.js:
--------------------------------------------------------------------------------
1 | // login
2 |
3 | var userLogin = {userName: "octocat_rules", password: "abacadabra"}
4 |
5 | var password;
6 |
7 | for (var i=0; i < 3; i++){
8 | password = prompt("Enter password for user " + userLogin["userName"] + ".")
9 | if (password === userLogin["password"]){
10 | console.log("Passwords match!");
11 | break;
12 | } else {
13 | console.log("Passwords do not match!");
14 | if (i===2){
15 | alert("No more password attempts!");
16 | }
17 | }
18 | }
--------------------------------------------------------------------------------
/01-front-end-basics/js-control-flow/22-23/lab/solutions/security_questions.js:
--------------------------------------------------------------------------------
1 | // security questions
2 | var securityQuestions = [
3 | {
4 | question: "What was your first pet's name?",
5 | expectedAnswer: "FlufferNutter"
6 | },
7 | {
8 | question: "What was the model year of your first car?",
9 | expectedAnswer: "1985"
10 | },
11 | {
12 | question: "What city were you born in?",
13 | expectedAnswer: "NYC"
14 | }
15 | ]
16 |
17 |
18 | var thisAnswer = "";
19 | for (var i=0; i < securityQuestions.length; i++){
20 | thisAnswer = prompt(securityQuestions[i]["question"]);
21 | if (thisAnswer !== securityQuestions[i].expectedAnswer){
22 | alert("Incorrect security question response!");
23 | break;
24 | }
25 | }
--------------------------------------------------------------------------------
/01-front-end-basics/js-control-flow/22-23/lab/solutions/sing.js:
--------------------------------------------------------------------------------
1 | // sing
2 |
3 | var numBottles = prompt("How many bottles of beer on the wall?");
4 |
5 | var bottles = "bottles"
6 | while (numBottles > 0){
7 | console.log(numBottles + " " + bottles + " of beer on the wall,");
8 | console.log(numBottles + " " + bottles + " of beer");
9 | console.log("Take one down and pass it around,");
10 | numBottles = numBottles - 1;
11 | if (numBottles === 1){
12 | bottles = "bottle"
13 | }
14 | if (numBottles === 0){
15 | console.log("No more bottles of beer on the wall!");
16 | } else {
17 | console.log(numBottles + " " + bottles + " of beer on the wall!");
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/01-front-end-basics/js-functions-advanced/22/solutions.js:
--------------------------------------------------------------------------------
1 | // Looping Exercise 1 Solution:
2 | for (var key in myFirstJSON){
3 | for (var i = 0; i < myFirstJSON['language basics'][0]['Spanish']['letters'].length; i++){
4 | console.log(myFirstJSON['language basics'][0]['Spanish']['letters'][i]);
5 | }
6 | }
7 |
8 | // Looping Exercise 2 Solution:
9 | function languageBasics(language, type){
10 | var tempArrayRoot = myFirstJSON['language basics'];
11 | if(language === 'Spanish'){
12 | for (var i = 0; i < tempArrayRoot[0][language][type].length; i++){
13 | if (type === 'letters'){
14 | console.log(tempArrayRoot[0][language][type][i]);
15 | } else if (type === 'numbers') {
16 | console.log(tempArrayRoot[0][language][type][i]);
17 | }
18 | }
19 | } else if (language === 'Japanese'){
20 | for (var j = 0; j < tempArrayRoot[1][language][type].length; j++){
21 | if (type === 'letters') {
22 | console.log(tempArrayRoot[1][language][type][j]);
23 | } else if (type === 'numbers'){
24 | console.log(tempArrayRoot[1][language][type][j]);
25 | }
26 | }
27 | } else {
28 | console.log("Please enter either 'Spanish' or 'Japanese' and either 'letters' or 'numbers'");
29 | }
30 | }
31 |
32 | // Stretch: Refactor the function above. There are many ways. Consider using forEach, map, reduce or similar jQuery methods
33 |
34 |
35 |
36 | // Closure Exercise 1:
37 | var closeCall = function(firstNum){
38 | var secondNum = 6;
39 | var addStuff = function(secondNum){
40 | return firstNum + secondNum;
41 | };
42 | return addStuff(secondNum);
43 | };
44 |
45 | // Closure Exercise 2:
46 | var Animal = function(){
47 | return {
48 | 'name': 'beaver',
49 | 'age': 2,
50 | 'gender': 'male',
51 | 'catchPhrase': 'Dam!',
52 | speak: function(words){
53 | console.log("hi there, " + words);
54 | },
55 | doSomething: function(placeholder){
56 | console.log(placeholder + " I just cut down a tree!");
57 | }
58 | };
59 | };
60 |
61 | var chucky = new Animal();
62 |
63 | chucky.speak('I am a beaver!');
64 |
65 |
66 | // Closure Exercise 3:
67 |
68 | var Car = {};
69 |
70 | Car.brand = "Toyota";
71 | Car.model = "Corolla";
72 | Car.year = 1984;
73 | Car.horsePower = 250;
74 | Car.hitPoints = 10;
75 | Car.shields = 5;
76 | Car.maxSpeed = 50;
77 | Car.weapons = [{"machine gun": 80}, {"oil slick": 30}, {"wheel swords": 55}];
78 | Car.attack = function(){
79 | var weapons = this.weapons;
80 | for(var i = 0; i < weapons.length; i++){
81 | for (var key in weapons[i]){
82 | console.log( key + ' attack! Damage done: ' + weapons[i][key] );
83 | }
84 | }
85 | }
86 |
87 |
88 |
89 |
--------------------------------------------------------------------------------
/01-front-end-basics/js-functions/22/core_exercises.md:
--------------------------------------------------------------------------------
1 | ## Challenges
2 |
3 | ### Instructions
4 |
5 | >Create a new directory in your dev folder called javascript-functions. CD into this directory and create a new JavaScript file by running 'touch functions.js' in your terminal. Open this file in Sublime. This is where you will be writing all of your functions! You can run your code by typing 'node functions.js' in your terminal so long as you are still in the same directory. Make sure to call your functions as well as define them! This is how you will test your code. To avoid calling every function that you write every time, comment out where you have called the function on your functions.js document. Rock on.
6 |
7 | 1. Write a 'sayHello' function that logs 'Hello' to the console.
8 |
9 | 2. Rewrite 'sayHello' to accept a name as a parameter, and logs 'Hello' + the name to the console.
10 |
11 | 3. Write a `multiply` function that finds the product of two numbers.
12 |
13 | ```js
14 | multiply(5, 7) => 35
15 | ```
16 | 3. Write a 'negative' function that takes an integer, and if that integer is positive, it turns it into a negative integer and returns that integer.
17 |
18 | 2. Write a function that takes in a number and returns `true` if the number is even and `false` if the number is odd (**Hint:** Look up the `%` operator).
19 |
20 | ```js
21 | isEven(4) => true
22 | ```
23 |
24 |
25 | 4. Write a function that generates a random number in a specified range (**Hint:** Look up Math.random()).
26 |
27 | ```js
28 | getRand(5, 10) => 8 (any number between 5 and 10)
29 | ```
30 |
31 |
32 | 5. Write a function that generates an array of specified length that contains random numbers from 1 to 100.
33 |
34 | ```js
35 | randArr(3) => [23, 11, 82]
36 | ```
37 |
38 | 3. Write a function that swaps two values at two different indexes in an array.
39 |
40 | ```js
41 | swap(["moe", "larry", "curly"], 0, 2) => ["curly", "larry", "moe"]
42 | ```
43 |
--------------------------------------------------------------------------------
/01-front-end-basics/js-functions/22/core_solutions.md:
--------------------------------------------------------------------------------
1 | ## Solutions
2 |
3 | 1. Write a 'sayHello' function that logs 'Hello' to the console.
4 | ```js
5 | function sayHello(){
6 | console.log('Hello');
7 | };
8 | ```
9 |
10 | 1. Rewrite 'sayHello' to accept a name as a parameter, and logs 'Hello' + the name to the console.
11 | ```js
12 | function sayHello(name){
13 | console.log('Hello ' + name);
14 | };
15 | ```
16 |
17 | 1. Write a `multiply` function that finds the product of two numbers.
18 |
19 | ```js
20 | function multiply(x, y){
21 | return x * y
22 | }
23 | ```
24 | 1. Write a 'negative' function that takes an integer, and if that integer is positive, it turns it into a negative integer and returns that integer.
25 |
26 | ```js
27 | function negative(integer){
28 | if (integer > 0){
29 | return integer * -1;
30 | }
31 | else {
32 | return integer
33 | }
34 | }
35 | ```
36 |
37 | 1. Write a function that takes in a number and returns `true` if the number is even and `false` if the number is odd (**Hint:** Look up the `%` operator).
38 |
39 | ```js
40 | function isEven(integer){
41 | return ( integer % 2 === 0 );
42 | }
43 | ```
44 |
45 | 1. Write a function that generates a random number in a specified range (**Hint:** Look up Math.random()).
46 |
47 | ```js
48 | function getRand(min, max){
49 | return Math.floor(Math.random() * (max - min) + min);
50 | }
51 |
52 | ```
53 |
54 | 1. Write a function that generates an array of specified length that contains random numbers from 1 to 100.
55 |
56 | ```js
57 | function randArr(length){
58 | var array = [];
59 | for(var i=0; i < length; i++){
60 | var randomNum = Math.floor(Math.random() * 100);
61 | array.push(randomNum);
62 | }
63 | return array
64 | }
65 | randArr(3) => [23, 11, 82]
66 | ```
67 |
68 | 1. Write a function that swaps two values at two different indexes in an array.
69 |
70 | ```js
71 | function swap(array, index1, index2){
72 | var temp = array[index1];
73 | array[index1] = array[index2];
74 | array[index2] = temp;
75 | return array
76 | }
77 |
78 | ```
79 |
--------------------------------------------------------------------------------
/01-front-end-basics/js-functions/22/stretch_exercises:
--------------------------------------------------------------------------------
1 | ## Stretch Challenges
2 |
3 | 1. Write a `getMax` function that finds the maximum number in an array.
4 |
5 | 2. Write a function called `explainMather` that takes in three arguments: two numbers and a function called `mather`. The `explainMather` function should pass the two numbers into `mather` and write out a message in the console to show the two number inputs and the output from `mather`. Test `explainMather` by passing in your `multiply` function from challenge #1.
6 |
7 | 3. Write a `vowels` function that counts the number of vowels in a given string.
8 |
9 | 4. merge(arr1, arr2)
10 |
11 | Write a function that takes two sorted arrays of numbers and returns a merged array of the sorted numbers. For example, if the input arrays were `var arr1 = [3,6,11]` and `var arr2 = [2,4,5,8,9]`, the returned array would be: `[2,3,4,5,6,8,9,11]`.
12 |
13 | 5. letterCount(word)
14 |
15 | Write a function that counts the number of times each letter occurs in a given string. It should return an object containing the count for each letter. For example, the string "apple" would return the following:
16 |
17 | ```js
18 | {
19 | a: 1,
20 | p: 2,
21 | l: 1,
22 | e: 1
23 | }
24 | ```
25 |
26 | **Bonus**: Make sure that lower case letters and upper case letters count for the same character. Also, ignore spaces and punctuation.
27 |
28 | 7. numSquare(max)
29 |
30 | Create a function called `numSquare` that will return an array of all perfect square numbers up to, but not exceeding a max number.
31 |
32 | ## Extra-Stretch Challenges
33 |
34 | 1. isPrime(num)
35 |
36 | Create a function that returns `true` if the number passed in is a prime number and `false` if not.
37 |
38 | 2. primes(max)
39 |
40 | Using your `isPrime` function, create a function `primes` that will return an array of all prime numbers up to, but not exceeding a max number.
41 |
--------------------------------------------------------------------------------
/01-front-end-basics/js-iterators/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/01-front-end-basics/js-iterators/.gitkeep
--------------------------------------------------------------------------------
/01-front-end-basics/json-and-html-string/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/01-front-end-basics/json-and-html-string/.gitkeep
--------------------------------------------------------------------------------
/01-front-end-basics/oo-objects-constructors/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/01-front-end-basics/oo-objects-constructors/.gitkeep
--------------------------------------------------------------------------------
/01-front-end-basics/oo-objects-constructors/22-23/exercises.md:
--------------------------------------------------------------------------------
1 | ###Quick Challenge
2 | - Copy the object above and save it to a javaScript file, `data.js`
3 | - Add some properties that logically fit into an object describing our class (address, floor number, and a list of instructors.
4 | - Run your file using 'node data.js' in your console.
5 | - Add some lines to 'data.js' to console.log some of your new properties!
6 |
7 | If everything worked out, you should have a fully functioning data object, only now with even MORE properties with us to play with!
8 |
9 |
10 | ###Quick Challenge - She loves me, she loves me not...
11 | Create an object method for flower that will play the age old game ['He loves me, he loves me not...'](https://en.wikipedia.org/wiki/He_loves_me..._he_loves_me_not)
12 | - Count down from the petal number down to 1
13 | - Alternately display 'He loves me' or 'He loves me not' to the console for each petal count decrement.
14 | - Display the final phrase with an exclamation; that's the end of the game!
15 |
16 |
17 | There are many more aspects to objects that we will discover tomorrow. For now, play with objects and think up some great object examples that we might use in class.
18 |
--------------------------------------------------------------------------------
/01-front-end-basics/oo-objects-constructors/22-23/solutions.js:
--------------------------------------------------------------------------------
1 | var data = {
2 | school: "General Assembly",
3 | city: "San Francisco",
4 | course: "Web Development Immersive",
5 | course_id: "WDI22",
6 | classrootm: "1",
7 | floor: 5,
8 | students: [{
9 | id: 0,
10 | last_name: "Aramayo",
11 | first_name: "Angelo",
12 | github_username: "angelo2dot0"
13 | }, {
14 | id: 1,
15 | last_name: "Bia",
16 | first_name: "Racha",
17 | github_username: "racha_bella"
18 | }, {
19 | id: 2,
20 | last_name: "Gabot",
21 | first_name: "Brian",
22 | github_username: "bgabot89"
23 | }],
24 | instructors: [{
25 | id: 0,
26 | last_name: "White",
27 | first_name: "Alex",
28 | }, {
29 | id: 1,
30 | last_name: "Veenstra",
31 | first_name: "Brianna",
32 | }, {
33 | id: 2,
34 | last_name: "Hulan",
35 | first_name: "Ben",
36 | }]
37 | }
38 |
39 | console.log(data.instructors[0].first_name) //=> Alex
40 |
41 |
42 |
43 |
44 |
45 | // He/ She Loves Me
46 |
47 | function Flower(petals){
48 | this.petals = petals;
49 | this.countDown = function(pronoun){
50 | var lovesMe = pronoun + " loves me!"
51 | var lovesMeNot = pronoun + " loves me not!"
52 | var n;
53 | for ( n=0; n <= this.petals; n++ ){
54 | if (n === this.petals){
55 | lovesMe = lovesMe.toUpperCase() + "!!!!";
56 | lovesMeNot = lovesMeNot.toUpperCase() + "!!!!";
57 | }
58 | var oddOrEven = n % 2
59 | switch(oddOrEven){
60 | case 0:
61 | console.log(lovesMe);
62 | break;
63 | case 1:
64 | console.log(lovesMeNot);
65 | }
66 | }
67 | }
68 | }
69 |
70 | var bud = new Flower(12);
71 | bud.countDown('She');
72 |
73 | // ---------------------------------
74 | // More Advanced Prototypal Solution
75 | // ---------------------------------
76 |
77 |
78 | // function Flower(petals){
79 | // this.petals = petals;
80 | // };
81 |
82 | // Flower.prototype.countDown = function(pronoun){
83 | // var lovesMe = pronoun + " loves me!"
84 | // var lovesMeNot = pronoun + " loves me not!"
85 | // var n;
86 | // for ( n=0; n <= this.petals; n++ ){
87 | // if (n === this.petals){
88 | // lovesMe = lovesMe.toUpperCase() + "!!!!";
89 | // lovesMeNot = lovesMeNot.toUpperCase() + "!!!!";
90 | // }
91 | // var oddOrEven = n % 2
92 | // switch(oddOrEven){
93 | // case 0:
94 | // console.log(lovesMe);
95 | // break;
96 | // case 1:
97 | // console.log(lovesMeNot);
98 | // }
99 | // }
100 | // }
101 |
102 | // var bud = new Flower(8);
103 | // bud.countDown('She');
104 |
--------------------------------------------------------------------------------
/01-front-end-basics/oo-objects-constructors/26/solution/monkey.js:
--------------------------------------------------------------------------------
1 | // Create a constructor function that makes a monkey
2 | function Monkey(name, species) {
3 | this.name = name;
4 | this.species = species;
5 | this.foodsEaten = [];
6 | this.eatSomething = function(food) {
7 | this.foodsEaten.push(food);
8 | }
9 | this.introduce = function() {
10 | console.log("My name is "+ this.name +". I come from the "+ this.species + " family. I have eaten "+ this.foodsEaten.join(", ") + ".");
11 | }
12 | }
13 |
14 | var monkey1 = new Monkey("Jack", "Howler");
15 | monkey1.eatSomething("banana");
16 | monkey1.introduce();
17 |
18 | var monkey2 = new Monkey("James", "Pygmy Marmoset");
19 | monkey2.eatSomething("peach");
20 | monkey2.eatSomething("plum");
21 | monkey2.introduce();
22 |
23 | var monkey3 = new Monkey("James", "Squirrel Monkey");
24 | monkey3.eatSomething("pineapple");
25 | monkey3.introduce();
26 |
27 | // Getting properties using the dot syntax / bracket syntax
28 | console.log(monkey1.name);
29 | console.log(monkey1["name"]);
30 |
--------------------------------------------------------------------------------
/01-front-end-basics/oo-prototype-inheritance/.gitkeep:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/01-front-end-basics/oo-prototype-inheritance/24/solutions.md:
--------------------------------------------------------------------------------
1 | ## Challenges
2 |
3 | 1. Create an `Animal` constructor with the properties `name`, `age`, `color`, and `sound`.
4 |
5 | ```js
6 | function Animal(name, age, color, sound) {
7 | this.name = name;
8 | this.age = age;
9 | this.color = color;
10 | this.sound = sound;
11 | }
12 | ```
13 |
14 | 2. Animals should have a method called `speak` which outputs the `sound` they make.
15 |
16 | ```js
17 | Animal.prototype.speak = function() {
18 | return this.sound;
19 | };
20 | ```
21 |
22 | 3. Create a `Cat` constructor with the same properties as `Animal` (bonus if you use the `call` method). Cats should also have a property called `isFluffy`.
23 |
24 | ```js
25 | function Cat(name, age, color, isFluffy) {
26 | Animal.call(this, name, age, color);
27 | this.sound = "meow";
28 | this.isFluffy = isFluffy;
29 | };
30 | ```
31 |
32 | 4. Implement prototypal inheritance with `Cat` as a subclass of `Animal`.
33 |
34 | ```js
35 | Cat.prototype = new Animal;
36 | Cat.prototype.constructor = Cat;
37 | ```
38 |
39 | 5. Create a new instance of `Cat` and make them speak!
40 |
41 | ```js
42 | cat = new Cat("Sprinkles", 3, "brown", true);
43 | //=> Cat {name: "Sprinkles", age: 3, color: "brown", sound: "meow", isFluffy: true}
44 |
45 | cat.speak();
46 | //=> "meow"
47 | ```
48 |
49 | 6. Check if the cat you just created is an `instanceof` `Cat`. How about an `instanceof` `Animal`?
50 |
51 | ```js
52 | cat instanceof Cat
53 | //=> true
54 |
55 | cat instanceof Animal
56 | //=> true
57 | ```
58 |
59 | 7. Start tonight's homework!
60 |
61 | * apartment-oop (solution branch)
62 |
--------------------------------------------------------------------------------
/01-front-end-basics/oo-prototypes/25/pie-example/Pie.js:
--------------------------------------------------------------------------------
1 | function Pie( crust, filling ) {
2 | // Attributes
3 | this.crust = crust;
4 | this.filling = filling;
5 | this.container = 'my stomach';
6 | this.mold = false;
7 | this.slices = 0;
8 | }
9 |
10 |
11 |
12 |
13 |
14 | Pie.prototype.slice = function() {
15 | this.slices += 2;
16 | console.log("slices : " + this.slices);
17 | };
18 |
19 | Pie.prototype.serve = function( name ) {
20 | if ( this.slices > 0 ) {
21 | console.log("Here's a slice, " + name );
22 | this.slices--;
23 | } else {
24 | console.log("No pie for you!");
25 | }
26 | };
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 | Pie.prototype = {
36 | slice : function() {
37 |
38 | this.slices += 2;
39 | console.log("slices : " + this.slices);
40 | },
41 |
42 | serve : function( name ) {
43 | if ( this.slices > 0 ) {
44 | console.log("Here's a slice, " + name );
45 | this.slices--;
46 | } else {
47 | console.log("No pie for you!");
48 | }
49 | },
50 | };
51 |
52 |
53 | $( document ).ready(function() {
54 |
55 | var apple = new Pie("heavenly", "Apple");
56 | var pumpkin = new Pie("buttery", "Pumpkin");
57 | var pecan = new Pie("flakey", "Pecan");
58 | var pies = [apple, pumpkin, pecan];
59 | pies.forEach(function appendToPiesList(pie) {
60 | pie.slice();
61 | pie.slice();
62 | pie.slice();
63 | pie.slice();
64 | $('#pieslist').append('
I have ' + pie.slices + ' slices of ' + pie.filling+' pie!
2 |
9 |
--------------------------------------------------------------------------------
/02-express-mongo-crud/mongoose-reference-populate/19-20/img/many_to_many.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/02-express-mongo-crud/mongoose-reference-populate/19-20/img/many_to_many.png
--------------------------------------------------------------------------------
/02-express-mongo-crud/mongoose-reference-populate/19-20/img/one_to_many.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/02-express-mongo-crud/mongoose-reference-populate/19-20/img/one_to_many.png
--------------------------------------------------------------------------------
/02-express-mongo-crud/mongoose-reference-populate/19-20/img/one_to_one.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/02-express-mongo-crud/mongoose-reference-populate/19-20/img/one_to_one.png
--------------------------------------------------------------------------------
/02-express-mongo-crud/mongoose-reference-populate/22-23/exercises.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | # Exercises
4 |
5 | ### Setup
6 | To run mongoose commands in terminal:
7 |
8 | 1. `cd ~/dev`
9 | 1. `mkdir w04-d1-dusk`
10 | 1. `cd w04-d1-dusk`
11 | 1. `touch server.js` --> this is where your mongoose code will go
12 | 1. `npm install mongoose`
13 | 1. to run: `nodemon server.js` --> this takes you to the node console
14 |
15 | ### Base Exercises
16 |
17 | 1. Assemble the code in this module's README into your `server.js` file and refactor it to create your own models that use referenced documents. Be creative and make it interesting and relevant (easier said than done).
18 | 1. Create at least 5 'top-level' documents (in my case, five games) and at least 3 referenced documents (in my case, three consoles).
19 | 1. Demonstrate the ability to display the documents with just an ObjectId for the referenced documents.
20 | 1. Finally, call `populate()` on a query and demonstrate the **full** referenced documents as in the README with the Legend of Zelda: Ocarina of Time and the Nintendo 64.
21 |
22 | ### Stretch Exercises
23 |
24 | 1. Add another model to your code to create a multi-tiered structure.
25 | 1. Incorporate both embedded and referenced models.
26 |
27 | ### Tips:
28 |
29 | * Use `.remove` or `.findOneAndRemove` if your database gets cluttered.
30 |
31 | * This `server.js` file might not work exactly because of the *asynchronous* nature of the database operations we're doing. (They can finish in any order -- test this out with console logs in every callback.) Still, each individual snippet of code will be something we can incorporate into our server code later.
32 |
--------------------------------------------------------------------------------
/03-angular-mean/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/03-angular-mean/.gitkeep
--------------------------------------------------------------------------------
/03-angular-mean/api-integration/27-28/readme.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | ## Angular Movie API Integration
4 |
5 | | Objectives |
6 | | :--- |
7 | | Create a single page Angular app from scratch. |
8 | | Make requests to an external API and display the results in a presentable format. |
9 | | Separate appropriate functionality into services and directives. |
10 |
11 |
12 | #### [Starter code](https://github.com/sf-wdi-27-28/angular_movie_project)
13 |
14 | #### Specs
15 |
16 | - The page should have a form that uses the [OMDB api](http://www.omdbapi.com/) to search for matching movies and then display the results.
17 | - *Example*: If a user searches for `Star Wars`, a card for each Star Wars movie result will be displayed.
18 |
19 | - The card display of each movie should include a poster image, the movie title, and the year of release. The display of cards should be responsive and use Bootstrap.
20 |
21 | - When the user clicks on a search result, go to a show page for that movie.
22 | - *Example*: If a user is viewing a list of every Star Wars movie and clicks on `Star Wars: A New Hope`, you will navigate to a show view with a single movie card.
23 |
24 | - Once you have basic API functionality, you should abstract all of the access to the [OMDB api](http://www.omdbapi.com/) into a custom service called `MovieService`. You should be able to ask the `MovieService` to get search results and to get one single movie.
25 |
26 | - Once you have basic display working, you should abstract the card away into a directive called `wdiMovieCard` that takes in a movie object to display.
27 |
--------------------------------------------------------------------------------
/03-angular-mean/auth-angular/25/solutions.md:
--------------------------------------------------------------------------------
1 | # Angular Auth with Satellizer - Solutions
2 |
3 | angular_auth_satellizer (solution branch)
4 |
--------------------------------------------------------------------------------
/03-angular-mean/custom-directives/README.md:
--------------------------------------------------------------------------------
1 | ##Custom Directives, yay!
2 |
--------------------------------------------------------------------------------
/03-angular-mean/intro-angular/25/solutions.md:
--------------------------------------------------------------------------------
1 | # Intro Angular - Solutions
2 |
3 | ## Challenges
4 | ```html
5 |
49 | ```
50 |
51 | 5. Create an array of your favorite programming libraries and/or frameworks in your `site#about` controller method. Pass them into your view and iterate through each of them inside a `
` tag. Create an `
` tag for each favorite language/framework.
52 |
53 | ```ruby
54 | #
55 | # app/controllers/site_controller.rb
56 | #
57 |
58 | class SiteController < ApplicationController
59 | def about
60 | @favorite_language = "Ruby"
61 | @favorite_frameworks = ["Express", "Angular", "Rails"]
62 | end
63 | end
64 | ```
65 |
66 | ```html
67 |
68 |
69 |
73 | <% @favorite_frameworks.each do |framework| %>
74 |
<%= framework %>
75 | <% end %>
76 |
77 | ```
78 |
--------------------------------------------------------------------------------
/04-ruby-rails/intro-ruby/25/exercises.md:
--------------------------------------------------------------------------------
1 | ## Ruby Exercises
2 |
3 | You may create a separate file for each of the exercises to avoid cluttering a file.
4 |
5 | ### Looping And Other Exercises
6 |
7 | Use a loop to do the following:
8 |
9 | 1.) Write a method called `p_times` that takes a `statement` and a `num` puts the `statement` some `num` of times to the console.
10 |
11 | 2.) Write a method called `letter_count` to count letter occurence in a string, returned as a `Hash`.
12 |
13 | 3.) Write a method called `mock_me` that `gets` some input from the terminal and puts it until the input is the word `quit` or `q`. (Be sure to remove trailing `\n`.)
14 |
15 | 4.) Write a method called `print_contacts` that takes a `hash` of `name` and `phone-number` key-value pairs and puts the `name` with the contact info.
16 |
17 | 5.) Write a method called `get_contact` that
18 |
19 | * takes a `contacts` hash,
20 | * prints the contacts,
21 | * prompts the terminal for a **new** `name` and a `phone` number,
22 | * and then adds the `name` and `phone` as a key value pair respectively if `name` is not already a contact.
23 | * The `get_contact` method should `return` the `contacts` hash.
24 |
25 | ### List exercises
26 |
27 | #### Using `Array#inject`
28 | [API on Array#inject](http://apidock.com/ruby/Enumerable/inject)
29 |
30 | Write a method for each exercise below that uses `Array#inject`:
31 |
32 | 1.) Write a method called `get_sum` to find the `sum` of the values in an array.
33 |
34 | 2.) Write a method called `get_max` to find the `max` of the values in an array.
35 |
36 | 3.) Write a method called `get_min` to find the `min` of the values in an array.
37 |
38 | 4.) Write a method called `reverse_str` to reverse a string.
39 |
40 | **Challenge**: *write a method called `partial_sums` that pushes the partial sum of an array to a new list*
41 |
42 | ```
43 | partial_sums([])
44 | #=> [0]
45 | partial_sums([5])
46 | #=> [0, 5]
47 | partial_sums([5,6,7])
48 | #=> [0, 5, 11, 18]
49 | ```
50 |
51 | #### Using `Array#map`
52 | [API on Array#map] (http://ruby-doc.org/core-2.2.0/Array.html#method-i-map)
53 |
54 | Write a method for each exercise below that uses `Array#map`:
55 |
56 | 1.) Write a method called `multiply_by` that takes a number and returns an array of numbers multiplied by that number.
57 |
58 | 2.) Write a method called `reverse_each` that takes an array of words and returns an array of reversed words.
59 |
60 | 3.) Write method called `get_responses` that takes an array of questions (strings) and returns an array of responses input from the console for each question. (Hint: you will need to use `gets.chomp` and `puts` )
61 |
62 | ### Method Problems
63 |
64 | * Write a method to compute the `factorial` of a number.
65 | * Write a method to check if a number is a `palindrome`.
66 | * Write a method to `reverse` a word in-place, do not use iterators, use only a while loop and indices.
67 | * Write a method to `merge` to two sorted Arrays.
68 |
--------------------------------------------------------------------------------
/04-ruby-rails/intro-ruby/25/solutions.js:
--------------------------------------------------------------------------------
1 | // javascript solutions to looping exercisces
2 |
3 | // In our old javascript way
4 | var pTimes = function(statement,num) {
5 | for (var i = 0; i < num; i++) {
6 | console.log(statement);
7 | }
8 | }
9 | // In a more ruby like way
10 | var pTimes2 = function(statement,num) {
11 | var i = 0;
12 | while(i < num) {
13 | console.log(statement);
14 | i += 1;
15 | }
16 | }
17 |
18 | // Solution to Exercise 2 in javascript
19 | var letterCount = function(str) {
20 | var ans = {};
21 | for (var i = 0; i ' + contacts[i]);
54 | }
55 | }
56 |
57 | printContacts({'michael': '555-555-5555', 'delmer': '666-666-6666'});
58 |
--------------------------------------------------------------------------------
/04-ruby-rails/intro-ruby/25/solutions.rb:
--------------------------------------------------------------------------------
1 | # Basic Solution to Exercise 1
2 | def pTimes(statement,num)
3 | i = 0
4 | while i < num do
5 | puts statement
6 | i += 1
7 | end
8 | end
9 |
10 | # A spiffy way to do it
11 | def pTimes2(statement,num)
12 | num.times do
13 | puts statement
14 | end
15 | end
16 |
17 | # pTimes('hello',5)
18 |
19 | # Solution to Exercise 2
20 | def letterCount(str)
21 | ans = {}
22 | i = 0
23 | while i < str.length do
24 | if ans[str[i]] == nil
25 | ans[str[i]] = 1
26 | else
27 | ans[str[i]] += 1
28 | end
29 | i += 1
30 | end
31 | ans
32 | end
33 |
34 | # puts letterCount 'hello'
35 | def mockMe
36 | while true do
37 | mock = gets.chomp
38 | if mock == 'quit'
39 | break
40 | else
41 | puts mock
42 | end
43 | end
44 | end
45 |
46 | # mockMe
47 |
48 | # Exercise 4
49 | def printContacts(contacts)
50 | contacts.each do |k,v,l|
51 | puts k, v
52 | end
53 | end
54 |
55 | contactsHash = {'michael' => '555-555-5555', 'del' => '666-666-6666'}
56 | # printContacts contactsHash
57 |
58 | # Exercise 5
59 | def getContact(contacts)
60 | puts contacts
61 | puts 'Name: '
62 | name = gets.chomp
63 | puts 'Phone: '
64 | phone = gets.chomp
65 | contacts[name] = phone
66 | contacts
67 | end
68 |
69 | # puts getContact contactsHash
70 |
71 | ## List exercises
72 | def getSum(xs)
73 | xs.inject do |memo,x|
74 | memo + x
75 | end
76 | end
77 |
78 | # puts getSum [1,2,3]
79 |
80 | def getMax(xs)
81 | xs.inject do |memo,x|
82 | if memo < x
83 | x
84 | else
85 | memo
86 | end
87 | end
88 | end
89 |
90 | # puts getMax [1,2,5,4,3]
91 |
92 | def getMin(xs)
93 | xs.inject do |memo,x|
94 | if memo < x
95 | memo
96 | else
97 | x
98 | end
99 | end
100 | end
101 |
102 | # puts getMin [1,2,-2,5,4,3]
103 |
104 | def reverseStr(str)
105 | str.chars.inject do |memo, x|
106 | x + memo
107 | end
108 | end
109 |
110 | # puts reverseStr "hello world"
111 |
112 | def partialSums(arr)
113 | sums = [0]
114 | arr.inject(0) do |memo,x|
115 | sums.push(memo+x)
116 | memo+x
117 | end
118 | sums
119 | end
120 |
121 | # p partialSums [1,2,3]
122 |
123 | def multiplyBy(num,arr)
124 | arr.map do |x|
125 | x * num
126 | end
127 | end
128 |
129 | def reverseEach(arr)
130 | arr.map do |x|
131 | reverseStr x
132 | end
133 | end
134 |
135 | # p reverseEach ['hello','world','michael']
136 |
137 | def getResponses(arr)
138 | arr.map do |x|
139 | puts x
140 | gets.chomp
141 | end
142 | end
143 |
144 | # p getResponses ['what','the','fuck']
145 |
146 | def factorial(n)
147 | if n < 2
148 | 1
149 | else
150 | n * factorial(n-1)
151 | end
152 | end
153 |
154 | # puts factorial 4
155 |
156 |
--------------------------------------------------------------------------------
/04-ruby-rails/intro-sql/25/challenges.md:
--------------------------------------------------------------------------------
1 | #Challenges
2 |
3 | 1. Use SQL aggregators to get the total value of the inventory, calculated as the sum of the price*quantity for each item.
4 |
5 | 2. Create a books table based on the printed table above. It should have attributes for `id`, `title`, `pub_year`, `isbn`, and `author_id`. For now, just make the `author_id` an INTEGER.
6 |
7 | 3. Add the classic children's books from earlier in this readme into your books table.
8 |
9 | 4. The library wants to start selling off old books. Add a `book_id` attribute to the products table so that the library can store books as inventory.
10 |
11 | 5. Insert the books from your books table into your products table. Make up a price and quantity for them.
12 |
13 | #Stretch Challenges
14 |
15 | 1. Find the inventory value of each book, and sort the records by inventory value, in descending order.
16 |
17 | 2. Find the inventory value of the books by Lewis Caroll.
18 |
--------------------------------------------------------------------------------
/04-ruby-rails/intro-sql/25/friends.sql:
--------------------------------------------------------------------------------
1 | DROP DATABASE IF EXISTS friends_example;
2 | CREATE DATABASE friends_example;
3 |
4 | \c friends_example
5 |
6 | CREATE TABLE biking_friends (
7 | id SERIAL PRIMARY KEY,
8 | name varchar(255)
9 | );
10 |
11 | CREATE TABLE running_friends (
12 | id SERIAL PRIMARY KEY,
13 | name varchar(255)
14 | );
15 |
16 | INSERT INTO biking_friends (name) VALUES ('john doe');
17 | INSERT INTO biking_friends (name) VALUES ('jane doe');
18 | INSERT INTO biking_friends (name) VALUES ('jack doe');
19 | INSERT INTO biking_friends (name) VALUES ('jay doe');
20 | INSERT INTO biking_friends (name) VALUES ('jen doe');
21 | INSERT INTO biking_friends (name) VALUES ('jesse doe');
22 |
23 |
24 | INSERT INTO running_friends (name) VALUES ('max doe');
25 | INSERT INTO running_friends (name) VALUES ('jen doe');
26 | INSERT INTO running_friends (name) VALUES ('john doe');
27 | INSERT INTO running_friends (name) VALUES ('jane doe');
28 | INSERT INTO running_friends (name) VALUES ('jesse doe');
29 | INSERT INTO running_friends (name) VALUES ('ruby doe');
30 |
--------------------------------------------------------------------------------
/04-ruby-rails/intro-sql/27/assets/README.md:
--------------------------------------------------------------------------------
1 | this directory will hold image assets
2 |
--------------------------------------------------------------------------------
/04-ruby-rails/intro-sql/27/assets/postgresql-cheat-sheet.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/04-ruby-rails/intro-sql/27/assets/postgresql-cheat-sheet.pdf
--------------------------------------------------------------------------------
/04-ruby-rails/intro-sql/27/assets/primary_foreign_key.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/04-ruby-rails/intro-sql/27/assets/primary_foreign_key.png
--------------------------------------------------------------------------------
/04-ruby-rails/intro-sql/27/assets/sqljoins.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/04-ruby-rails/intro-sql/27/assets/sqljoins.jpg
--------------------------------------------------------------------------------
/04-ruby-rails/intro-sql/27/challenges.md:
--------------------------------------------------------------------------------
1 | #Challenges
2 |
3 | 1. Use SQL aggregators to get the total value of the inventory, calculated as the sum of the `price * quantity` for each item.
4 |
5 | 2. Create a books table based on the printed table above. It should have attributes for `id`, `title`, `pub_year`, `isbn`, and `author_id`. For now, just make the `author_id` an INTEGER.
6 |
7 | 3. Add the classic children's books from the reamde into your books table.
8 |
9 | 4. The library wants to start selling off old books. Add a `book_id` attribute to the products table so that the library can store books as inventory.
10 |
11 | 5. Insert the books from your books table into your products table. Make up a price and quantity for them.
12 |
13 | #Stretch Challenges
14 |
15 | 1. Find the inventory value of each book, and sort the records by inventory value, in descending order.
16 |
17 | 2. Find the inventory value of the books by Lewis Caroll.
18 |
--------------------------------------------------------------------------------
/04-ruby-rails/intro-sql/27/friends.sql:
--------------------------------------------------------------------------------
1 | DROP DATABASE IF EXISTS friends_example;
2 | CREATE DATABASE friends_example;
3 |
4 | \c friends_example
5 |
6 | CREATE TABLE biking_friends (
7 | id SERIAL PRIMARY KEY,
8 | name varchar(255)
9 | );
10 |
11 | CREATE TABLE running_friends (
12 | id SERIAL PRIMARY KEY,
13 | name varchar(255)
14 | );
15 |
16 | INSERT INTO biking_friends (name) VALUES ('john doe');
17 | INSERT INTO biking_friends (name) VALUES ('jane doe');
18 | INSERT INTO biking_friends (name) VALUES ('jack doe');
19 | INSERT INTO biking_friends (name) VALUES ('jay doe');
20 | INSERT INTO biking_friends (name) VALUES ('jen doe');
21 | INSERT INTO biking_friends (name) VALUES ('jesse doe');
22 |
23 |
24 | INSERT INTO running_friends (name) VALUES ('max doe');
25 | INSERT INTO running_friends (name) VALUES ('jen doe');
26 | INSERT INTO running_friends (name) VALUES ('john doe');
27 | INSERT INTO running_friends (name) VALUES ('jane doe');
28 | INSERT INTO running_friends (name) VALUES ('jesse doe');
29 | INSERT INTO running_friends (name) VALUES ('ruby doe');
30 |
--------------------------------------------------------------------------------
/04-ruby-rails/intro-sql/27/startercode.sql:
--------------------------------------------------------------------------------
1 | -- run this file with psql -f startercode.sql
2 | -- Setup --
3 | DROP DATABASE IF EXISTS library_app; -- if the library_app database exists, remove it...
4 | CREATE DATABASE library_app; -- and recreate it
5 |
6 | DROP TABLE authors; -- go ahead and drop our tables as well
7 | DROP TABLE products; -- to be more careful, we could drop these tables IF EXISTS
8 | DROP TABLE books;
9 |
10 | CREATE TABLE authors (
11 | id SERIAL PRIMARY KEY,
12 | first_name VARCHAR(255),
13 | year_of_birth INTEGER,
14 | year_of_death INTEGER,
15 | created_at TIMESTAMP NOT NULL DEFAULT now()
16 | );
17 |
18 | CREATE TABLE products (
19 | id SERIAL PRIMARY KEY,
20 | name VARCHAR(255),
21 | price NUMERIC NOT NULL DEFAULT 'NaN',
22 | quantity INTEGER NOT NULL DEFAULT 0
23 | );
24 |
25 | INSERT INTO products
26 | (name, price, quantity)
27 | VALUES
28 | ('bookmark', 0.50, 200),
29 | ('book cover', 2.00, 75),
30 | ('bookbag', 65.00, 20),
31 | ('bookbag', 50.00, 20),
32 | ('reading light', 25.00, 10);
33 |
--------------------------------------------------------------------------------
/04-ruby-rails/intro-sql/28/assets/README.md:
--------------------------------------------------------------------------------
1 | this will hold images.
2 |
--------------------------------------------------------------------------------
/04-ruby-rails/intro-sql/28/assets/primary_foreign_key.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/04-ruby-rails/intro-sql/28/assets/primary_foreign_key.png
--------------------------------------------------------------------------------
/04-ruby-rails/intro-sql/28/assets/sqljoins.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/04-ruby-rails/intro-sql/28/assets/sqljoins.jpg
--------------------------------------------------------------------------------
/04-ruby-rails/intro-sql/28/challenges.md:
--------------------------------------------------------------------------------
1 | #Challenges
2 |
3 | 1. Use SQL aggregators to get the total value of the inventory, calculated as the sum of the price*quantity for each item.
4 |
5 | 2. Create a books table based on the printed table above. It should have attributes for `id`, `title`, `pub_year`, `isbn`, and `author_id`. For now, just make the `author_id` an INTEGER.
6 |
7 | 3. Add the classic children's books from earlier in this readme into your books table.
8 |
9 | 4. The library wants to start selling off old books. Add a `book_id` attribute to the products table so that the library can store books as inventory.
10 |
11 | 5. Insert the books from your books table into your products table. Make up a price and quantity for them.
12 |
13 | #Stretch Challenges
14 |
15 | 1. Find the inventory value of each book, and sort the records by inventory value, in descending order.
16 |
17 | 2. Find the inventory value of the books by Lewis Caroll.
18 |
--------------------------------------------------------------------------------
/04-ruby-rails/intro-sql/28/friends.sql:
--------------------------------------------------------------------------------
1 | DROP DATABASE IF EXISTS friends_example;
2 | CREATE DATABASE friends_example;
3 |
4 | \c friends_example
5 |
6 | CREATE TABLE biking_friends (
7 | id SERIAL PRIMARY KEY,
8 | name varchar(255)
9 | );
10 |
11 | CREATE TABLE running_friends (
12 | id SERIAL PRIMARY KEY,
13 | name varchar(255)
14 | );
15 |
16 | INSERT INTO biking_friends (name) VALUES ('john doe');
17 | INSERT INTO biking_friends (name) VALUES ('jane doe');
18 | INSERT INTO biking_friends (name) VALUES ('jack doe');
19 | INSERT INTO biking_friends (name) VALUES ('jay doe');
20 | INSERT INTO biking_friends (name) VALUES ('jen doe');
21 | INSERT INTO biking_friends (name) VALUES ('jesse doe');
22 |
23 |
24 | INSERT INTO running_friends (name) VALUES ('max doe');
25 | INSERT INTO running_friends (name) VALUES ('jen doe');
26 | INSERT INTO running_friends (name) VALUES ('john doe');
27 | INSERT INTO running_friends (name) VALUES ('jane doe');
28 | INSERT INTO running_friends (name) VALUES ('jesse doe');
29 | INSERT INTO running_friends (name) VALUES ('ruby doe');
30 |
--------------------------------------------------------------------------------
/04-ruby-rails/js-and-turbolinks/27/exercises.md:
--------------------------------------------------------------------------------
1 | [Rails and JS Lab with Turbolinks](https://github.com/SF-WDI-LABS/rails_with_js_and_turbolinks)
2 |
--------------------------------------------------------------------------------
/04-ruby-rails/migration-hell/README.md:
--------------------------------------------------------------------------------
1 | # Migration Hell Drills
2 |
3 | In this drill, we're going to explore migration hell. Please come along.
4 |
5 | The #1 rule of migration hell is this:
6 | ##### DON'T MODIFY EXISTING MIGRATIONS
7 |
8 | Got it?
9 |
10 | Cool.
11 |
12 | Let's begin
13 |
14 | ### Create an app with some migrations
15 |
16 | 1. Create a new rails app. Make sure to use postgres. You got this one.
17 |
18 | 1. Add some models
19 | ```console
20 | > rails g model recipe name:string instructions:string posted:string
21 | > rails g model ingredient name:string amount:string
22 | ```
23 | 1. Create a relationship between these models using the [has_and_belongs_to_many](http://guides.rubyonrails.org/association_basics.html#has-and-belongs-to-many-association-reference) shorthand.
24 |
25 | ```console
26 | > rails g migration create_join_table_ingredients_recipes ingredients recipes
27 | ```
28 | 1. Migrate!
29 |
30 | 1. Add the relationship in your models:
31 |
32 | ```ruby
33 | # models/ingredient.rb
34 | class Ingredient < ActiveRecord::Base
35 | has_and_belongs_to_many :recipes
36 | end
37 | ```
38 |
39 | ```ruby
40 | # models/recipe.rb
41 | class Recipe < ActiveRecord::Base
42 | has_and_belongs_to_many :ingredients
43 | end
44 | ```
45 | 1. Test out these associations in the rails console.
46 |
47 | ### Exercises
48 |
49 | 1. Oops! I forgot that I wanted an `author` attribute on the `recipe` model. **Add this attribute** now keeping in mind the #1 rule of migration hell.
50 |
51 | 1. Now that I'm thinking about it, I actually don't want that `author` attribute... Sorry. Can you **delete this attribute**?
52 |
53 | 1. This is really weird. I really didn't think this was going to happen, but I was thinking... shouldn't `instructions` actually be called `steps`? Yeah. That makes more sense to me. **Modify this attribute**.
54 |
55 | 1. I just realized that I accidentally made the `posted` attribute on recipes a string! This should be a datetime, der. Can you help me out to **change this datatype**?
56 |
57 | 1. I want a **new table**. Let's call it `comments` and make it a 1:n relationship with `recipes`. K thanks.
58 |
59 | 1. Blerg I HATE comments. Comments are sooo 2015. **Drop that table**.
60 |
--------------------------------------------------------------------------------
/04-ruby-rails/migration-hell/solutions.md:
--------------------------------------------------------------------------------
1 | 1. `rails g migration add_author_to_recipe author:string`
2 |
3 | 1. `rails g migration remove_author_from_recipe author:string`
4 |
5 | 1. `rails g migration change_column_name_instructions_in_recipe_to_steps`
6 | then in the migration
7 | ```ruby
8 | rename_column :recipe, :instructions, :steps
9 | ```
10 | 1. `rails g remove_posted_from_recipe`
11 | `rails g add_posted_to_recipe posted:datetime`
12 |
13 | 1. `rails g model comment`
14 |
15 | 1. `rails destroy model comment`
16 |
--------------------------------------------------------------------------------
/04-ruby-rails/migrations-and-associations/22-23/many_to_many_challenges.md:
--------------------------------------------------------------------------------
1 | # Many-to-Many Challenges
2 |
3 | Our goal is to build the relationship between `actors` and `movies`. An actor can appear in many movies, and a movie can have many actors. How would you set up this relationship? Is there an additional data table we need besides `actors` and `movies`? **Hint:** Think back to the relationship between students and courses.
4 |
5 | Here's what our models' attributes might look like for actors and movies:
6 | * `Actor`: first_name, last_name
7 | * `Movie`: title, description, year
8 |
9 | For these challenges, continue to work in your `practice` Rails app.
10 |
11 | ## Your Task
12 |
13 | 1. Create models and migrations for three tables: `actors`, `movies`, and a *join* table. Think about what you should name your join table and what columns it should have.
14 | 2. Implement a many-to-many relationship between `actors` and `movies`.
15 | 3. Use the Rails console to create at least three `actors` and two `movies`. Each movie should have at least one actor associated with it.
16 |
17 | ## Stretch Challenges
18 |
19 | 1. Add validations to your `Actor` and `Movie` models:
20 | * All attributes for actors and movies should be required (**Hint:** `presence: true`)
21 | * For movies, the year should not be in the future (**Hint:** Look at numericality)
22 |
23 | 2. Test your validations in the Rails console:
24 |
25 | ```ruby
26 | a = Actor.create
27 | a.errors.messages
28 | # => What does this return?
29 | ```
30 |
31 |
--------------------------------------------------------------------------------
/04-ruby-rails/migrations-and-associations/22-23/solution_link.md:
--------------------------------------------------------------------------------
1 | [solution](https://github.com/sf-wdi-22-23/modules-22/tree/master/w07-rails/d1-dusk-associations/solution)
2 |
--------------------------------------------------------------------------------
/04-ruby-rails/migrations-and-associations/24/many-to-many-challenges.md:
--------------------------------------------------------------------------------
1 | # Many-to-Many Challenges
2 |
3 | Our goal is to build the relationship between `actors` and `movies`. An actor can appear in many movies, and a movie can have many actors. How would you set up this relationship? Is there an additional data table we need besides `actors` and `movies`? **Hint:** Think back to the relationship between students and courses.
4 |
5 | Here's what our models' attributes might look like for actors and movies:
6 | * `Actor`: first_name, last_name
7 | * `Movie`: title, description, year
8 |
9 | For these challenges, continue to work in your `practice_associations` Rails app.
10 |
11 | ## Your Task
12 |
13 | 1. Create models and migrations for three tables: `actors`, `movies`, and a *join* table. Think about what you should name your join table and what columns it should have.
14 | 2. Implement a many-to-many relationship between `actors` and `movies`.
15 | 3. Use the Rails console to create at least three `actors` and two `movies`. Each movie should have at least one actor associated with it.
16 |
17 | ## Stretch Challenges
18 |
19 | 1. Add validations to your `Actor` and `Movie` models:
20 | * All attributes for actors and movies should be required (**Hint:** `presence: true`)
21 | * For movies, the year should not be in the future (**Hint:** Look at numericality)
22 |
23 | 2. Test your validations in the Rails console:
24 |
25 | ```ruby
26 | a = Actor.create
27 | a.errors.messages
28 | # => What does this return?
29 | ```
30 |
--------------------------------------------------------------------------------
/04-ruby-rails/migrations-and-associations/24/solutions.md:
--------------------------------------------------------------------------------
1 | # Practice Associations
2 |
3 | ## One-to-Many Challenges
4 |
5 | *Solutions for Rails console portions:*
6 |
7 | 1. Create an item:
8 |
9 | ```ruby
10 | i = Item.create(name: "lamp", description: "desk lamp", price: 20)
11 | ```
12 |
13 | 2. Create an order:
14 |
15 | ```ruby
16 | o = Order.create
17 | ```
18 |
19 | 3. Associate item to order:
20 |
21 | ```ruby
22 | o.items << i
23 | ```
24 |
25 | 4. For one order, iterate through each of its items and print the item details to the console:
26 |
27 | ```ruby
28 | o.items.each do |item|
29 | puts "#{item.name}: #{item.description}, $#{item.price}"
30 | end
31 | ```
32 |
33 | 5. Map each item in your database to its name:
34 |
35 | ```ruby
36 | Item.all.map(&:name)
37 | ```
38 |
39 | **Stretch:** Select only the items in an order that are less than a certain price:
40 |
41 | ```ruby
42 | o.items.where("price < ?", 30)
43 | ```
44 |
45 | ## Many-To-Many Challenges
46 |
47 | *Solutions for Rails console portions:*
48 |
49 | Create actor, movie, and association:
50 |
51 | ```ruby
52 | arnold = Actor.create(first_name: "Arnold", last_name: "Schwarzenegger")
53 | terminator = Movie.create(title: "The Terminator", description: "science fiction film", year: 1984)
54 | terminator.actors << arnold
55 |
56 | # check associations
57 | terminator.actors
58 | arnold.movies
59 | ```
60 |
--------------------------------------------------------------------------------
/04-ruby-rails/migrations-and-associations/25/exercises.md:
--------------------------------------------------------------------------------
1 | Go to [https://github.com/sf-wdi-25/breweries_models_and_migrations](https://github.com/sf-wdi-25/breweries_models_and_migrations)
2 |
--------------------------------------------------------------------------------
/04-ruby-rails/migrations-and-associations/25/solutions.md:
--------------------------------------------------------------------------------
1 | See the solutions branch on [https://github.com/sf-wdi-25/breweries_models_and_migrations](https://github.com/sf-wdi-25/breweries_models_and_migrations)
2 |
--------------------------------------------------------------------------------
/04-ruby-rails/migrations-and-associations/27/many_to_many_challenges.md:
--------------------------------------------------------------------------------
1 | # Many-to-Many Challenges
2 |
3 | Our goal is to build the relationship between `actors` and `movies`. An actor can appear in many movies, and a movie can have many actors. How would you set up this relationship? Is there an additional data table we need besides `actors` and `movies`? **Hint:** Think back to the relationship between students and courses.
4 |
5 | Here's what our models' attributes might look like for actors and movies:
6 | * `Actor`: first_name, last_name
7 | * `Movie`: title, description, year
8 |
9 | For these challenges, continue to work in your `practice` Rails app.
10 |
11 | ## Your Task
12 |
13 | 1. Create models and migrations for three tables: `actors`, `movies`, and a *join* table. Think about what you should name your join table and what columns it should have.
14 | 2. Implement a many-to-many relationship between `actors` and `movies`.
15 | 3. Use the Rails console to create at least three `actors` and two `movies`. Each movie should have at least one actor associated with it.
16 |
17 | ## Stretch Challenges
18 |
19 | 1. Add validations to your `Actor` and `Movie` models:
20 | * All attributes for actors and movies should be required (**Hint:** `presence: true`)
21 | * For movies, the year should not be in the future (**Hint:** Look at numericality)
22 |
23 | 2. Test your validations in the Rails console:
24 |
25 | ```ruby
26 | a = Actor.create
27 | a.errors.messages
28 | # => What does this return?
29 | ```
30 |
--------------------------------------------------------------------------------
/04-ruby-rails/migrations-and-associations/27/solutions.md:
--------------------------------------------------------------------------------
1 | # Practice Associations
2 |
3 | ## One-to-Many Challenges
4 |
5 | *Solutions for Rails console portions:*
6 |
7 | 1. Create an item:
8 |
9 | ```ruby
10 | i = Item.create(name: "lamp", description: "desk lamp", price: 20)
11 | ```
12 |
13 | 2. Create an order:
14 |
15 | ```ruby
16 | o = Order.create
17 | ```
18 |
19 | 3. Associate item to order:
20 |
21 | ```ruby
22 | o.items << i
23 | ```
24 |
25 | 4. For one order, iterate through each of its items and print the item details to the console:
26 |
27 | ```ruby
28 | o.items.each do |item|
29 | puts "#{item.name}: #{item.description}, $#{item.price}"
30 | end
31 | ```
32 |
33 | 5. Map each item in your database to its name:
34 |
35 | ```ruby
36 | Item.all.map { |item| item.name }
37 | # which can be shortened to
38 | Item.all.map(&:name)
39 | ```
40 |
41 | **Stretch:** Select only the items in an order that are less than a certain price:
42 |
43 | ```ruby
44 | o.items.where("price < ?", 30)
45 | ```
46 |
47 | ## Many-To-Many Challenges
48 |
49 | *Solutions for Rails console portions:*
50 |
51 | Create actor, movie, and association:
52 |
53 | ```ruby
54 | arnold = Actor.create(first_name: "Arnold", last_name: "Schwarzenegger")
55 | terminator = Movie.create(title: "The Terminator", description: "science fiction film", year: 1984)
56 | terminator.actors << arnold
57 |
58 | # check associations
59 | terminator.actors
60 | arnold.movies
61 | ```
62 |
--------------------------------------------------------------------------------
/04-ruby-rails/model-validations-error-handling/27/github-500.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/04-ruby-rails/model-validations-error-handling/27/github-500.png
--------------------------------------------------------------------------------
/04-ruby-rails/model-validations-error-handling/28/github-500.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/04-ruby-rails/model-validations-error-handling/28/github-500.png
--------------------------------------------------------------------------------
/04-ruby-rails/rails-auth/28/solution.md:
--------------------------------------------------------------------------------
1 | Here is one solution implementing auth in Rails.
2 |
--------------------------------------------------------------------------------
/04-ruby-rails/rails-gems/pretty-urls.md:
--------------------------------------------------------------------------------
1 | # How to add Friendly Ids (for pretty urls) to an existing project
2 |
3 | ## FriendlyId
4 |
5 | [Docs on GitHub](https://github.com/norman/friendly_id)
6 |
7 | 1. Add the gem to your gemfile.
8 |
9 | ```console
10 | gem 'friendly_id'
11 | ```
12 |
13 | 1. After including FriendlyId, run the bundle command.
14 |
15 | ```console
16 | bundle install
17 | ```
18 |
19 | 1. In order to add FriendlyId to an existing application, we will need to create a migration to add the necessary field to the model we want to use FriendlyId with. We add `uniq` to enforce unique slug values.
20 |
21 | ```console
22 | rails g migration AddSlugToPost slug:uniq
23 | ```
24 |
25 | 1. Now we need to update our database:
26 |
27 | ```console
28 | rake db:migrate
29 | ```
30 |
31 | 1. Now, we need to add code to our model to tell rails that we wish to use FriendlyId. Open the desired model and add the following code.
32 |
33 | ```ruby
34 | extend FriendlyId
35 | friendly_id :title, use: :slugged
36 | ```
37 |
38 | 1. We are almost there! While technically we are all set up and good to go, existing data still doesn't have a slug. If you have existing data, in order to add a slug, start a rails console:
39 |
40 | ```console
41 | rails c
42 | ```
43 |
44 | 1. Inside the rails console, run a command to loop through each model and save it:
45 |
46 | ```
47 | Post.find_each(&:save)
48 | ```
49 |
50 | 1. As a final step, we need to change our `.find`s to friendly finds everywhere in the application.
51 |
52 | ```ruby
53 | Post.find(params[:id])
54 | ```
55 |
56 | becomes
57 |
58 | ```ruby
59 | Post.friendly.find(params[:id])
60 | ```
61 |
62 | 1. Now it should work! Checkout out your new, prettier URLs.
63 |
--------------------------------------------------------------------------------
/04-ruby-rails/rails-view-helpers-and-partials/25/exercises.md:
--------------------------------------------------------------------------------
1 | Scan through [the glossary](glossary.md).
2 | You may also want to look at the examples in [the demo app](https://github.com/tgaff/view_helpers_demo_app/tree/master/app/views/people)
3 |
4 | Do [rails partials helpers](https://github.com/sf-wdi-25/rails_partials_helpers) refactor challenge.
5 |
--------------------------------------------------------------------------------
/04-ruby-rails/rails-view-helpers-and-partials/25/solutions.md:
--------------------------------------------------------------------------------
1 | See [rails partials helpers](https://github.com/sf-wdi-25/rails_partials_helpers) refactor challenge.
2 |
--------------------------------------------------------------------------------
/04-ruby-rails/rails-view-helpers-and-partials/27/exercises.md:
--------------------------------------------------------------------------------
1 | Scan through [the glossary](glossary.md).
2 | You may also want to look at the examples in [the demo app](https://github.com/tgaff/view_helpers_demo_app/tree/master/app/views/people)
3 |
4 | Do [rails partials helpers](https://github.com/sf-wdi-27-28/rails_partials_helpers) refactor challenge.
5 |
--------------------------------------------------------------------------------
/04-ruby-rails/rangular/24/solutons.md:
--------------------------------------------------------------------------------
1 | # MEAN Stack & Rails Angular - Solutions
2 |
3 | * MEAN Todo
4 | * Rails Angular Todo
5 |
--------------------------------------------------------------------------------
/04-ruby-rails/rspec-integration-testing-with-capybara/27/exercises.md:
--------------------------------------------------------------------------------
1 | See the [capybara lab](https://github.com/sf-wdi-27-28/testing_inventory_capybara)
2 |
--------------------------------------------------------------------------------
/04-ruby-rails/rspec-unit-tests/27/exercises.md:
--------------------------------------------------------------------------------
1 | [RSpec Lab](https://github.com/sf-wdi-27-28/rspec_testing_inventory)
2 |
--------------------------------------------------------------------------------
/04-ruby-rails/ruby-methods/22/README.md:
--------------------------------------------------------------------------------
1 | # Ruby Methods Practice
2 |
3 |
4 | | Objectives: Students will be able to... |
5 | |:--- |
6 | | Write methods in Ruby to solve problems. |
7 |
8 | ## Lesson Structure
9 |
10 | In this folder, there are three exercises that challenge you to:
11 | * use a gem to make an http request (real-world problem)
12 | * write a simple number guessing game (logic practice)
13 | * test whether a number is prime (common interview problem)
14 |
15 | Also, we have a Ruby Methods Drills activity focused on Test-Driven Development (TDD).
16 |
17 | Today, we'll do:
18 | * the "Using a Gem" exercise from exercises.md (real world problem).
19 | * the "Primes" exercise from exercises.md (common interview problem).
20 | * Ruby Methods Drills (lots of practice)!
21 |
22 | ## How to run a ruby script inside a file
23 |
24 | 1. `touch script.rb` in the Terminal to create your file
25 | 2. `sublime script.rb` - open it up and add some content
26 | 3. `ruby script.rb` from the Terminal to run it in the Terminal, OR
27 | 5. From inside irb, you can run a Ruby file by loading it: `load './filename.rb'`
28 |
29 | ## How to use gems in irb
30 |
31 | Gems in Ruby are a lot like node modules. Say you want to use a gem like "Awesome Print" to make your printing of objects and strings colorized and indented?
32 |
33 | 1. First install the gem on your computer: `gem install awesome_print`.
34 | 2. Now just require it at the top of your file or in irb and then use it according to its documentation. For example, `awesome_print` gives us an `ap` command:
35 |
36 | ```ruby
37 | require 'awesome_print'
38 | a = ["value1", "value2", "value3"]
39 | ap a
40 | ```
41 |
42 | [Ruby Toolbox](https://www.ruby-toolbox.com/) lists some popular gems!
43 |
44 |
--------------------------------------------------------------------------------
/04-ruby-rails/ruby-methods/22/exercises.md:
--------------------------------------------------------------------------------
1 | ## Ruby Method Exercises
2 |
3 | **Using a Gem**
4 |
5 | 1. Let's have an [HTTParty](https://github.com/jnunemaker/httparty) -- go ahead and open the docs!
6 |
7 | 1. Install the httparty gem from your Terminal with `gem install httparty`.
8 |
9 | 1. Require the gem in a new ruby script file with `require 'httparty'`.
10 |
11 | 1. Referencing the httparty docs and the spotify API docs, create a `spotify_album_search` method. It should use the gem to do an album search on the word "White" to the spotify API.
12 |
13 | 1. Update your method to return the response body, parsed as JSON.
14 |
15 | 1. Update your method to loop through and print the album names from your search.
16 |
17 | 1. Update your method to optionally take a parameter for the album name.
18 |
19 | **Guessing Game**
20 |
21 | 1. Create a program that runs in the Terminal and asks the user to guess a number between 1 and 100. Hint: `gets.chomp`.
22 |
23 | 1. Once the user guesses a number, the program should respond with "higher" or "lower", or report that the number was correct. The user should continue to make guesses until the correct number is found.
24 |
25 | 1. Once the user guesses correctly, the program should print the number of guesses needed to arrive at the correct answer.
26 |
27 | Sample interaction:
28 |
29 | ```
30 | Guess a number between 1 and 100
31 | 50
32 | The number is lower than 50. Guess again!
33 | 25
34 | The number is lower than 25. Guess again!
35 | 13
36 | The number is higher than 13. Guess again!
37 | 20
38 | The number is lower than 20. Guess again!
39 | 17
40 | The number is higher than 17. Guess again!
41 | 18
42 | The number is higher than 18. Guess again!
43 | 19
44 | You got 19 in 7 tries!
45 | ```
46 |
47 | **Test Primes (popular interview question!)**
48 |
49 | 1. Write an `is_prime?` method to check if a number is prime. A prime number is:
50 | * greater than 1
51 | * evenly divisible by 1
52 | * evenly divisible by itself
53 | * not evenly divisible by any other numbers between 1 and itself
54 |
55 | 1. Make your `is_prime?` method more efficient. Three hints on how to proceed are spaced out below. Before implementing each hint, develop a short argument to convince yourself that it works.
56 |
57 |
58 | * Hint: only check possible divisors up to half the original number
59 |
60 | * Hint: only check possible divisors up to the square root of the original number
61 |
62 | * Hint: if the number isn't 2, only check whether the number is divisible by odd numbers
63 |
--------------------------------------------------------------------------------
/04-ruby-rails/ruby-methods/22/solutions/guessing_game.rb:
--------------------------------------------------------------------------------
1 | ## Guessing Game ##
2 | def guessing_game
3 | puts "Guess a number between 1 and 100"
4 | correct = Random.new.rand(1..100)
5 | num_guesses = 1
6 | current_guess = gets.chomp.to_i
7 |
8 | while current_guess != correct
9 | if current_guess > correct
10 | puts "The number is lower than #{current_guess}. Guess again"
11 | elsif current_guess < correct
12 | puts "The number is higher than #{current_guess}. Guess again"
13 | end
14 | current_guess = gets.chomp.to_i
15 | num_guesses = num_guesses + 1
16 | end
17 | puts "You guessed #{correct} in #{num_guesses} tries!"
18 | end
19 |
20 | guessing_game
21 |
--------------------------------------------------------------------------------
/04-ruby-rails/ruby-methods/22/solutions/httparty.rb:
--------------------------------------------------------------------------------
1 | ## Using a Gem ##
2 | require "httparty"
3 |
4 | def spotify_album_search (word="White") # optionally take a parameter
5 | # uri = "https://api.spotify.com/v1/search?q=White&type=album" # <- "White"-only version
6 | uri = "https://api.spotify.com/v1/search?q=#{word}&type=album" # <- using parameter
7 | # do an album search on the word
8 | response = HTTParty.get(uri)
9 | # parse response body into JSON
10 | body = JSON.parse(response.body)
11 | # print each of the album names
12 | body["albums"]["items"].each do |a|
13 | puts a["name"]
14 | end
15 | # return parsed response body
16 | body
17 | end
18 |
19 | spotify_album_search
20 |
--------------------------------------------------------------------------------
/04-ruby-rails/ruby-methods/22/solutions/primes.rb:
--------------------------------------------------------------------------------
1 | ## Primes ##
2 | def is_prime?(num)
3 | if num > 1
4 | (2..(num-1)).each do |i|
5 | if num % i == 0
6 | return false
7 | end
8 | end
9 | true
10 | else
11 | false
12 | end
13 | end
14 |
15 |
16 | # Make your is_prime? method more efficient.
17 |
18 | def is_prime?(num)
19 | if num > 2
20 | if num % 2 == 0
21 | return false
22 | end
23 | i = 3 # start at 3
24 | maxn = num**(0.5) # go up to the square root of num
25 | while i <= maxn
26 | if num % i === 0
27 | return false
28 | end
29 | i = i+2 # count up by 2 to check only odd numbers
30 | end
31 | true
32 | elsif num == 2 # special case for 2
33 | true
34 | else
35 | false
36 | end
37 | end
38 |
39 | puts is_prime? 17
40 |
41 |
42 |
--------------------------------------------------------------------------------
/04-ruby-rails/ruby-oop/27/monster.rb:
--------------------------------------------------------------------------------
1 | # Monster class
2 | # getters and setters for instance variables
3 |
4 | # class variable for count
5 |
6 | # class instance variable for class description
7 |
8 | # class method getter for @@count class variable
9 |
10 | # class method getter for @class_description class instance variable
11 |
12 | # initial behavior
13 |
14 | # habitat? instance method
15 |
16 | # get_dangerous instance method
17 |
18 | # fight class method
19 |
20 | # Zombie class
21 |
22 | # zombie version of class_description
23 |
24 | # initial behavior and values
25 |
26 | # Werewolf class
27 |
28 | # werewolf version of class_description
29 |
30 | # initial behavior and values
31 |
32 | # update_threat_level instance method
33 |
34 | # Flying module
35 |
36 | #fly method
37 |
38 | # Vampire class
39 |
40 | # vampire class description
41 |
42 | # Flying module included
43 |
--------------------------------------------------------------------------------
/04-ruby-rails/ruby-oop/exercises.md:
--------------------------------------------------------------------------------
1 | ## Exercises: The Animal Kingdom
2 |
3 | ##### Create the following:
4 |
5 | 1. An `Animal` class, with the following:
6 | * Properties:
7 | * `kind`: A string that holds the type of animal
8 | * Instance Methods:
9 | * `eat`: Takes a parameter `food` to eat and prints out a message that the animal is eating `food`
10 | * `sleep` & `wake`: These two methods should NOT be passed any arguments. Instead, they will set an instance variable `@state` to the string `"asleep"` or `"awake"` respectively.
11 |
12 | 2. A `Person` class, with the following characteristics:
13 | * Inherits from `Animal`
14 | * Automatically sets `@type` to `"person"`
15 | * Adds 3 new instance vars:
16 | * age
17 | * gender
18 | * name
19 | * Also, people aren't cannibals! Make sure your `Person` class *overrides* the existing `eat` method (in `Animal`) so that a `Person` cannot eat a `"person"`
20 |
21 | #### Stretch Challenges
22 |
23 | * People can speak, and it's good to be polite. Add an instance method called `greet` that prints out a person's name, age, and gender in the following format: "Hi, I'm Teddy. I'm a person, and I'm 156 years old." (Hint: look up how to interpolate strings in Ruby)
24 | * Add a `class variable` that keeps track of all the people you create.
25 |
--------------------------------------------------------------------------------
/04-ruby-rails/ruby-oop/solutions.rb:
--------------------------------------------------------------------------------
1 | class Animal
2 | attr_accessor :state
3 | def initialize(kind)
4 | @type = kind
5 | @state = "awake"
6 | end
7 |
8 | def eat (food)
9 | puts "Yum! I am eating #{food}!"
10 | end
11 |
12 | def sleep
13 | @state = "asleep"
14 | end
15 |
16 | def wake
17 | @state = "awake"
18 | end
19 | end
20 |
21 | bird = Animal.new("Parrot")
22 | bird.eat("Crackers")
23 | bird.sleep
24 |
25 | puts bird.state
26 |
27 | class Person < Animal
28 | @@count = 0
29 | attr_accessor :age, :gender, :name
30 | def initialize(age, gender, name)
31 | @type = "person"
32 | @age = age
33 | @gender = gender
34 | @name = name
35 | @@count = @@count + 1
36 | end
37 |
38 | def self.count
39 | @@count
40 | end
41 |
42 | def eat(food)
43 | response = if food == "person"
44 | "Sir! I am NOT a cannibal!"
45 | else
46 | "Yum! I am eating #{food}!"
47 | end
48 | puts response
49 | end
50 |
51 | def greet
52 | puts "Hi, I'm #{@name}. I'm a #{@type}, and I'm #{@age} years old."
53 | end
54 | end
55 |
56 | justin = Person.new(33, "male", "Justin")
57 | jimmy = Person.new(27, "male", "Jimmy")
58 | justin.eat('dogs')
59 | justin.greet
60 | jimmy.eat('person')
61 | puts Person.count
62 |
--------------------------------------------------------------------------------
/assessments/24/week-06/readme.md:
--------------------------------------------------------------------------------
1 | # WDI 24 - Week 6 Assessment
2 |
3 | 1. Declare a variable called `favorite_food`, and set it equal to your favorite food. Concatenate your `favorite_food` variable with the string, "My favorite food is ".
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | 2. Write a regular expression that matches any number (**digit**) in the string, "Here are 10 ways Lyon is better than Paris."
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 | 3. Write a method called `fly` that takes a `speed` parameter and returns the speed multiplied by 2.
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 | 4. Create a class that represents a `Gemstone` with the instance variables `category` and `color`. Initialize these variables in the `Gemstone` class using parameters.
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 | 5. Create an instance of your `Gemstone` class created above with the `category` "Mineral Variety" and the `color` "red".
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 | 6. Define and briefly describe each letter in **MVC**.
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 | 7. Briefly describe the purpose of each of the following commands/files/directories in a Rails app:
72 |
73 | **Gemfile**
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 | **bundle install (or bundle)**
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 | **rails server (or rails s)**
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 | **config/routes.rb**
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 | **app/controllers/**
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 | 8. What is **ActiveRecord**, and how will we use it with Ruby on Rails?
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
--------------------------------------------------------------------------------
/assessments/24/week-06/solutions.md:
--------------------------------------------------------------------------------
1 | # WDI 24 - Week 6 Assessment [SOLUTIONS]
2 |
3 | 1. Declare a variable called `favorite_food`, and set it equal to your favorite food. Concatenate your `favorite_food` variable with the string, "My favorite food is ".
4 |
5 | ```ruby
6 | favorite_food = "ice cream"
7 | "My favorite food is #{favorite_food}."
8 | ```
9 |
10 | 2. Write a regular expression that matches any number (**digit**) in the string "Here are 10 ways Lyon is better than Paris."
11 |
12 | ```ruby
13 | /\d/
14 | ```
15 |
16 | 3. Write a method called `fly` that takes a `speed` parameter and returns the speed multiplied by 2.
17 |
18 | ```ruby
19 | def fly(speed)
20 | speed * 2
21 | end
22 | ```
23 |
24 | 4. Create a class that represents a `Gemstone` with the instance variables `category` and `color`. Initialize these variables in the `Gemstone` class using parameters.
25 |
26 | ```ruby
27 | class Gemstone
28 | def initialize(category, color)
29 | @category = category
30 | @color = color
31 | end
32 | end
33 | ```
34 |
35 | 5. Create an instance of your `Gemstone` class created above with the `category` "Mineral Variety" and the `color` "red".
36 |
37 | ```ruby
38 | Gemstone.new("Mineral Variety", "red")
39 | ```
40 |
41 | 6. Define and briefly describe each letter in **MVC**.
42 |
43 | **M** - Model: represents data objects in your application
44 |
45 | **V** - View: presentation layer; pages user sees and interacts with on your site
46 |
47 | **C** - Controller: handles user requests and controls what happens in response; interaction between Model and View
48 |
49 | 7. Briefly describe the purpose of each of the following commands/files/directories in a Rails app:
50 |
51 | **Gemfile** - file that lists gems (similar to modules or libraries) included in your Rails app
52 |
53 | **bundle install (or bundle)** - command that installs all gems listed in your `Gemfile` into your Rails app
54 |
55 | **rails server (or rails s)** - command that starts Rails's built-in server on localhost:3000 (similar to running `nodemon`)
56 |
57 | **config/routes.rb** - file where you define all the routes for your Rails app
58 |
59 | **app/controllers/** - directory that holds all controllers for your Rails app
60 |
61 | 8. What is **ActiveRecord**, and how will we use it with Ruby on Rails?
62 |
63 | ActiveRecord is the ORM (Object Relational Mapping) that comes built into Rails. We'll use it to query our database in our Rails apps.
64 |
--------------------------------------------------------------------------------
/assessments/27-28/day-01/day-1-assessment-wdi-27-28.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/assessments/27-28/day-01/day-1-assessment-wdi-27-28.pdf
--------------------------------------------------------------------------------
/assessments/27-28/week-01/week-1-assessment-wdi-27-28.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/assessments/27-28/week-01/week-1-assessment-wdi-27-28.pdf
--------------------------------------------------------------------------------
/assessments/27-28/week-02/week-2-assessment-wdi-27-28.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/assessments/27-28/week-02/week-2-assessment-wdi-27-28.pdf
--------------------------------------------------------------------------------
/assessments/27-28/week-03/week-3-assessment-wdi-27-28.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/assessments/27-28/week-03/week-3-assessment-wdi-27-28.pdf
--------------------------------------------------------------------------------
/assessments/27/week-07/week-7-assessment-wdi-27.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/assessments/27/week-07/week-7-assessment-wdi-27.pdf
--------------------------------------------------------------------------------
/homework/27-28/week-00-template.md:
--------------------------------------------------------------------------------
1 | # Week 00 Homework
2 |
3 | The homeworks and readings below are intended to prepare you for the next day's lectures. Please complete them first.
4 |
5 | If you have any remaining time, please complete/review the exercises from dawn and dusk lectures. You can also review the morning drills.
6 |
7 | Please refer to the [Instructions for Submitting Homework](/how-to/homework-submission.md).
8 |
9 | ## Day 1
10 |
11 | 1. Reading
12 | * [Example](#example)
13 | 2. Bonus/Stretch
14 | * [Example](#example)
15 |
16 | Please use any remaining time to complete and review the exercises from dawn & dusk:
17 |
18 | * [Example](#example)
19 | * [Example](#example)
20 |
21 | ## Day 2
22 |
23 | 1. Reading
24 | * [Example](#example)
25 | 2. Bonus/Stretch
26 | * [Example](#example)
27 |
28 | Please use any remaining time to complete and review the exercises from dawn & dusk:
29 |
30 | * [Example](#example)
31 | * [Example](#example)
32 |
33 | ## Day 3
34 |
35 | 1. Reading
36 | * [Example](#example)
37 | 2. Bonus/Stretch
38 | * [Example](#example)
39 |
40 | Please use any remaining time to complete and review the exercises from dawn & dusk:
41 |
42 | * [Example](#example)
43 | * [Example](#example)
44 |
45 | ## Day 4
46 |
47 | 1. Reading
48 | 2. Friday Review Prep
49 | - Complete the [Week 1 Self-Assessment](#PENDING) and identify 2 topics you want to review tomorrow
50 | - Ask and/or upvote 3 questions on QuestionCookie: http://www.questioncookie.com/wdi-00-w0-review
51 |
52 | Please use any remaining time to complete and review the exercises from dawn & dusk.
53 |
54 | ## Day 5 - Weekend Homework
55 |
56 | 1. Reading
57 | 2. Weekend Lab
58 |
59 | Please use any remaining time to review exercises/drills from the week! And don't forget to sleep!
60 |
--------------------------------------------------------------------------------
/homework/27-28/week-04/README.md:
--------------------------------------------------------------------------------
1 | # Week 4 Homework
2 |
3 | The homeworks and readings below are intended to prepare you for the next day's lectures. Please complete them first.
4 |
5 | If you have any remaining time, please complete/review the exercises from dawn and dusk lectures. You can also review the morning drills.
6 |
7 | Please refer to the [Instructions for Submitting Homework](/how-to/homework-submission.md).
8 |
9 |
22 |
23 |
31 |
32 |
40 |
41 |
51 |
52 |
60 |
--------------------------------------------------------------------------------
/homework/27-28/week-05/README.md:
--------------------------------------------------------------------------------
1 | # Week 5 Homework
2 |
3 | The homeworks and readings below are intended to prepare you for the next day's lectures. Please complete them first.
4 |
5 | If you have any remaining time, please complete/review the exercises from dawn and dusk lectures. You can also review the morning drills.
6 |
7 | Please refer to the [Instructions for Submitting Homework](/how-to/homework-submission.md).
8 |
9 |
22 |
23 |
31 |
32 | ## Day 3
33 |
34 | 1. Reading - Go over the `$http` documentation for Angular. You don't need to comprehend 100% of what it goes over, but please take the time to study the method structure, parameters,
35 | 2. Please use any remaining time to complete and review the complete walkthroughs in Sprint 1 and Sprint 2 from Tunely-Angular. For an added challenge, implement the following routes and `$http` methods :
36 |
37 | > Get 1 (show) `"/api/albums/:id"`
38 |
39 | > Search (search) `"/search?query=parameters"`
40 |
41 | > Create any necessary html needed to support the above methods
42 |
43 |
44 | ## Day 4
45 |
46 | 1. Re-read the [lecture notes for ngRoute](https://github.com/SF-WDI-LABS/shared_modules/tree/master/03-angular-mean/ngRoute/27) especially ngRoute setup instructions.
47 | * make a note to yourself about what each of the following is for: [ng-href, ng-view, $routeParams]
48 | 2. Tunely Sprint 4!
49 | - Make sure you follow the instructions about [branching](https://github.com/SF-WDI-LABS/tunely-angular/blob/master/docs/starting_with_a_branch.md) and checkout the sprint3 solutions.
50 | 3. If you really want some more to do and you've caught up on your sleep:
51 | - Try to connect angular to your personal API.
52 | - Knock out any remaining issues in your project 1.
53 |
54 | Please use any remaining time to complete and review the exercises from dawn & dusk.
55 |
56 |
57 |
65 |
--------------------------------------------------------------------------------
/homework/27-28/week-08/README.md:
--------------------------------------------------------------------------------
1 | # Week 8 Homework
2 |
3 | The homeworks and readings below are intended to prepare you for the next day's lectures. Please complete them first.
4 |
5 | If you have any remaining time, please complete/review the exercises from dawn and dusk lectures. You can also review the morning drills.
6 |
7 | Please refer to the [Instructions for Submitting Homework](/how-to/homework-submission.md).
8 |
9 | ## Day 1
10 |
11 | 1. In preparation for tomorrow, please familiarze yourself with the following:
12 | * First, make sure you're comfortable with how to represent [1:1, 1:N, & N:N Relationships](http://www.databaseprimer.com/pages/table-relationships/) in databse tables.
13 | * What would your table relationships look like for: `drivers, vehicles, drivers licenses`, and `zoos, animals caretakers` (we will go over this in class!)
14 | * Then, read all about Active Record:
15 | * Setting up databse tables with [Migrations](http://edgeguides.rubyonrails.org/active_record_migrations.html) - All of it!
16 | * Setting up model relationships with [Associations](http://guides.rubyonrails.org/association_basics.html) - Only sections [1](http://guides.rubyonrails.org/active_record_migrations.html#migration-overview) and [2.0-2.4](http://guides.rubyonrails.org/association_basics.html#the-types-of-associations)!
17 | 2. If you have any remaining time, try adding Auth to an existing Rails App (like the Bog App, or Rock-n-Rails).
18 |
19 | ## Day 2
20 |
21 | 1. Please review the lecture notes from the morning modules [1:N, N:N Relationships](https://gist.github.com/nathanallen/5bdae5d047aca4fc26f2191d27dd665d) and [Migrations & Associations](https://github.com/SF-WDI-LABS/shared_modules/tree/master/04-ruby-rails/migrations-and-associations/27)
22 | - If you have time, try some of the exercises, and take a look at the solutions.
23 | 1. Next, in preparation for tomorrow, please read the rails guide on [ActiveRecord Validations](http://guides.rubyonrails.org/active_record_validations.html). Pay special attention to sections 1-3 (you can skim the rest).
24 |
25 |
33 |
34 |
44 |
45 |
53 |
--------------------------------------------------------------------------------
/homework/27-28/week-09/README.md:
--------------------------------------------------------------------------------
1 | # Week 9 Homework
2 |
3 | The homeworks and readings below are intended to prepare you for the next day's lectures. Please complete them first.
4 |
5 | If you have any remaining time, please complete/review the exercises from dawn and dusk lectures. You can also review the morning drills.
6 |
7 | Please refer to the [Instructions for Submitting Homework](/how-to/homework-submission.md).
8 |
9 | ## Day 1
10 |
11 | 1. Reading: In preparation for tomororw, please read the Rails Guide on [The Asset Pipeline](http://guides.rubyonrails.org/asset_pipeline.html) -- Sections [1](http://guides.rubyonrails.org/asset_pipeline.html#what-is-the-asset-pipeline-questionmark) & [2](http://guides.rubyonrails.org/asset_pipeline.html#in-production).
12 | 2. Issue Creation: We recommend you document 3+ outstanding bugs/enhancements/features in your Vagabond App, using [Github Issues](https://guides.github.com/features/issues/). It's good practice, and it will make it easier to pick up where you left off. Make sure to include:
13 | - How to reproduce the bug ("As a user, I visit page, scroll down...")
14 | - Specific error message(s)
15 | - Specific line numbers
16 | - Priority Level -- 0,1,2,3,4...? (see [examples](https://bugs.opera.com/help/issueTypes.html))
17 | - Screenshots, Labels, Assignee, etc (optional)
18 |
19 | Please use any remaining time to brush up on any area of rails you feel fuzzy on: views, view_helpers, routing, controllers, helper methods, sessions, auth, active record, validations, etc.
20 |
21 | ## Day 2
22 |
23 | 1. Please review the requirements for [Project 2](https://github.com/sf-wdi-27-28/project-2-28), and prepare to pitch tomorrow afternoon! The crazier the idea, the better! Just make sure it's "in scope".
24 | 2. Explore your Lightning Talk topic and finalize your gist / presentation.
25 |
26 | Please use any remaining time to review (the solutions for) the [asset pipeline](https://github.com/SF-WDI-LABS/shared_modules/tree/master/04-ruby-rails/asset-pipeline/27) and [turbolinks](https://github.com/sf-wdi-27-28/turbolinks_challenge) labs.
27 |
28 |
36 |
37 |
47 |
48 |
56 |
--------------------------------------------------------------------------------
/homework/27-28/week-10/README.md:
--------------------------------------------------------------------------------
1 | # Week 10 Homework
2 |
3 | The homeworks and readings below are intended to prepare you for the next day's lectures. Please complete them first.
4 |
5 | If you have any remaining time, please complete/review the exercises from dawn and dusk lectures. You can also review the morning drills.
6 |
7 | Please refer to the [Instructions for Submitting Homework](/how-to/homework-submission.md).
8 |
9 |
22 |
23 |
31 |
32 |
40 |
41 |
51 |
52 |
60 |
--------------------------------------------------------------------------------
/homework/27-28/week-11/README.md:
--------------------------------------------------------------------------------
1 | # Week 11 Homework
2 |
3 | The homeworks and readings below are intended to prepare you for the next day's lectures. Please complete them first.
4 |
5 | If you have any remaining time, please complete/review the exercises from dawn and dusk lectures. You can also review the morning drills.
6 |
7 | Please refer to the [Instructions for Submitting Homework](/how-to/homework-submission.md).
8 |
9 |
22 |
23 |
31 |
32 |
40 |
41 |
51 |
52 |
60 |
--------------------------------------------------------------------------------
/homework/27-28/week-12/README.md:
--------------------------------------------------------------------------------
1 | # Week 12 Homework
2 |
3 | The homeworks and readings below are intended to prepare you for the next day's lectures. Please complete them first.
4 |
5 | If you have any remaining time, please complete/review the exercises from dawn and dusk lectures. You can also review the morning drills.
6 |
7 | Please refer to the [Instructions for Submitting Homework](/how-to/homework-submission.md).
8 |
9 |
22 |
23 |
31 |
32 |
40 |
41 |
48 |
49 |
57 |
--------------------------------------------------------------------------------
/homework/27/week-07/docs/Rails-For-Zombies-Slides.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/homework/27/week-07/docs/Rails-For-Zombies-Slides.pdf
--------------------------------------------------------------------------------
/homework/27/week-09/README.md:
--------------------------------------------------------------------------------
1 | ## Day 1
2 |
3 | 1. Put the final touches on Vagabond, and get some rest!
4 |
5 |
6 | ## Day 2
7 |
8 | 1. **Fill out** a [WDI Group Project Peer Feedback form](https://docs.google.com/forms/d/1PJro3MtOXJMbSIBCXv5oGcZAGHQ2FBGcojPT04taOBo/viewform?usp=send_form) for your Vagabond team.
9 | 2. **Read over** the [Project 2 requirements](https://github.com/sf-wdi-27-28/project-2-27) and **generate** an idea you'd like to pitch to the class.
10 | 3. **Prepare a very short (2-5 minute) lightning talk** on a Ruby or Ruby on Rails gem of your choice. See the [assignment readme](https://github.com/SF-WDI-LABS/shared_modules/blob/master/04-ruby-rails/rails-gems/lightning-talks.md). You will present tomorrow morning.
11 | 4. **Read and review** the [JS in rails class notes](https://github.com/SF-WDI-LABS/shared_modules/tree/master/04-ruby-rails/js-and-turbolinks/27).
12 | 5. **OPTIONAL:**(if you have time) From the [testing inventory lab](https://github.com/sf-wdi-27-28/rspec_testing_inventory), **complete up to** ["pass the controller tests" goal](https://github.com/sf-wdi-27-28/rspec_testing_inventory#goal-pass-the-controller-tests).
13 |
14 | Please use any remaining time to review exercises from the day.
15 |
16 |
17 |
18 |
19 |
27 |
28 |
29 |
38 |
46 |
--------------------------------------------------------------------------------
/homework/27/week-10/README.md:
--------------------------------------------------------------------------------
1 | # Day 4
2 |
3 | 1. Scan through the [Rails Style Guide](https://github.com/bbatsov/ruby-style-guide) to see some of the standards the pros follow (and insist on). You don't have to read everything but take some time to get the basics.
4 | 2. Fill out the [project 2 peer feedback form](http://goo.gl/forms/ZN1fJi5rs0ugi5ki1).
5 | 2. Get some rest; don't work too late on the styleguide.
6 |
7 | > Styleguides are used in the industry to specify certain ways of using a particular language that are deemed ideal. Following styleguides makes your code more readable to other developers. Many of the rules in styleguides have very specific intentions that will also help you avoid bugs.
8 |
9 | > Don't worry about understanding the reasoning behind every styleguide rule now. These will come to you in time as your skills and experience increase.
10 |
11 |
12 | # Day 5
13 |
14 | 1. Create or update your [portfolio](./portfolio.md), and make sure it's deployed publicly online!
15 | 2. Prepare a [lightning talk](./lightning-talk.md) on a technology we haven't covered. (Think about a tool you might want to use in project 3!)
16 |
--------------------------------------------------------------------------------
/homework/27/week-10/lightning-talk.md:
--------------------------------------------------------------------------------
1 | #Lightning Talks
2 |
3 | Create a 5 minute presentation on a topic that is useful to your fellow developers. Talking about technology is one of the most difficult skills for new developers to get comfortable with, and it's one employers value highly.
4 |
5 | In your presentation, answer the following questions:
6 |
7 | - What problem does this technology solve?
8 | - How do you use it? (Is there a "cheatsheet" you found or made that others can reference?)
9 | - What did you build?
10 |
11 | Your presentation should also include a small demo of working code.
12 |
13 | Lightning talks will be on Wednesday morning next week.
14 |
15 | ##Topics:
16 | Here are some suggestions; you are welcome to add your own:
17 |
18 | **DATA STORAGE**
19 |
20 | - [ ] Redis
21 | - [ ] Firebase
22 | - [ ] Amazon S3
23 |
24 | **WORKFLOW TOOLS**
25 |
26 | - [ ] Grunt / Gulp
27 | - [ ] Emmet
28 | - [ ] Travis CI
29 | - [ ] Capistrano
30 |
31 | **Templating**
32 |
33 | - [ ] HAML
34 | - [ ] Jade
35 | - [ ] Handlebars / Mustache
36 | - [ ] EJS
37 |
38 | **Ruby and/or Rails**
39 |
40 | - [ ] Sinatra framework
41 | - [ ] Chef
42 | - [ ] OmniAuth
43 | - [ ] Capybara
44 | - [ ] Brakeman
45 | - [ ] Cucumber
46 | - [ ] I18n
47 | - [ ] Kimono / Nokogiri
48 | - [ ] Active Jobs
49 |
50 | **JavaScript and/or Node**
51 |
52 | - [ ] ES6
53 | - [ ] Underscore / Lodash
54 | - [ ] Cheerio
55 | - [ ] Browserify
56 | - [ ] Mocha / Chai
57 | - [ ] Grunt / Gulp
58 | - [ ] Kimono
59 |
60 | **Front-End Tools and APIs**
61 |
62 | - [ ] Static Site Generator (Jekyll, Hexo, Hugo, or another)
63 | - [ ] Modernizr
64 | - [ ] LiveReload
65 | - [ ] SVG
66 | - [ ] Phaser game framework
67 | - [ ] Three.js
68 | - [ ] D3.js
69 | - [ ] Chart.js
70 | - [ ] Polymer / Web components
71 | - [ ] Canvas API
72 | - [ ] HTML5 location API
73 | - [ ] Web Real-Time Communication (WebRTC) Video
74 | - [ ] WebRTC Audio
75 |
76 | **Front End Frameworks**
77 |
78 | - [ ] React
79 | - [ ] Ionic
80 | - [ ] Meteor
81 | - [ ] Ember
82 | - [ ] Backbone
83 |
84 | **Languages**
85 |
86 | - [ ] SASS or LESS
87 | - [ ] Python
88 | - [ ] Clojure
89 | - [ ] CoffeeScript
90 | - [ ] Go
91 | - [ ] Java
92 |
93 | **Security and Authorization**
94 |
95 | - [ ] XSS
96 | - [ ] OAuth
97 | - [ ] Recaptcha
98 | - [ ] CORS
99 | - [ ] JWT
100 |
101 | **Web Communication Protocols**
102 |
103 | - [ ] Websockets / Socket.io
104 | - [ ] TCP/IP
105 |
--------------------------------------------------------------------------------
/homework/27/week-10/portfolio.md:
--------------------------------------------------------------------------------
1 | # Portfolio
2 |
3 | You're going to need a portfolio site to showcase the amazing projects you've built in WDI. Over this weekend, build your portfolio site or update your current portfolio site. The technologies you use are up to you.
4 |
5 | Make sure your site is hosted and live on the web. If you need a back-end, you can host on Heroku. If you have a static site, though, you can host with a service like github pages.
6 |
7 | ## Requirements
8 |
9 | 1. Create GitHub repo for your portfolio, and create a portfolio website.
10 |
11 | 2. Include a list of your projects. Each project description can include things like:
12 | - screenshot or project logo
13 | - elevator pitch / short description
14 | - deployed site link
15 | - github repo link
16 | - your role on the project if you worked in a team
17 |
18 | 3. Choose one of the wireframes below to implement, or create your own wireframe. (Click the inspiration link above each wireframe to see a live site following that pattern.)
19 |
20 | 4. Make sure your site is responsive. It should look great on mobile devices and in different browsers.
21 |
22 | 5. It makes sense to use a framework and/or template to get started, but make sure you use custom styles to differentiate your site from others using the same source.
23 |
24 | ## Wireframes
25 |
26 | #### Alternating Photo/Description
27 | [[inspiration]](http://www.randallleung.com)
28 |
29 |
30 |
31 | #### Project Cards
32 | [[inspiration]](http://www.nicolastarier.com)
33 |
34 |
35 |
36 | #### Case Study
37 | The "case study" layout is meant to represent a detailed page for one project. [[inspiration]](http://haraldurthorleifsson.com/googleplus)
38 |
39 |
40 |
41 | ## Resources
42 |
43 | #### Design Inspiration
44 | * [Dribble](https://dribbble.com)
45 | * [AWWWARDS](http://www.awwwards.com/websites/portfolio)
46 | * [UI Parade](http://www.uiparade.com)
47 |
48 | #### Fonts, Icons, Colors
49 | * [Google Fonts](https://www.google.com/fonts)
50 | * [Font Awesome (Icons)](http://fortawesome.github.io/Font-Awesome/icons)
51 | * [The Noun Project](https://thenounproject.com)
52 | * [Adobe Kuler](https://color.adobe.com/explore/newest)
53 | * [Flat UI Color Picker](http://www.flatuicolorpicker.com)
54 | * [Sip (Color Picker)](https://itunes.apple.com/us/app/sip/id507257563)
55 |
--------------------------------------------------------------------------------
/homework/27/week-10/wireframes/case_study.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/homework/27/week-10/wireframes/case_study.png
--------------------------------------------------------------------------------
/homework/27/week-10/wireframes/photo_description.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/homework/27/week-10/wireframes/photo_description.png
--------------------------------------------------------------------------------
/homework/27/week-10/wireframes/project_cards.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/homework/27/week-10/wireframes/project_cards.png
--------------------------------------------------------------------------------
/homework/27/week-11/README.md:
--------------------------------------------------------------------------------
1 | # Day 1
2 |
3 | 1. Work with your team to finish the Technical Requirements of today's [MEAN lab](https://github.com/SF-WDI-LABS/mean-lab) - bonuses are not required. Remember to follow the lab's **[submission instructions](https://github.com/SF-WDI-LABS/mean-lab#lab-submission)**!
4 | 2. **Submit your portfolio links** (from the weekend lab) in [this google form](http://goo.gl/forms/ccDibeBZFeQ9dwr53). We look forward to seeing what you've built!
5 |
6 | Please feel free to use extra time to review, continue preparing your lightning talks for Wednesday, or flesh out project 3 ideas.
7 |
8 |
9 | # Day 2
10 |
11 | 1. If your group did not submit yesterday's [MEAN lab](https://github.com/SF-WDI-LABS/mean-lab), then you are LATE. Please submit it now using the **[submission instructions](https://github.com/SF-WDI-LABS/mean-lab#lab-submission)**!
12 | 2. Complete the [Rangular lab](). No pull request is required. Feel free to use the included code.
13 | 3. Make final preparations for your **lightning talks** tomorrow.
14 |
15 | Please feel free to use extra time to review, continue preparing your lightning talks for Wednesday, or flesh out project 3 ideas.
16 |
--------------------------------------------------------------------------------
/how-to/assets/AWS_bill_cropped.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/how-to/assets/AWS_bill_cropped.jpg
--------------------------------------------------------------------------------
/how-to/assets/AtomShortcuts.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/how-to/assets/AtomShortcuts.png
--------------------------------------------------------------------------------
/how-to/assets/keep_it_secret.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SF-WDI-LABS/shared_modules/13522fd4c4a9ceb0be487c0b6197cc7e77035566/how-to/assets/keep_it_secret.jpg
--------------------------------------------------------------------------------
/how-to/hide-secrets-in-node.md:
--------------------------------------------------------------------------------
1 | # Hiding Environment Variables in Node.js
2 |
3 | ## Install & Require dotenv Module
4 |
5 | 1. In the Terminal, in the root directory of your Node.js app, install the `dotenv` module.
6 |
7 | ```zsh
8 | npm install --save dotenv
9 | ```
10 |
11 | 2. At the top of your `server.js` file, require and load `dotenv`.
12 |
13 | ```js
14 | /*
15 | * server.js
16 | */
17 |
18 | var express = require('express'),
19 | app = express(),
20 |
21 | // require other modules
22 | ...
23 |
24 | // require and load dotenv
25 | require('dotenv').load();
26 | ```
27 |
28 | ## Create .env File
29 |
30 | 1. In the root directory of your project, create a file called `.env`. This is a hidden file where you'll store API keys and other environment-specific variables.
31 |
32 | ```zsh
33 | touch .env
34 | ```
35 |
36 | 2. **Before you do anything else,** add `.env` to your `.gitignore`! This is what "hides" your API keys and prevents them from being exposed on GitHub.
37 |
38 | ```js
39 | /*
40 | * .gitignore
41 | */
42 |
43 | node_modules
44 | .env
45 | ```
46 |
47 | 3. **After you add `.env` to your `.gitignore`,** add your API keys to `.env`. *Change MY_API_KEY to your variable name and your actual key.*
48 |
49 | ```js
50 | /*
51 | * .env
52 | */
53 |
54 | MY_API_KEY=0932nv8d17vhd72o2e8cfv82csd9n1dcd98
55 | ```
56 |
57 | ## Accessing Environment Variables
58 |
59 | In `server.js`, or any other back-end JS file (models, etc.), you can access your API keys and other environment-specific variables through `process.env`.
60 |
61 | ```js
62 | /*
63 | * server.js (or any other back-end JS file)
64 | */
65 |
66 | // I need to use my API key! How do I access it?
67 | process.env.MY_API_KEY // returns value of MY_API_KEY
68 | ```
69 |
70 |
71 | ## Set Environment Variables on Heroku
72 |
73 | You've gitignored your .env file, so it won't get pushed to GitHub _or_ Heroku. But your app will need those envirnoment variables to work on Heroku, anyway.
74 |
75 | From inside your project directory, use Heroku's config command to set each of your environment variables.
76 |
77 | ```zsh
78 | heroku config:set MY_API_KEY=0932nv8d17vhd72o2e8cfv82csd9n1dcd98
79 | ```
80 |
81 | You can check that you've successfully set the variables:
82 |
83 | ```zsh
84 | heroku config
85 | ```
86 |
87 |
88 |
89 | ## Resources
90 |
91 | [dotenv docs](https://github.com/motdotla/dotenv)
92 | Heroku's [configuration variables set up docs](https://devcenter.heroku.com/articles/config-vars)
93 |
--------------------------------------------------------------------------------
/how-to/keyboard-shortcuts.md:
--------------------------------------------------------------------------------
1 | # keyboard-shortcuts
2 |
3 |
4 | ### Basic Mac Shortcuts
5 | #### These key combos work in most Mac applications
6 |
7 | - **Command Space** → this will bring up your Spotlight.
8 | Use this to launch your Terminal, PostgreSQL, or any other application installed on your Mac
9 |
10 | - Hold down **Alt** and tap **Tab** to switch between open applications
11 |
12 | - **Command S** >> Save current document
13 | - **Command Option S** >> Save all open documents
14 | - **Command A** >> Select all in current document
15 | - **Command C** >> Copy
16 | - **Command X** >> Cut
17 | - **Command V** >> Paste
18 | - **Shift** and tap **←** or **→** >> Highlights by letter
19 | - **Shift Option** and tap **←** or **→** >> Highlights by word
20 | - **Shift Command** and tap **←** or **→** >> Highlights to the start or end of the line. Tap the arrow key once more if you were just looking to move the curser
21 |
22 | Full list of Mac keyboard shortcuts
23 |
24 | ### Basic Atom Shortcuts (many of these work in other text editors as well)
25 |
26 |
27 | - **Command /** >> Turn the selected text into a comment, or uncomment the text if already a comment
28 | - **Command** and tap **←** or **→** >> Move to the end or begining of a line
29 | - **Command Delete** >> Delete to beginning of line
30 | - **Command D** >> Select next instance of highlighted text
31 | - **Command Control G** >> select all instances of highlighted text
32 | - **Command Control** and tap **↑** or **↓** >> move line up//down
33 |
34 | -- Hold down **Command** and click multiple locations to use multiple simultaneous cursors
35 |
36 |
37 | ****
38 |
39 | ### ShiftIt Basics
40 |
41 | - **Control Option Command** + **←** or **→** >> Snaps the active widow to the right or left of your screen. Tap **←** or **→** again to reduce the % of the screen occupied by the window
42 | - **Control Option Command** + **↑** or **↓** >> Same as above, but snaps to the top or bottom
43 | - **Control Option Command M** >> Brings the active window to fullscreen (windowed)
44 |
45 |
46 | #### Misc.
47 |
48 | - Try typing the first few letters of a file or directory in your terminal and then press **Tab**. Terminal will autocomplete the file/dir name
49 | - Double-Clicking a word will highlight it
50 |
--------------------------------------------------------------------------------
/how-to/lightning-talks.md:
--------------------------------------------------------------------------------
1 | #Lightning Talks
2 |
3 | Your goal is to create a 5-6 minute presentation on a topic that is useful to your fellow developer. We encourage you to dive right in with a small demo that you created!
4 |
5 | - What problem does this technology solve?
6 | - How do you use it? Is there a "cheatsheet" you found or made that others can reference?
7 | - What did you build?
8 |
9 | Lightning talks will be on Tuesday afternoon, May 24th.
10 |
11 | ##Signup for your topic [here](https://docs.google.com/spreadsheets/d/19lhOKlMHJW-bn604_x1eNtQwolCN44aCjBrXmbzv208/edit?usp=sharing)
12 | ##Topics:
13 | Here are some suggestions; you are welcome to add your own:
14 |
15 | **DATA STORAGE**
16 |
17 | - [ ] Redis
18 | - [ ] Firebase
19 | - [ ] Amazon S3
20 |
21 | **WORKFLOW TOOLS**
22 |
23 | - [ ] Grunt / Gulp
24 | - [ ] Emmet
25 | - [ ] Travis CI
26 | - [ ] Capistrano
27 |
28 | **Templating**
29 |
30 | - [ ] HAML
31 | - [ ] Jade
32 | - [ ] Handlebars / Mustache
33 |
34 | **Other Web Frameworks**
35 |
36 | - [ ] Sails.js
37 | - [ ] Flask
38 | - [ ] Django
39 |
40 | **Ruby and/or Rails**
41 |
42 | - [ ] Sinatra framework
43 | - [ ] Chef
44 | - [ ] Will_Paginate / kaminari
45 | - [ ] OmniAuth
46 | - [ ] Capybara
47 | - [ ] Brakeman
48 | - [ ] Cucumber
49 | - [ ] I18n
50 | - [ ] Nokogiri / Kimono
51 | - [ ] Active Jobs
52 |
53 | **JavaScript and/or Node**
54 |
55 | - [ ] ES6
56 | - [ ] Lodash or Underscore
57 | - [ ] Cheerio
58 | - [ ] Browserify
59 |
60 | **UI Elements and Tools**
61 |
62 | - [ ] Modernizr
63 | - [ ] Static Site Generator (Jekyll, Hexo, or another)
64 | - [ ] LiveReload
65 | - [ ] SVG
66 | - [ ] Canvas API
67 | - [ ] WebRTC Video
68 | - [ ] WebRTC Audio
69 | - [ ] Phaser game framework
70 | - [ ] Three.js
71 | - [ ] D3.js
72 | - [ ] Chart.js
73 | - [ ] Polymer / Web components
74 |
75 | **Front End Frameworks**
76 |
77 | - [ ] React
78 | - [ ] Ionic
79 | - [ ] Meteor
80 | - [ ] Ember
81 | - [ ] Backbone
82 |
83 | **Languages**
84 |
85 | - [ ] SASS or LESS
86 | - [ ] Python
87 | - [ ] Clojure
88 | - [ ] CoffeeScript
89 | - [ ] Go
90 | - [ ] Swift
91 |
92 | **Security and Authorization**
93 |
94 | - [ ] XSS
95 | - [ ] OAuth
96 | - [ ] AuthZero
97 | - [ ] Recaptcha
98 |
99 | **ETC**
100 |
101 | - [ ] Websockets / Socket.io
102 | - [ ] TCP/IP
103 |
--------------------------------------------------------------------------------
/how-to/peer-review.md:
--------------------------------------------------------------------------------
1 | # Peer Review
2 | 
3 |
4 |
5 | | Objectives |
6 | | :--- |
7 | | Create a Github Issue for your project ([what to include](report-an-issue.md)) |
8 | | Fork & then clone your partner's project |
9 | | Pair program to resolve the Github Issue & submit a Pull Request |
10 |
11 | ###1. Create an Issue (10m)
12 |
13 | * Discuss what your application does at a high level. This should be one or two sentences, an elevator pitch. (5m)
14 | * Discuss 1 minor issue in your project. Make sure it's a simple issue, like a small addition, that could be solved relatively quickly with the tools we already have - jQuery, express, etc.
15 | * On Github, create a new Issue. Be descriptive of what is wrong and how you'd like it fixed. Maybe give some rough steps you'd take to solve it.
16 |
17 | 
18 |
19 | ###2. Setup the Project (5m)
20 | 1. __Fork__ your partner's project.
21 | 2. __Clone__ the fork you just made locally.
22 | 3. Make a new __branch__ named after the issue you're solving.
23 | - ` git checkout -b fix_signin_redirect`
24 | * See if you can successfully setup your partner's project by following the instructions in their readme. Note any roadblocks you hit along the way (create github issues).
25 |
26 | 
27 |
28 | ###3. Fix the problem (20m)
29 | 1. Make sure you are on the new __branch__ named after the issue you're solving, working on your __fork__ of your partner's project.
30 | - ` git checkout -b fix_signin_redirect`
31 | 2. Pair to solve the problem. Make frequent commits.
32 |
33 | ###4. Resolve the Issue (15m)
34 | 3. Push your branch to the fork:
35 | - `git push origin fix_signin_redirect`
36 | 4. Navigate to your repo on Github.com and submit the branch `fix_signin_redirect` as a pull request.
37 | 5. The project owner should code review and merge the pull request. They can code review small changes on Github itself, or they can fetch the pull request and view it locally.
38 |
39 | 
40 |
41 | ###5. Repeat
42 | Make sure you each get a chance to create and resolve a github issue.
43 |
--------------------------------------------------------------------------------
/how-to/report-an-issue.md:
--------------------------------------------------------------------------------
1 | # Issues
2 |
3 | Issues are one of the features GitHub provides to allow users to report bugs or make suggestions on projects. Most widely-used projects will have at least a few issues.
4 |
5 |
6 |
7 |
8 |
9 | GitHub has thorough [documentation on creating an issue](https://help.github.com/articles/creating-an-issue/).
10 |
11 | ## What to Include
12 |
13 | #### Expected Behavior (Required!)
14 |
15 | > What was your goal? What did you want to happen?
16 |
17 | #### Actual Behavior (Required!)
18 |
19 | > What happened instead?
20 |
21 | #### Steps to reproduce this behavior? (Required!)
22 |
23 | > What did you try? Be as specific as possible. You and others will need to to reproduce
24 | your issue in order to fix it. Code samples and lists of steps you took are great here.
25 |
26 | #### What version of the software were you using?
27 |
28 | > For web projects, it can be helpful to include which browser you were using,
29 | which version of the browser, and which operating system.
30 |
31 | #### Text of any error messages
32 |
33 | #### Contents of Javascript console in the browser or other logs
34 |
35 | #### Screenshot(s) showing the problem
36 |
37 | > Attach files by dragging & dropping, selecting them, or pasting from the clipboard.
38 |
39 |
--------------------------------------------------------------------------------
/how-to/request-a-code-review.md:
--------------------------------------------------------------------------------
1 | # Code Reviews
2 |
3 | Code reviews are a great way to get ideas, tips, and feedback on your projects:
4 |
5 | - Learn best practices
6 | - Discover new patterns/strategies for tackling problems
7 | - Get a second pair of eyes on your code (fewer bugs!)
8 |
9 | We encourage you to request at least 3 code reviews during your time as a student. They are an awesome way to "level up" and get individual feedback. Don't freak out, it's super valuable, and it's not that scary! We're happy to do them -- but it's up to you to ask!
10 |
11 | ## How to Request a Code Review
12 |
13 | 1. Push your project to GitHub.
14 | 2. Add your instructor/reviewer as a collaborator (*Settings > Collaborators & Teams > Add Collaborator*).
15 | + WDI 30
16 | * ben-manning - Ben
17 | * justincastilla - Justin
18 | * melicarls - Melissa
19 | * nathanallen - Nathan
20 | + WDI 27/28:
21 | * bgveenstra - Brianna
22 | * cofauver - Cory
23 | * jlopker - Juliana
24 | * justincastilla - Justin
25 | * nathanallen - Nathan
26 | * tgaff - Travis
27 | 3. To request the review, simply send a message to your instructor using Slack with a link to your project.
28 | + Describe what you're doing, and indicate any areas of concern / code you want us to pay particular attention to.
29 |
30 | #### What to expect
31 |
32 | Depending on your instructor, your review may entail:
33 |
34 | - **GitHub Issues**: these are commonly used to flag problems/issues with code, or areas of concern.
35 | + GitHub issues can be closed or resolved either on GitHub or by writing commit messages that reference the issue number (e.g. `git commit -m "fixes #10"`).
36 | - **A `code_review` branch**: This may either be a single commit with many inline comments/todos, or multiple commits, each addressing/fixing a specific problem.
37 | + We do not advise you merge code_review branches into your master branch -- please take the time to learn/absorb the feedback and implement the changes yourself.
38 |
--------------------------------------------------------------------------------