4 |
5 | Udacity Grow with Google Scholarship challenge course
6 |
7 | Intermediate Web Developer track
8 |
9 | Brendon Smith
10 |
11 | [br3ndonland](https://github.com/br3ndonland)
12 |
13 | [](https://choosealicense.com/)
14 |
15 | ## Background
16 |
17 | This repository contains notes and resources from the [Udacity Grow with Google](https://www.udacity.com/grow-with-google) Scholarship challenge course, in the Intermediate Web Developer track.
18 |
19 | The [Grow with Google scholarship program](https://www.udacity.com/grow-with-google) is an initiative designed to help people make career changes into coding. I was accepted to the intermediate web developer track to learn techniques for building progressive web apps. There was a three month challenge round, after which the top participants move on to a more advanced Mobile Web Specialist program.
20 |
21 | Here's how it went down:
22 |
23 | - Found out about the Grow with Google scholarship via Udacity's [Facebook](https://www.facebook.com/Udacity/posts/1250067568431912) and [Medium](https://medium.com/udacity/grow-with-google-50-000-new-scholarships-available-now-1aa0513430b6) posts, while on a bus to NYC for the [New York Coffee Festival](https://www.newyorkcoffeefestival.com/) on October 14, 2017.
24 | - [Applied](https://github.com/br3ndonland/udacity-google/blob/master/udacity-google-00-apply.md) in December 2017.
25 | - Won the scholarship in January 2018!
26 |
27 | Social media message:
28 |
29 | > I won a web development scholarship from Udacity and Google! I was accepted to the intermediate web developer track. There is a three month challenge round. If I do well, I can win another scholarship to a more advanced Mobile Web Specialist program.
30 | >
31 | > #GoogleUdacityScholars #GrowWithGoogle
32 |
33 | - Started the challenge course materials February 21, 2018.
34 | - Completed the challenge course materials on March 7, 2018 (working on Udacity basically full time). The course taught us how to build progressive web apps and use the new features in JavaScript ES6.
35 | - Attended five local meetups.
36 | - Started building a collaborative open-source transportation app, [MBTAccess](https://github.com/growwithgooglema/mbtaccess), in April 2018.
37 | - **Ranked in the top 10% of 10,000 students in the intermediate web developer track.** Ranking was based on completing all course materials, as well as participation in the Slack workspace, discussion forum, and meetups.
38 | - **Won a full scholarship to the [Google Mobile Web Specialist Nanodegree program](https://www.udacity.com/course/mobile-web-specialist-nanodegree--nd024).** See my [udacity-google-mws](https://github.com/br3ndonland/udacity-google-mws) repo for materials from the Nanodegree program.
39 |
40 | ## Course materials
41 |
42 | Materials in this repository:
43 |
44 | - [es6](es6): JavaScript ES6 course
45 | - [es6-1-syntax](es6/es6-1-syntax.md): JavaScript ES6 Syntax
46 | - [es6-2-functions](es6/es6-2-functions.md): JavaScript ES6 Functions
47 | - [es6-3-built-ins](es6/es6-3-built-ins.md): JavaScript ES6 Built-Ins (Symbols, Sets, Proxies, Maps, Generators)
48 | - [es6-4-polyfills-transpiling](es6/es6-4-polyfills-transpiling.md): JavaScript ES6 Transpiling and Polyfills
49 | - [offline-web-apps](offline-web-apps): Offline web apps course
50 | - [offline-1-benefits](offline-web-apps/offline-1-benefits.md): Intro to offline-first web apps
51 | - [offline-2-sw](offline-web-apps/offline-2-sw.md): Overview of Service Worker for offline-first web apps
52 | - [offline-3-indexeddb](offline-web-apps/offline-3-indexeddb.md): IndexedDB and Caching for offline-first web apps
53 | - [markdown-guide.md](markdown-guide.md): Guide to writing with Markdown
54 | - [udacity-google-00-apply.md](udacity-google-00-apply.md): Program application
55 | - [udacity-google-01.md](udacity-google-01.md): Course intro
56 | - [udacity-google-10.md](udacity-google-10.md): Program completion and feedback
57 | - [udacity-google-story.md](udacity-google-story.md): Developer story detailing my experience in the program
58 |
--------------------------------------------------------------------------------
/udacity-google-10.md:
--------------------------------------------------------------------------------
1 | # Lesson 10. Challenge Course Wrap-Up
2 |
3 | Udacity Grow with Google Scholarship challenge course
4 |
5 | Intermediate Web Developer track
6 |
7 | Brendon Smith
8 |
9 | br3ndonland
10 |
11 | ## Table of Contents
12 |
13 | - [Table of Contents](#table-of-contents)
14 | - [I did it](#i-did-it)
15 | - [Great work](#great-work)
16 | - [Program feedback](#program-feedback)
17 | - [Program suggestions](#program-suggestions)
18 |
19 | ## I did it
20 |
21 | I did it! I got through all the material for the challenge course! I will find out the results mid-April.
22 |
23 |
24 |
25 |
26 |
27 | ## Great work
28 |
29 | Message from Udacity:
30 |
31 | > Congrats on completing the Mobile Web Specialist challenge course!
32 | >
33 | > It's been an awesome journey and we hope you've enjoyed the program thus far.
34 | >
35 | > The fun doesn't stop here. We will be evaluating your course progress and engagement in the student community to determine the recipients of Nanodegree scholarships for the second phase of this program.
36 | >
37 | > Stay tuned for the announcement of round two scholarship recipients on April 17!
38 |
39 | ## Program feedback
40 |
41 | I was really pumped when I got this scholarship. And even more pumped when I started the lessons.
42 |
43 | **I enjoyed the introduction to progressive web apps (PWAs)**. I think about PWAs every time I look at my phone. I regularly prune my app collection to remove anything I don't use, but my Google Pixel XL still currently has >150 apps. That seems like too many. I think we are over-dependent on native apps. Native apps have their place, but have reduced the openness of the web and created clutter on our mobile devices. The future seems like it's going to be in blurring the line between websites and apps. I'm excited to be surfing the next wave of PWAs!
44 |
45 | The **timing** was challenging. When the Grow with Google challenge course began, I had been working through the Udacity Full Stack Web Developer Nanodegree program (FSND). I was a a little bit stressed about the time limit on the challenge course, and about how to budget my time between the two programs. However, with the help of my Udacity FSND mentor, I came up with an effective approach. I worked up to a good pause point in the FSND, then worked through the Grow with Google materials, finishing over a month ahead of the deadline, and then got back to the FSND.
46 |
47 | Another challenging aspect for me was the **participation**. Social media can be distracting. It took me a little while to warm up to the forums and Slack, but I was glad I did. Two positive outcomes of the social networking were **meetups** and **pomodoros**. I got to meet up with some fellow Udacious humans in Boston. I also learned about the pomodoro technique. It's like interval training for working, and really helped me get through the course materials efficiently. My participation not only helped me, but the other students as well. I took detailed notes on the course materials and shared them on [GitHub](https://github.com/br3ndonland/udacity-google). Other students appreciated the organized, thorough notes. I also put together a [guide to writing with Markdown](markdown-guide.md) to help other students maximize their documentation.
48 |
49 | Thanks Udacity and Google!
50 |
51 | ## Program suggestions
52 |
53 | - **Present the ES6 lessons first.** This would especially help those of us new to JavaScript. I heard some students did the ES6 syntax lessons first and found it helpful.
54 | - **Update the wittr code for ES6.** This would make the codebase for the course more cohesive, allowing us to apply what we learn in the ES6 syntax lessons. It is helpful to include Babel transpiling for browser compatibility, but for the students it would be more helpful to always be looking at ES6 throughout the course.
55 | - **Explain the wittr stack more clearly.** There was a lot of code running under the hood. The instructor Jake did a good job explaining how the app connects to the internet (caching, sockets, etc), but it would have been great to have a more detailed walk-through of the code used to actually build the app.
56 | - It would also be great to have a **project** as a more technical assessment of our performance, but I understand that it would be difficult to evaluate 10K projects.
57 |
58 | I shared this in the Udacity discussion forum, and many people agreed.
59 |
60 | [(Back to TOC)](#table-of-contents)
61 |
--------------------------------------------------------------------------------
/udacity-google-story.md:
--------------------------------------------------------------------------------
1 | # Student stories challenge
2 |
3 | ## Table of Contents
4 |
5 | - [Table of Contents](#table-of-contents)
6 | - [Personal story](#personal-story)
7 | - [1. Circumstances that brought you to Udacity](#1-circumstances-that-brought-you-to-udacity)
8 | - [2. Reasons for applying](#2-reasons-for-applying)
9 | - [3. Ways in which this Scholarship Challenge helped so far in your life](#3-ways-in-which-this-scholarship-challenge-helped-so-far-in-your-life)
10 | - [Tips for fitting study time/project time into your daily schedule](#tips-for-fitting-study-timeproject-time-into-your-daily-schedule)
11 | - [Result](#result)
12 |
13 | ## Personal story
14 |
15 | ### 1. Circumstances that brought you to Udacity
16 |
17 | During my two years in a large molecular biology lab at Harvard, I became frustrated by the lack of technology tools to do my work efficiently. I saw that we are facing a reproducibility crisis in science, in which the discoveries that we publish are not correct or relevant to humans. I also saw that many scientists are struggling to sustain work/life balance.
18 |
19 | We will never effectively address these issues without better technology tools to perform and document our work. After realizing this, I left my job at Harvard to dedicate myself to web development. My purpose is to build science technology tools for a more efficient, reproducible and sustainable research culture.
20 |
21 | ### 2. Reasons for applying
22 |
23 | I wanted to expand my training into progressive web apps (PWAs). I think about PWAs every time I look at my phone. I regularly prune my app collection to remove anything I don't use, but my Google Pixel XL still currently has >150 apps. That seems like too many. I think we are over-dependent on native apps. Native apps have their place, but have reduced the openness of the web and created clutter on our mobile devices. The future seems like it's going to be in blurring the line between websites and apps. I'm excited to be surfing the next wave of PWAs!
24 |
25 | ### 3. Ways in which this Scholarship Challenge helped so far in your life
26 |
27 | I was really pumped when I got this scholarship. And even more pumped when I started the lessons. I enjoyed the introduction to progressive web apps (PWAs) in the lessons, and found that the program improved my life!
28 |
29 | I discovered that **web development engages the two major motivating outcomes in my life, focused personal growth and positive impact.**
30 |
31 | I am most happy when I am improving myself. Web developers use a large set of tools and skills. I have enjoyed building these skills so far, and appreciate how quickly I can make progress. My vision for improving science leads my personal growth to be focused and purposeful.
32 |
33 | Web development will enable me to have a positive impact on the world by building technology tools for science. Science is of central importance in our society, but scientists do not have the software or hardware to work effectively. I will be able to deliver improved technology tools that will allow science to become more efficient, reproducible, and sustainable.
34 |
35 | **The participation was challenging for me, but ended up really enriching my experience.** Social media can be distracting. It took me a little while to warm up to the forums and Slack, but I was glad I did. Two positive outcomes of the social networking were **meetups** and **pomodoros**. I got to meet up with some fellow Udacious humans in Boston. I also learned about the pomodoro technique. It's like interval training for working, and really helped me get through the course materials efficiently. My participation not only helped me, but the other students as well. I took detailed notes on the course materials and shared them on [GitHub](https://github.com/br3ndonland/udacity-google). Other students appreciated the organized, thorough notes. I also put together a guide to writing with Markdown to help other students maximize their documentation.
36 |
37 | Thanks Udacity and Google!
38 |
39 | ## Tips for fitting study time/project time into your daily schedule
40 |
41 | Pomodoro intervals were really helpful for watching lessons. I found that each lesson took about one 25 minute pomodoro. After the 25 minutes, I would reflect on how well I used my time, and how I want to spend the next 25 minutes. Pomodoros helped me stay efficient and focused.
42 |
43 | ## Result
44 |
45 | One story winner was selected from each track of the program.
46 |
47 | Slack announcement:
48 |
49 | > _WAY TO GO, SCHOLARS!_ You exceeded our 1,000 story goal by submitting 1,193 of your amazing Student Stories to us! :man_dancing::dancer:
50 | >
51 | > And now, we'd like to introduce the five Mobile Web finalists:
52 | >
53 | > HUGE congrats to @jSick, @neuralnet, @derick_gross, @twip, and @Serenity :clap:
54 | >
55 | > Read their personal story and vote for your favorite in the doc below. You can only pick one! All votes need to be in by _tomorrow March 21st at 11:59 pm PT._
56 | >
57 | > Thank you to everyone who submitted a story! It was so much fun getting to know you better.
58 | >
59 | > Mobile Web Finalist Stories [here](https://docs.google.com/presentation/d/1XItqm2vEREGrqLCBh1FMgG0fbhBJtFEMArvJYAW1kvQ/edit?usp=sharing)
60 |
--------------------------------------------------------------------------------
/es6/es6-4-polyfills-transpiling.md:
--------------------------------------------------------------------------------
1 | # JavaScript Polyfills and Transpiling
2 |
3 |
4 |
53 |
54 |
55 |
56 | > It makes sense that code doesn't work in older browsers that were developed prior to the release of ES6, but there are some browsers that have been released after ES6 that don't support the new JavaScript syntax and functionality yet.
57 | >
58 | > Most of us don't think much about the browser and all it can do...until it doesn't work! But really, browser makers have a tough time. Think about HTML, CSS, and JavaScript - these languages are fluid and are always improving. Browser makers have to keep up with all of these changes.
59 |
60 | #### But how do they know about these changes
61 |
62 | > They learn (or actually build) the language specifications!
63 | >
64 | > Just like the [World Wide Web Consortium (W3C)](https://www.w3.org/) is the standards body for things like HTML, CSS, and SVG, [Ecma International](https://www.ecma-international.org/) is an industry association that develops and oversees standards like JavaScript and JSON. You can find the specifications for ES6 [here](http://www.ecma-international.org/ecma-262/6.0/index.html).
65 |
66 | #### Further Info
67 |
68 | > Ecma International is an important industry community and definitely worth checking out in more detail:
69 | >
70 | > - [https://en.wikipedia.org/wiki/Ecma_International](https://en.wikipedia.org/wiki/Ecma_International)
71 | > - [http://www.ecma-international.org/memento/index.html](http://www.ecma-international.org/memento/index.html)
72 | >
73 | > **NOTE:** The code we've been looking at in this course is not supported by older browsers. Older browsers that were developed prior to the release of ES6 were developed to support the version of JavaScript at the time (which was ES5.1). If you try running any ES6 code in an older browser, it won't work.
74 |
75 | ### 4.03. ES6 Specification
76 |
77 | #### Intro to ES6 Specification
78 |
79 | > The specification (commonly shortened to "spec") for ES6 can be found [here](http://www.ecma-international.org/ecma-262/6.0/index.html). The spec lists the set of rules and guidelines on _how_ the language is supposed to function. It doesn't give specific details on how browser makers are supposed to achieve functionality, but it does provide step-by-step instructions on how the language is supposed to work. While making this course, we repeatedly referred to this official spec.
80 | >
81 | > Ok, so honestly, it can be a little difficult to decipher some of the cryptic wording of the spec. But when you have a question about ES6, we recommend checking out info on the topic like that provided by the [Mozilla Developer Network](https://developer.mozilla.org/) and then also reviewing what the spec actually says.
82 |
83 | #### Quiz Question
84 |
85 | Check out the [ES6 Specification](http://www.ecma-international.org/ecma-262/6.0/index.html). Which section in the spec covers arrow functions?
86 |
87 | - section 6
88 | - section 10.3.2
89 | - section 14.2
90 | - section 18.3.29
91 |
92 |
293 |
294 | #### Transpiling project in repo
295 |
296 | > If you check in the [repo for this project](https://github.com/udacity/course-es6/tree/master/lesson-4/walk-through-transpiling), inside the Lesson 4 directory is a little project that's all set up for transpiling ES6 code to ES5 code. There's an "ES6" directory that contains the ES6 code we'll be transpiling (using Babel) to ES5 code that will be able to run in every browser.
297 | >
298 | > The way Babel transforms code from one language to another is through plugins. There are plugins that transform ES6 arrow functions to regular ES5 functions (the [ES2015 arrow function plugin](http://babeljs.io/docs/plugins/transform-es2015-arrow-functions/)). There are plugins that transform ES6 template literals to regular string concatenation (the [ES2015 template literals transform](http://babeljs.io/docs/plugins/transform-es2015-template-literals/)). For a full list, check out [all of Babel's plugins](http://babeljs.io/docs/plugins/).
299 |
300 |
301 |
302 | > Now, you're busy and you don't want to have to sift through a big long list of plugins to see which ones you need to convert your code from ES6 to ES5. So instead of having to use a bunch of individual plugins, Babel has **presets** which are groups of plugins bundled together. So instead of worrying about which plugins you need to install, we'll just use the [ES2015 preset](http://babeljs.io/docs/plugins/preset-es2015/) that is a collection of all the plugins we'll need to convert all of our ES6 code to ES5.
303 | >
304 | > You can see that the project has a `.babelrc` file. This is where you'd put all of the plugins and/or presets that the project will use. Since we want to convert all ES6 code, we've set it up so that it has the ES2015 preset.
305 |
306 | ```json
307 | {
308 | "presets": ["es2015"]
309 | }
310 | ```
311 |
312 |
313 |
314 | > **WARNING:** Babel uses both **Node** and **NPM** to distribute its plugins. So before you can install anything, make sure you have both of these tools installed:
315 | >
316 | > - install [Node](https://nodejs.org/) (which will automatically install NPM)
317 |
318 | ### 4.12. Transpiling Walkthrough
319 |
320 | **Note that Richard has selected the MIT license for his materials. I have correspondingly also selected the MIT license for my course repo.**
321 |
322 | > The project's \*package.json- file lists all of the NPM packages that this project depends on.
323 | >
324 | > This project depends on
325 | >
326 | > - `babel-cli`
327 | > - `babel-preset-es2015`
328 | >
329 | > The babel 2015 preset is a collection of all es6 plugins. So these are the plugins that will be downloaded and installed.
330 | >
331 | > Once they're installed we need to tell the Babel CLI which plugins it should use to do the transpiling. The CLI will check the \*.babelrc- file for which plugins and presets to use.
332 | >
333 | > So the _package.json- file lists what should be installed and the _.babelrc- file tells babel which plugins to use when it does its transpiling.
334 | >
335 | > Now that babel knows to use this preset we need to tell it to actually transpile the code. To do that we've added a build script that will tell babel to take the files in the ES6 directory, transpile them using the es2015 preset, and then put the transformed code in the ES5 directory.
336 |
337 |
338 |
339 | ### 4.13. Transpiling Recap
340 |
341 | > NOTE: As of the creation of this course (circa Winter 2016), most of ES6 is supported by the current set of browsers. But that's "most", not "all", unfortunately. And that's also referring to "current" browsers. There are plenty of older browsers that do not support many, if any, of the new ES6 additions. However, it is safe to say that pretty much every browser supports the previous version of the language (ES5.1).
342 | >
343 | > It's important to stay on top of all the changes JavaScript is going through. The best way to do that is to start making use of the new features that are added. The problem is that not all browsers support these new features.
344 | >
345 | > So, to have your cake and eat it too, you can write in ES6 and then use a transpiler to convert it to ES5 code. This lets you transform your project's code base to the newest version of the language while still letting it run everywhere. Then, once all of the browsers your app has to run on fully support ES6 code, you can stop transpiling your code and just serve the straight ES6 code, directly!
346 |
347 | ### 4.14. Course Summary
348 |
349 |
350 |
351 | ## Feedback on Lesson 9 (JavaScript ES6 lesson 4/4)
352 |
353 | Informative and helpful lesson.
354 |
355 | [Previous lesson](es6-3-built-ins.md)
356 |
357 | [(Back to top)](#top)
358 |
--------------------------------------------------------------------------------
/offline-web-apps/offline-3-indexeddb.md:
--------------------------------------------------------------------------------
1 | # IndexedDB and Caching
2 |
3 |
4 |
50 |
51 | - Why does IndexedDB have a bad reputation?
52 | - The API is "a little... horrid" and it can create spaghetti code.
53 | - It has its own event-based promise system (it predates promises) that can be confusing.
54 | - Jake believes in teaching the web platform rather than libraries, but in this case, we will use **[IndexedDB Promised (idb)](https://github.com/jakearchibald/idb)**, which Jake created. It mirrors the IndexedDB API and uses promises instead of events.
55 |
56 | ### 3.02. Getting Started with IDB
57 |
58 | - Navigate to [http://localhost:8888/idb-test](http://localhost:8888/idb-test) which is currently just a blank page with a script tag to import `idb`.
59 | - Jake walked through some of the code in `idb`.
60 |
61 | #### Create database
62 |
63 | - `createObjectStore`: Jake referred to [MDN](https://developer.mozilla.org/en-US/docs/Web/API/IDBDatabase/createObjectStore). Jake creates an object store named 'keyval'.
64 | - `IDBObjectStore.put()`: [MDN](https://developer.mozilla.org/en-US/docs/Web/API/IDBObjectStore/put)
65 |
66 | ```javascript
67 | import idb from "idb"
68 |
69 | var dbPromise = idb.open("test-db", 1, function(upgradeDb) {
70 | var keyValStore = upgradeDb.createObjectStore("keyval")
71 | keyValStore.put("world", "hello")
72 | })
73 | ```
74 |
75 | #### Read from database
76 |
77 | ```javascript
78 | dbPromise
79 | .then(function(db) {
80 | var tx = db.transaction("keyval")
81 | var keyValStore = tx.objectStore("keyval")
82 | return keyValStore.get("hello")
83 | })
84 | .then(function(val) {
85 | console.log('The value of "hello" is:', val)
86 | })
87 | ```
88 |
89 | #### Add another value to the object store
90 |
91 | ```javascript
92 | dbPromise
93 | .then(function(db) {
94 | var tx = db.transaction("keyval", "readwrite")
95 | var keyValStore = tx.objectStore("keyval")
96 | keyValStore.put("bar", "foo")
97 | return tx.complete
98 | })
99 | .then(function() {
100 | console.log("Added foo:bar to keyval")
101 | })
102 | .catch(function(error) {
103 | console.error("Transaction failed:", error)
104 | })
105 | ```
106 |
107 | ### 3.03. Quiz: Getting Started with IDB
108 |
109 | Git
110 |
111 | - Checkout to new branch:
112 |
113 | ```shell
114 | $ git reset --hard
115 | $ git checkout origin/page-skeleton
116 | ```
117 |
118 |
314 |
315 | - _public/js/main/IndexController.js_
316 | - The `IndexController._openSocket` method is called to open the Web Socket.
317 | - `IndexController._openSocket` listens for the message event, and passes data to the `IndexController._onSocketMessage` method.
318 | - `IndexController._onSocketMessage` parses JSON data and passes it to `IndexController._postsView.addPosts`.
319 |
320 | ### 3.06. Quiz: Using IDB Cache
321 |
322 | Git
323 |
324 | - Checkout to new branch:
325 |
326 | ```shell
327 | $ git reset --hard
328 | $ git checkout origin/task-idb-store
329 | ```
330 |
331 | Task
332 |
333 | > Your task is to return a Promise for a database called 'wittr' that has an object store called 'wittrs' that uses 'id' as its key and has an index called called 'by-date', which is sorted by the 'time' property.
334 | >
335 | > Once you've done that, you'll need to add messages to the database. Down in the IndexController.\_onSocketMessage method, the database has been fetched. Your task is to add each of the messages to the Wittr store. Note that we're not using the entries in the database yet - we'll do that in the next chapter.
336 |
337 | If the database gets messed up, run `indexedDB.deleteDatabase('wittr')` in DevTools to reset.
338 |
339 |
533 |
534 | - Images will be stored in a separate cache from the other static content. This allows the photos to live on between different versions of the app.
535 | - We will be working with a responsive image. It has different sizes based on the viewport width.
536 | - Using responses multiple times: `response.json();` cannot be re-read with `response.blob();`. Once the data are read in as json, it disappears from memory. This applies to `event.respondWith(response);` as well. This is a problem for our photos. We want to open a cache, fetch from the network, and send the response both to the cache and the browser. To fix this, we clone the response with `response.clone()`. A clone goes to the cache, and the original response gets sent to the page.
537 |
538 | ### 3.10. Quiz: Cache Photos Quiz
539 |
540 | Git
541 |
542 | - Checkout to new branch:
543 |
544 | ```shell
545 | $ git reset --hard
546 | $ git checkout origin/task-cache-photos
547 | ```
548 |
549 | Code in _public/js/sw/index.js_ (the service worker script)
550 |
551 |
773 |
774 | ## Lesson feedback
775 |
776 | Again, a very informative and helpful lesson. It would be nice to use Udacity's browser-based quiz system instead of all the git resets, but I understand that it would be difficult to demo the app without a local clone of the git repo.
777 |
778 | [Previous lesson](offline-2-sw.md)
779 |
780 | [(Back to top)](#top)
781 |
--------------------------------------------------------------------------------
/markdown-guide.md:
--------------------------------------------------------------------------------
1 | # Markdown guide
2 |
3 | Brendon Smith ([br3ndonland](https://github.com/br3ndonland))
4 |
5 | ## Table of Contents
6 |
7 | - [Markdown syntax](#markdown-syntax)
8 | - [Syntactic suggestions](#syntactic-suggestions)
9 | - [General Markdown resources](#general-markdown-resources)
10 | - [Markdown apps](#markdown-apps)
11 | - [Text editors](#text-editors)
12 | - [IDEs](#ides)
13 | - [Note apps](#note-apps)
14 | - [In-browser editors](#in-browser-editors)
15 | - [Social apps](#social-apps)
16 |
17 | **Markdown is a simplified HTML syntax.** It has most of the functionality of HTML while being much easier to read, and is very widely used (for example, READMEs on GitHub).
18 |
19 | Here's a comparison of the same code written in Markdown and HTML (using Sublime Text):
20 |
21 |
22 |
23 | ## Markdown syntax
24 |
25 | ### Syntactic suggestions
26 |
27 | Suggestions for standardized Markdown formatting have been provided by [markdownlint](https://github.com/DavidAnson/markdownlint) and [Markdown Style Guide](http://www.cirosantilli.com/markdown-style-guide/). Here are a few personal pointers:
28 |
29 | #### File extensions
30 |
31 | - Several different extensions can be used, including .md, .mdown, and .markdown.
32 | - **I prefer to use .md for brevity and consistency.**
33 |
34 | #### Headers
35 |
36 | - Create headers with `#`. Each `#` increases header level (`##` is outline level two), up to six levels.
37 | - **For organization, I reserve H1 (`#`) for the title of the file at the top. Major headers begin with H2 (`##`).**
38 | - I use headers to create a **Table of Contents (TOC)** at the beginning of the file.
39 | - **I add `## Table of Contents` before the TOC for navigation.** I also include ``, which tells the VSCode Markdown All In One extension not to put the `## Table of Contents` header itself into the TOC.
40 | - **I include [(Back to top)](#top) links after each section for easy navigation back to the top of the page.** Simply write `[(Back to top)](#top)`.
41 | - I add and auto-update TOCs in vscode with the [Markdown All in One](https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one) extension.
42 | - [Markdown All in One](https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one), JupyterLab and RStudio provide inline TOC displays ([see below](#jupyterlab)).
43 | - Prior to vscode, I was adding and updating TOCs with [DocToc](https://github.com/thlorenz/doctoc) from the command line.
44 |
45 | #### Text
46 |
47 | - **Bold text:** use **double star at beginning and end of text to bold.**
48 | - _Italics:_ use _underscores or single stars with no space before and after._
49 | - **I prefer to indent Markdown text with two spaces.** Four spaces can be read by some systems as code blocks.
50 |
51 | #### Lists
52 |
53 | - **Lists should be preceded by a blank line.**
54 | - Single `*`, `-`, or `+` at beginning of line, followed by tab or space.
55 | - Indent for next outline level
56 | - Like this
57 |
58 | 1. Ordered lists
59 | 2. Like this
60 | - And you can add in unordered lists within ordered lists like this.
61 | - Adding an unordered list within an ordered list requires two levels of indentation.
62 |
63 | #### Code
64 |
65 | You can include `inline code inside single backticks`
66 |
67 | ```text
68 | Fenced code blocks inside triple backticks
69 | ```
70 |
71 | - Code blocks can be indented to match your lists
72 |
73 | ```text
74 | like this
75 | ```
76 |
77 | - In GitHub-Flavored Markdown, you can specify the language next to the first set of triple backticks for syntax highlighting. Each language has a full name (like `python`), and an abbreviation (like `py`). The full list of supported languages can be found in [GitHub's Linguist repo](https://github.com/github/linguist), which is used to detect languages on GitHub. The _[languages.yml](https://github.com/github/linguist/blob/master/lib/linguist/languages.yml)_ contains a list of the available abbreviations (called "extensions" in the YAML) for each language.
78 |
79 | - Shell: `shell` or `sh`
80 |
81 | ```sh
82 | git status
83 | git commit
84 | ```
85 |
86 | - JavaScript _fizzbuzz.js_, ES6, formatted with [Prettier](https://prettier.io/): `javascript` or `js`
87 |
88 | ```js
89 | const fizzBuzz = () => {
90 | for (let i = 1; i <= 100; i++) {
91 | let out = ""
92 | if (i % 3 === 0) out += "Fizz"
93 | if (i % 5 === 0) out += "Buzz"
94 | console.log(out || i)
95 | }
96 | }
97 | ```
98 |
99 | - Python _fizzbuzz.py_, Python 3, formatted with [Black](https://black.readthedocs.io/en/stable/): `python` or `py`
100 |
101 | ```py
102 | def fizzbuzz():
103 | """Print 1-100
104 | Multiples of 3: Fizz
105 | Multiples of 5: Buzz
106 | Multiples of 3 and 5: FizzBuzz
107 | """
108 | for i in range(1, 101):
109 | out = ""
110 | if i % 3 == 0:
111 | out += "Fizz"
112 | if i % 5 == 0:
113 | out += "Buzz"
114 | print(out or i)
115 | ```
116 |
117 | #### Images
118 |
119 | ```text
120 | `
121 | ```
122 |
123 | **I still prefer to use HTML image tags, because they allow for more customization.** In particular, it's useful to set width on SVG.
124 |
125 | ```text
126 | 66 | The scope defines the URLs to be handled. ServiceWorker will handle any deeper URL, but not shallower URLs. 67 |
68 |
103 |
104 | #### let and const
105 |
106 | > Variables declared with `let` and `const` eliminate this specific issue of hoisting because they’re **scoped to the block, not to the function.** Previously, when you used `var`, variables were either scoped globally or locally to an entire function scope.
107 | >
108 | > If a variable is declared using `let` or `const` inside a block of code (denoted by curly braces `{ }`), then the variable is stuck in what is known as the **temporal dead zone** until the variable’s declaration is processed. This behavior prevents variables from being accessed only until after they’ve been declared.
109 | >
110 | > **Question 2 of 3**
111 | >
112 | > What do you expect to be the output from running `getClothing(false)`?
113 |
114 | ```javascript
115 | function getClothing(isCold) {
116 | if (isCold) {
117 | const freezing = "Grab a jacket!"
118 | } else {
119 | const hot = "It’s a shorts kind of day."
120 | console.log(freezing)
121 | }
122 | }
123 | ```
124 |
125 | Answer: `ReferenceError: freezing is not defined`.
126 |
127 | > Because freezing is not declared inside the else statement, the function scope, or the global scope, a ReferenceError is thrown.
128 |
129 | #### Rules for using let and const
130 |
131 | > `let` and `const` also have some other interesting properties.
132 | >
133 | > - Variables declared with `let` can be reassigned, but can’t be redeclared in the same scope.
134 | > - Variables declared with `const` must be assigned an initial value, but can’t be redeclared in the same scope, and can’t be reassigned.
135 | >
136 | > **Question 3 of 3**
137 | >
138 | > What do you expect to be output from running the following code?
139 |
140 | ```javascript
141 | let instructor = "James"
142 | instructor = "Richard"
143 | console.log(instructor)
144 | ```
145 |
146 | Answer: Richard. Got it on the first try.
147 |
148 | > This is the correct way to use `let`. Use `let` to declare variables when you plan on changing the value of a variable later in your code.
149 |
150 | #### Use cases
151 |
152 | > The big question is when should you use `let` and `const`? The general rule of thumb is as follows:
153 | >
154 | > - use `let` when you plan to reassign new values to a variable, and
155 | > - use `const` when you don’t plan on reassigning new values to a variable.
156 | >
157 | > Since `const` is the strictest way to declare a variable, we suggest that you always declare variables with `const` because it'll make your code easier to reason about since you know the identifiers won't change throughout the lifetime of your program. If you find that you need to update a variable or change it, then go back and switch it from `const` to `let`.
158 | >
159 | > That’s pretty straightforward, right? But what about `var`?
160 |
161 | #### What about var
162 |
163 | > **Is there any reason to use `var` anymore? Not really.**
164 | >
165 | > There are some arguments that can be made for using `var` in situations where you want to globally define variables, but this is often considered bad practice and should be avoided. From now on, we suggest ditching `var` in place of using `let` and `const`.
166 |
167 | ### 1.03. Quiz: Using Let and Const (1-1)
168 |
169 | Quiz
170 |
171 | Replace `var` with `let` or `const`
172 |
173 | ```javascript
174 | /*
175 | - Programming Quiz: Using Let and Const (1-1)
176 | */
177 |
178 | var CHARACTER_LIMIT = 255
179 | var posts = [
180 | "#DeepLearning transforms everything from self-driving cars to language translations. AND it's our new Nanodegree!",
181 | "Within your first week of the VR Developer Nanodegree Program, you'll make your own virtual reality app",
182 | "I just finished @udacity's Front-End Web Developer Nanodegree. Check it out!"
183 | ]
184 |
185 | // prints posts to the console
186 | function displayPosts() {
187 | for (var i = 0; i < posts.length; i++) {
188 | console.log(posts[i].slice(0, CHARACTER_LIMIT))
189 | }
190 | }
191 |
192 | displayPosts()
193 | ```
194 |
195 |
' +
452 | '' + 454 | animal.fact + 455 | "
" + 456 | '' + 471 | animal.summary + 472 | "
" + 473 | "
507 | ${animal.fact}
509 |${animal.summary}
516 |