From 993393f401b8eefbb27095a7d607d5c0aef97b0a Mon Sep 17 00:00:00 2001 From: Hasna SABAH Date: Sat, 30 Sep 2017 16:38:53 +0100 Subject: [PATCH 01/89] added "Normal Form" article with examples and external links --- .../databases/normal-form/index.md | 108 +++++++++++++++++- 1 file changed, 104 insertions(+), 4 deletions(-) diff --git a/src/pages/computer-science/databases/normal-form/index.md b/src/pages/computer-science/databases/normal-form/index.md index 1bc9e3c73d2..069e32d1bfc 100644 --- a/src/pages/computer-science/databases/normal-form/index.md +++ b/src/pages/computer-science/databases/normal-form/index.md @@ -2,14 +2,114 @@ title: Normal Form --- ## Normal Form +Normalization was first introduced as part of the relational model. It is the process of organizing data tables and columns in a way that reduces redundancies and improves integrity. This can either be done through : +* synthesis : creates a normalized database design based on a known set of dependencies. +* decomposition : takes an existing (insufficiently normalized) database design and improves it based on the known set of dependencies + +There are three common normal forms (1st, 2nd and 3rd) plus a rather advanced form called BCNF. They are progressive : in orther to qualify for the 3rd normal form, a database schema must satisfy the rules of the 2nd normal form, and so on for the 1st normal form. +* **1st normal form** : The information is stored in a table, each column contains atomic values, and there are not repeating groups of columns. This : + 1. Eliminates repeating groups in individual tables. + 2. Creates a separate table for each set of related data. + 3. Identifies each set of related data with a primary key +##### Example +A design that violates the 1st normal form, the "telephone" column does not contain atomic values + +| customer ID | First name | Last name | Telephone | +|-------------|------------|-----------|--------------------------------------| +| 123 | Pooja | Singh | 555-861-2025, 192-122-1111 | +| 789 | John | Doe | 555-808-9633 | +| 456 | San | Zhang | (555) 403-1659 Ext. 53; 182-929-2929 | + +One solution would be to have an extra column for each phone number. But then, this will repeat conceptually the same attribute(phone number). Moreover, adding extra telephone number will require reorganizing the table by adding more column.This is definitely not practicle. + +Another solution is to have a separate table for the association customer <-> Telephone: This respects the 1st normal form and there can be as many rows per customer as needed. + +| customer ID | First name | Last name | +|-------------|------------|-----------| +| 123 | Pooja | Singh | +| 789 | John | Doe | +| 456 | San | Zhang | + + +| customer ID | Telephone | +|-------------|------------------------| +| 123 | 555-861-2025 | +| 123 | 192-122-1111 | +| 789 | 555-808-9633 | +| 456 | (555) 403-1659 Ext. 53 | +| 456 | 182-929-2929 | + +* **2nd normal form** : The table is in the first normal form and all the non-key columns depend on the table's primary key. This narrows the table's purpose. +##### Example +A design that violates the 2nd normal form. The model full name being the primary key, there are other candidate keys like {manufacturer, model}. The "Manufacturer Country" column is dependant on a non-key column (the Manufacturer). + +| Manufacturer | Model | Model Full Name | Manufacturer Country | +|---------------------|--------------|----------------------|----------------------| +| Forte | X-Prime | Forte X-Prime | Italy | +| Forte | Ultraclean | Forte Ultraclean | Italy | +| Dent-o-Fresh | EZbrush | Dent-o-Fresh EZbrush | USA | +| Kobayashi | ST-60 | Kobayashi ST-60 | Japan | +| Hoch | Toothmaster | Hoch Toothmaster | Germany | +| Hoch | X-Prime | Hoch X-Prime | Germany | + +The normalized design would be to split into two tables like the following: + +| Manufacturer | Manufacturer Country | +|---------------------|----------------------| +| Forte | Italy | +| Dent-o-Fresh | USA | +| Kobayashi | Japan | +| Hoch | Germany | + +| Manufacturer | Model | Model Full Name | +|---------------------|--------------|----------------------| +| Forte | X-Prime | Forte X-Prime | +| Forte | Ultraclean | Forte Ultraclean | +| Dent-o-Fresh | EZbrush | Dent-o-Fresh EZbrush | +| Kobayashi | ST-60 | Kobayashi ST-60 | +| Hoch | Toothmaster | Hoch Toothmaster | +| Hoch | X-Prime | Hoch X-Prime | + + +* **3rd normal form** : The table is in second normal form and all of its columns are not transitively dependent on the primary key. +A column is said to be dependant on an another column if it can be derived from it, for example, the age can be derived from the birthday. Transitivity means this dependance might involve other columns. for example, if we consider three columns `PersonID BodyMassIndex IsOverweight` , the column 'IsOverweight' is transitively dependant on 'personID' through 'BodyMassIndex'. + +##### Example +A design that violates the 3rd normal form. {Tournament, Year} is the primary key for the table and the column 'Winner Date of Birth' transitively depends on it. + +| Tournament | Year | Winner | Winner Date of Birth | +|----------------------|-------------|----------------|----------------------| +| Indiana Invitational | 1998 | Al Fredrickson | 21 July 1975 | +| Cleveland Open | 1999 | Bob Albertson | 28 September 1968 | +| Des Moines Masters | 1999 | Al Fredrickson | 21 July 1975 | +| Indiana Invitational | 1999 | Chip Masterson | 14 March 1977 | + +A design compliant with the 3rd normal form would be : + +| Tournament | Year | Winner | +|----------------------|-------------|----------------| +| Indiana Invitational | 1998 | Al Fredrickson | +| Cleveland Open | 1999 | Bob Albertson | +| Des Moines Masters | 1999 | Al Fredrickson | +| Indiana Invitational | 1999 | Chip Masterson | + +| Winner | Date of Birth | +|----------------|-------------------| +| Chip Masterson | 14 March 1977 | +| Al Fredrickson | 21 July 1975 | +| Bob Albertson | 28 September 1968 | -This is a stub. Help our community expand it. -This quick style guide will help ensure your pull request gets accepted. - #### More Information: - +* database normalisation on [wikipedia](https://en.wikipedia.org/wiki/Database_normalization) +* first normal form on [wikipedia](https://en.wikipedia.org/wiki/First_normal_form) +* second normal form on [wikipedia](https://en.wikipedia.org/wiki/Second_normal_form) +* third normal form on [wikipedia](https://en.wikipedia.org/wiki/Third_normal_form) + + + + From 7189b1d6d59c44f37bc07ba8b15e7954d00d2cb3 Mon Sep 17 00:00:00 2001 From: Jeff Thompson Date: Tue, 3 Oct 2017 20:59:15 -0500 Subject: [PATCH 02/89] clarify text Edits were made to the text in order to help clear up the meaning of some passages . --- src/pages/javascript/prototypes/index.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/pages/javascript/prototypes/index.md b/src/pages/javascript/prototypes/index.md index 16673279b6e..caf2f9855d4 100644 --- a/src/pages/javascript/prototypes/index.md +++ b/src/pages/javascript/prototypes/index.md @@ -3,11 +3,11 @@ title: Prototypes --- ## Prototypes -JavaScript is a prototype-based language, so the prototype is one of the most important concepts which new JavaScript learners must know. This article will give you a short overview about this concept through examples. Before read the article, you need to have basic understanding [`this` reference in JavaScript](/javascript/this-in-javascript). +JavaScript is a prototype-based language, therefore understanding the prototype object is one of the most important concepts which JavaScript practitioners need to know. This article will give you a short overview of the Prototype object through various examples. Before reading this article, you will need to have a basic understanding of [`this` reference in JavaScript](/javascript/this-in-javascript). ### Prototype object -For the sake of clarity, let's examine following example: +For the sake of clarity, let's examine the following example: ```javascript function Point2D(x, y) { @@ -16,7 +16,7 @@ function Point2D(x, y) { } ``` -As `Point2D` function is declared, a property named `prototype` will be created by default for it (note that, in JavaScript, a function is also a object). The `prototype` property is also a object which contains `constructor` property and its value is `Point2D` function: `Point2D.prototype.constructor = Point2D`. And when you call `Point2D` with `new` keyword, *newly created objects will inherit all properties from* `Point2D.prototype`. To check that, you can add a method named `move` into `Point2D.prototype` as follow: +As `Point2D` function is declared, a property named `prototype` will be created by default for it (note that, in JavaScript, a function is also a object). The `prototype` property is also a object which contains a `constructor` property and its value is `Point2D` function: `Point2D.prototype.constructor = Point2D`. And when you call `Point2D` with `new` keyword, *newly created objects will inherit all properties from* `Point2D.prototype`. To check that, you can add a method named `move` into `Point2D.prototype` as follow: ```javascript Point2D.prototype.move = function(dx, dy) { @@ -42,7 +42,8 @@ Built-in objects in JavaScript is constructed similar as above. For example: ### Prototype chain -The prototype chain mechanism is simple: When you access a property `p` on object `obj`, the JavaScript engine will search this property inside `obj` object. If the engine fail to search, it continues searching in prototype of `obj` object and so on until reach `Object.prototype`. As the search finished, if not found, the result will be `undefined`. For example: +The prototype chain mechanism is simple: When you access a property `p` on object `obj`, the JavaScript engine will search this property inside `obj` object. If the engine fails to search, it continues searching in the prototype of `obj` object and so on until reaching `Object.prototype`. If after the search has finished, and nothing has been found the result will be `undefined`. +For example: ```javascript var obj1 = { @@ -58,4 +59,4 @@ console.log(obj2.b); // 2 console.log(obj2.c); // undefined ``` -In above snippet, the statement `var obj2 = Object.create(obj1)` will create `obj2` object with prototype is `obj1` object. In other words, `obj1` becomes prototype of `obj2` instead of `Object.prototype` by default. As you see, though `b` is not a property of `obj2`, you can still access it by prototype chain. For `c` property, however, you get `undefined` value because it can't be found in `obj1` and `Object.prototype` as well. \ No newline at end of file +In above snippet, the statement `var obj2 = Object.create(obj1)` will create `obj2` object with prototype `obj1` object. In other words, `obj1` becomes the prototype of `obj2` instead of `Object.prototype` by default. As you can see, `b` is not a property of `obj2`, you can still access it via the prototype chain. For `c` property, however, you get `undefined` value because it can't be found in `obj1` and `Object.prototype`. From 86e9fe4c160c1eb98556ceb8017bdcba78760224 Mon Sep 17 00:00:00 2001 From: Jeff Thompson Date: Wed, 4 Oct 2017 17:44:00 -0500 Subject: [PATCH 03/89] Edit article Cleaned up a few sentences to make them read better and to be more grammatically correct . --- src/pages/css/class-selector/index.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pages/css/class-selector/index.md b/src/pages/css/class-selector/index.md index 803af05b0c3..d2570353315 100644 --- a/src/pages/css/class-selector/index.md +++ b/src/pages/css/class-selector/index.md @@ -2,7 +2,9 @@ title: Class Selector --- ## Class Selector -Class Selector is used in CSS file to apply style to HTML elements with corresponding class name. In HTML, we can set class name for elements by adding "class" attribute: +A Class Selector is used in a CSS file to apply style to the HTML elements with the corresponding class name. In HTML, we can set the class name for any element by adding a "class" attribute. + +Examples: ```html

This is a heading 1

This is a paragraph 1

@@ -10,7 +12,7 @@ Class Selector is used in CSS file to apply style to HTML elements with correspo

This is a paragraph 2

This is a div 1
``` -Since class name is not unique, the HTML class attribute makes it possible to define equal styles for elements with the same class name. **Here is how you can select class in CSS file to style elements (notice the . notation):** +Since class name is not unique, the HTML class attribute makes it possible to define equal styles for elements with the same class name. **Here is how you can select class in a CSS file to style elements (notice the . notation):** **All elements of class `test` will be applied with this style:** ```css From 2be541350e156b2516d3a72d06eb02d1207b4368 Mon Sep 17 00:00:00 2001 From: John Paul Ada Date: Thu, 5 Oct 2017 08:25:32 +0800 Subject: [PATCH 04/89] Added Tail Call Optimization Content --- .../tco-tail-call-optimization/index.md | 62 ++++++++++++++++--- 1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/src/pages/software-engineering/tco-tail-call-optimization/index.md b/src/pages/software-engineering/tco-tail-call-optimization/index.md index 656049630cb..fd90c64b731 100644 --- a/src/pages/software-engineering/tco-tail-call-optimization/index.md +++ b/src/pages/software-engineering/tco-tail-call-optimization/index.md @@ -1,15 +1,63 @@ --- -title: Tco Tail Call Optimization +title: TCO Tail Call Optimization --- -## Tco Tail Call Optimization +## Tail Call Optimization (TCO) -This is a stub. Help our community expand it. +Tail Call Optimization (**TCO**) is a solution to the problem of stack overflows when doing recursion. -This quick style guide will help ensure your pull request gets accepted. +### The Problem +Every call to a function is pushed to a stack in computer memory. When the function finishes, it is popped from the stack. In recursion, the function calls itself so it keeps on adding to the stack until all those functions finishes. There is, of course, a limit to this stack. When there are too many functions called, too many calls are added to the stack. When the stack is full and a function is called, this results in a **stack overflow** because the stack is already full. The recursive function will not finish and will result in an error. - +#### Example +Here is an example of a JavaScript factorial function using recursion **without** TCO: -#### More Information: - +```javascript + function fact(x) { + if (x <= 1) { + return 1; + } else { + return x * fact(x-1); + } + } + + console.log(fact(10)); // 3628800 + console.log(fact(10000)); // RangeError: Maximum call stack size exceeded +``` + +Notice that running `fact` with an argument of 10000 will result in a **stack overflow**. + +### Using TCO to solve the problem +To solve this using Tail Call Optimization, the statement where the function calls itself should be in a tail position. The tail position is the last statement to be executed in a function. Therefore, the function's call to itself should be the last thing called before the function ends. + +In the previous example, the multiplication operation is executed last in the `return x * fact(x-1)` statement, so it was not the final operation of the function. Therefore, it is not tail call optimized. In order for it to be tail call optimized, you need to make the call to itself the last operation of the function. + +#### Example +Here is an example of a JavaScript (ECMAScript 2015) factorial function using recursion **with** TCO: +```javascript + function fact(n) { + return factTCO(n, 1); + } + function factTCO(x, acc) { + if (x <= 1) { + return acc; + } else { + return factTCO(x-1, x*acc); + } + } + + console.log(fact(10)); // 3628800 + console.log(fact(10000)); // Infinity - Number too large, but unlike the unoptimized factorial, this does not result in stack overflow. +``` + +Notice that running `fact` on 10000 this time will **not result in a stack overflow** because the call to `factTCO` is the last operation of the function. + +### Why this works +When the compiler or interpreter notices that the self-call is the last operation of the function, it pops the current function and pushes the self-call to the stack. This way the size of the stack isn't changed. Therefore, the stack doesn't overflow because of the function. + +### Notes + +#### More Information: +- [What is tail call optmization?](https://stackoverflow.com/questions/310974/what-is-tail-call-optimization) (StackOverflow) +- [Tail call optimization in ECMAScript 6](http://2ality.com/2015/06/tail-call-optimization.html) (2ality - Dr. Axel Rauschmayer's blog) From 899f9a7477b8af49a06a27792930b346b3a2011b Mon Sep 17 00:00:00 2001 From: John Paul Ada Date: Thu, 5 Oct 2017 08:45:32 +0800 Subject: [PATCH 05/89] Added Basic Networking in C Stub --- src/pages/c/basic-networking/index.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/pages/c/basic-networking/index.md diff --git a/src/pages/c/basic-networking/index.md b/src/pages/c/basic-networking/index.md new file mode 100644 index 00000000000..59ced7d2800 --- /dev/null +++ b/src/pages/c/basic-networking/index.md @@ -0,0 +1,15 @@ +--- +title: Basic Networking +--- +## Basic Networking + +This is a stub. Help our community expand it. + +This quick style guide will help ensure your pull request gets accepted. + + + +#### More Information: + + + From a3123ff86d952ef2082e6433d77b1c1cdb0c9aa0 Mon Sep 17 00:00:00 2001 From: John Paul Ada Date: Thu, 5 Oct 2017 08:46:06 +0800 Subject: [PATCH 06/89] Added File Handling in C Stub --- src/pages/c/file-handling/index.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/pages/c/file-handling/index.md diff --git a/src/pages/c/file-handling/index.md b/src/pages/c/file-handling/index.md new file mode 100644 index 00000000000..776efcbc910 --- /dev/null +++ b/src/pages/c/file-handling/index.md @@ -0,0 +1,15 @@ +--- +title: File Handling +--- +## File Handling + +This is a stub. Help our community expand it. + +This quick style guide will help ensure your pull request gets accepted. + + + +#### More Information: + + + From 1a1dd74cafd2b6d2079588864411a9cd3d0b5791 Mon Sep 17 00:00:00 2001 From: Sridhar Easwaran Date: Thu, 5 Oct 2017 14:20:55 +0530 Subject: [PATCH 07/89] added Codewars to Challenges --- src/pages/java/resources/index.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/pages/java/resources/index.md b/src/pages/java/resources/index.md index c23019f9be5..1aef4af4b37 100644 --- a/src/pages/java/resources/index.md +++ b/src/pages/java/resources/index.md @@ -31,6 +31,7 @@ Java is trademarked and licensed by Oracle. Most of the following are un-officia * Excercism Java Challenges * Project Euler * Practice It! - Java Challenges +* Codewars - Java Katas ## Community @@ -39,4 +40,4 @@ Java is trademarked and licensed by Oracle. Most of the following are un-officia * /r/Java * /r/LearnJava * Java Ranch -* Java Code Geeks \ No newline at end of file +* Java Code Geeks From 32f152ecf1e5e27c0f59da02efe980ada8721567 Mon Sep 17 00:00:00 2001 From: Vikram Bahl Date: Fri, 6 Oct 2017 11:07:15 +0800 Subject: [PATCH 08/89] add information on social engineering added definition, info and links on social engineering hack --- .../security/social-engineering/index.md | 26 ++++++++++++++++--- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/src/pages/security/social-engineering/index.md b/src/pages/security/social-engineering/index.md index 3e882e0155e..4f21ddd2ab0 100644 --- a/src/pages/security/social-engineering/index.md +++ b/src/pages/security/social-engineering/index.md @@ -3,13 +3,31 @@ title: Social Engineering --- ## Social Engineering -This is a stub. Help our community expand it. +Social Engineering is the art of gaining access to a secured system or resource by exploiting human behavior. It involves tricking people into breaking normal security procedures. Most attack vectors rely heavily on leveraging technical skills to find gaps in the security system. Social Engineering relies heavily on having a good understanding of human psychology. Thoroughly researching the target weeks before an attack makes social engineering a powerful tool in the hands of the attacker. + +#### Traits of a good Social Engineering Hacker + +* Demonstrates high emotional intelligence +* Intuitive understanding of human psychology +* Charming and persuasive +* Patient and observant +* Adept at predicting human behavior based on exploiting our need to be helpful, curious, greedy and vane + +#### Some examples of Social Engineering hacks + +* Baiting: Leaving a malware infected USB at a coffee shop in the hope that someone is curious enough to plug it in and check it out. Once the person plugs the USB in, malware is installed on their computer + +* Pretexting: Telling lies to gain access to private information. For eg, pretending to be a bank officer and ask people for personal information to 'confirm their account'. + +* Phishing: Send an email which looks like it is from a trusted source to bait the user into clicking a link (to install malware) or replying with private information. -This quick style guide will help ensure your pull request gets accepted. - #### More Information: - +Read on more information on social engineering hacks and steps you can take to protct yourself from one: +[What is Social Engineering?](https://www.webroot.com/us/en/home/resources/tips/online-shopping-banking/secure-what-is-social-engineering) +[Protect yourself Social Engineering attacks](http://www.makeuseof.com/tag/protect-8-social-engineering-attacks/) +[7 best Social Engineering hacks](https://www.darkreading.com/the-7-best-social-engineering-attacks-ever/d/d-id/1319411?) + From b545f9b308adf6cd5a4c7cb7add9d0b822ed6ffd Mon Sep 17 00:00:00 2001 From: Stephanie Date: Fri, 6 Oct 2017 14:37:10 -0600 Subject: [PATCH 09/89] Added article for Body tag --- src/pages/html/elements/body/index.md | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/pages/html/elements/body/index.md b/src/pages/html/elements/body/index.md index 5a7119dbd05..1fa5f246634 100644 --- a/src/pages/html/elements/body/index.md +++ b/src/pages/html/elements/body/index.md @@ -2,14 +2,22 @@ title: Body --- ## Body - -This is a stub. Help our community expand it. - -This quick style guide will help ensure your pull request gets accepted. - +

The <body> tag contains the content for a webpage. Along with <head>, it is one of the two required elements of an HTML document. <body> must be the second child of an <html> element. There can only be one <body> element on a page. +The <body> element should contain all of a page's content, including all display elements. The <body> element can also contain <script> tags, generally scripts that must be run after a page's content has been loaded. + + ```html + + + Document Titles Belong in the Head + + +

This paragraph is content. It goes in the body!

+ + + ``` #### More Information: - + MDN article on <body> From 4fef999dd294d226e14bdd250397f346b6eaa597 Mon Sep 17 00:00:00 2001 From: Nick Cleary Date: Fri, 6 Oct 2017 18:16:47 -0400 Subject: [PATCH 10/89] Fixed thought bubble Fixed an issue where the third thought bubble was no appearing, rather having "![:speech_balloon:" appear in its place --- src/pages/certificates/symmetric-difference/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/certificates/symmetric-difference/index.md b/src/pages/certificates/symmetric-difference/index.md index 2d5f05a904e..681a1197a0a 100644 --- a/src/pages/certificates/symmetric-difference/index.md +++ b/src/pages/certificates/symmetric-difference/index.md @@ -32,7 +32,7 @@ Write a function that returns the symmetric difference of the two arrays: `yourF > _try to solve the problem now_ -## ![:speech_balloon: Hint: 3 +## ![:speech_balloon:](https://forum.freecodecamp.com/images/emoji/emoji_one/speech_balloon.png?v=3 ":speech_balloon:") Hint: 3 Use `Array.prototype.reduce` along with `yourFunction` to repeat the process on multiple arguments @@ -197,4 +197,4 @@ Something strange about the definition of symmetric difference is that if one id * Categorize the solution in one of the following categories — **Basic**, **Intermediate** and **Advanced**. ![:traffic_light:](https://forum.freecodecamp.com/images/emoji/emoji_one/traffic_light.png?v=3 ":traffic_light:") * Please add your username only if you have added any **relevant main contents**. (![:warning:](https://forum.freecodecamp.com/images/emoji/emoji_one/warning.png?v=3 ":warning:") **_DO NOT_** _remove any existing usernames_) -> See ![:point_right:](https://forum.freecodecamp.com/images/emoji/emoji_one/point_right.png?v=3 ":point_right:") **`Wiki Challenge Solution Template`** for reference. \ No newline at end of file +> See ![:point_right:](https://forum.freecodecamp.com/images/emoji/emoji_one/point_right.png?v=3 ":point_right:") **`Wiki Challenge Solution Template`** for reference. From 6fc53c66cc19392169be9963dfe26209a75581d5 Mon Sep 17 00:00:00 2001 From: LW001 <24354260+LW001@users.noreply.github.com> Date: Sat, 7 Oct 2017 00:40:33 +0200 Subject: [PATCH 11/89] README Grammar fixes --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 583f7a02208..3051bf04a85 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ This repo is where we plan and maintain these Guide articles, which we then host - [License](#license) ## What are Guide articles? -Guide articles can be an explanation of a syntax, design pattern, what aria labels are for, or something like what the numbers mean in the top right hand corner of your screen when at freecodecamp.org. You can find an [example article about HTML Elements here](./src/pages/html/elements/index.md). +Guide articles can be an explanation of a syntax, design pattern, what aria labels are for, or something like what the numbers mean in the top right-hand corner of your screen when at freecodecamp.org. You can find an [example article about HTML Elements here](./src/pages/html/elements/index.md). ## What can I write an article about? We welcome your help writing these articles. You don't have to be an expert in a topic to write about it - this entire Guide is open source, so even if you make a mistake, another contributor will eventually correct it. @@ -173,7 +173,7 @@ Here are specific formatting guidelines for any code: ### Adding images to articles -For including images, if the images aren't already hosted somewhere else on the web, you'll need to put them online yourself. A good way to do this is to commit them to a GitHub repository of your own, then push them to GitHub. Then you can right click the image and copy its image source. +For including images, if the images aren't already hosted somewhere else on the web, you'll need to put them online yourself. A good way to do this is to commit them to a GitHub repository of your own, then push them to GitHub. Then you can right-click the image and copy its image source. Then you'd just need to reference them in your markdown file with this syntax: From c02fa4afcca483f914df7d969ee19961c271af0d Mon Sep 17 00:00:00 2001 From: Sayan Goswami Date: Sat, 7 Oct 2017 11:46:06 +0530 Subject: [PATCH 12/89] Move to `variable` directory --- src/pages/cplusplus/{variable.md => variables/index.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/pages/cplusplus/{variable.md => variables/index.md} (100%) diff --git a/src/pages/cplusplus/variable.md b/src/pages/cplusplus/variables/index.md similarity index 100% rename from src/pages/cplusplus/variable.md rename to src/pages/cplusplus/variables/index.md From b7d677fcda0941c9b0607166ba9b65bd42dfb13f Mon Sep 17 00:00:00 2001 From: Njoku Ugochukwu Godson Date: Sat, 7 Oct 2017 08:48:45 +0100 Subject: [PATCH 13/89] Added an article on Integrated Development Environments (IDEs). also included a link for users to learn more on IDEs. --- .../index.md | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/pages/developer-tools/ide-integrated-development-environments/index.md b/src/pages/developer-tools/ide-integrated-development-environments/index.md index f5dc3fbd95a..3b6208c8eed 100644 --- a/src/pages/developer-tools/ide-integrated-development-environments/index.md +++ b/src/pages/developer-tools/ide-integrated-development-environments/index.md @@ -1,15 +1,8 @@ --- title: IDE Integrated Development Environments --- -## IDE Integrated Development Environments - -This is a stub. Help our community expand it. - -This quick style guide will help ensure your pull request gets accepted. - - - -#### More Information: - - +## Integrated Development Environments (IDEs) +

An Integrated Development Environment (IDE) is a software suite that consolidates the basic tools developers need to write and test software. IDEs are designed to encompass all programming tasks in one application.

+

Therefore, IDEs offer a central interface featuring all the tools a developer needs, including the following: a code editor, a compiler or interpreter, a debugger and build automation tools (these tools automate common developer tasks.) that the developer accesses through a single graphical user interface (GUI).The IDE may be a stand-alone application or may be included as part of one or more compatible applications.

+

Additional resources to check out on IDEs here.

From 241d3ee44cd2431ce5137ce8740949826021be04 Mon Sep 17 00:00:00 2001 From: pranabendra <30474395+pranabendra@users.noreply.github.com> Date: Mon, 9 Oct 2017 09:28:33 +0530 Subject: [PATCH 14/89] Complementary Angles - Added my changes --- .../mathematics/complementary-angles/index.md | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/pages/mathematics/complementary-angles/index.md b/src/pages/mathematics/complementary-angles/index.md index 366d5658d4e..cadeab67c90 100644 --- a/src/pages/mathematics/complementary-angles/index.md +++ b/src/pages/mathematics/complementary-angles/index.md @@ -1,15 +1,21 @@ --- title: Complementary Angles --- -## Complementary Angles +# Complementary Angles -This is a stub. Help our community expand it. +## Definition -This quick style guide will help ensure your pull request gets accepted. +Two angles which sum up to 90°, are called complementary angles. - -#### More Information: - +![](https://raw.githubusercontent.com/pranabendra/articles/master/Complementary-angles/comp1.png) +Complementary angles don't have to be next to each other, just so long as the total is 90°. +### For Example : + +In the above figures, diagrams `a.` and `b.` show that the complementary angles are adjacent, whereas in `c.` and `d.`, the complementary angles are not adjacent. + +## More Information: + +Complementary Angles From 6dea33312fc2cce0532fb9b54bed22730c71d95a Mon Sep 17 00:00:00 2001 From: arcdev1 Date: Mon, 9 Oct 2017 13:35:22 -0400 Subject: [PATCH 15/89] Dev mastery/developer ethics content (#809) * Added definition, samples, and references * Added description and listing of Dark Patterns * Added short descriptions of each dark pattern. * Reformatted list of examples * Formatting tweaks * Added listing of hypothetical case studies sourced from The Software Engineering Ethics Research Institute of the Department of Computer and Information Sciences at East Tenesee State University. * Clarified definition * moved "more information" into body. * drafted content on ethical breaches * post-commit --- src/pages/agile/extreme-programming/index.md | 6 ++-- .../agile/test-driven-development/index.md | 8 ++--- src/pages/agile/the-agile-manifesto/index.md | 2 +- .../algorithms/sorting-algorithms/index.md | 2 +- .../sorting-algorithms/quick-sort/index.md | 2 +- .../bootstrap-glyphicon-components/index.md | 6 ++-- src/pages/bootstrap/index.md | 6 ++-- src/pages/cloud-development/index.md | 2 +- .../computer-hardware/motherboard/index.md | 2 +- src/pages/computer-hardware/ram/index.md | 6 ++-- .../data-structures/stacks/index.md | 2 +- .../computer-science/databases/acid/index.md | 4 +-- .../computer-science/what-is-an-api/index.md | 10 +++--- src/pages/css/class-selector/index.md | 2 +- .../css/css3-borders-rounded-corners/index.md | 4 +-- src/pages/css/padding/index.md | 10 +++--- .../background-color-property/index.md | 2 +- .../designer-tools/Experience-design/index.md | 10 +++--- .../developer-ethics/case-studies/index.md | 27 ++++++++++++++ .../developer-ethics/dark-patterns/index.md | 32 +++++++++++++++++ .../ethical-breaches/index.md | 18 ++++++++++ src/pages/developer-ethics/index.md | 35 ++++++++++++++++--- .../the-programmers-oath/index.md | 2 +- .../attributes/script-src-attribute/index.md | 2 +- .../html/block-and-inline-elements/index.md | 2 +- .../array/array-prototype-foreach/index.md | 2 +- .../window-setinterval-method/index.md | 6 ++-- .../window-settimeout-method/index.md | 4 +-- src/pages/jquery/jquery-css-method/index.md | 2 +- .../machine-learning/random-forest/index.md | 4 +-- .../python/data-structures/objects/index.md | 2 +- .../python/data-structures/ranges/index.md | 2 +- src/pages/python/string-strip-method/index.md | 2 +- src/pages/ruby/ruby-arrays/index.md | 2 +- src/pages/tools/color-picker/index.md | 6 ++-- src/pages/typography/ems-and-ens/index.md | 4 +-- .../visual-design/visual-hierarchy/index.md | 3 +- 37 files changed, 174 insertions(+), 69 deletions(-) create mode 100644 src/pages/developer-ethics/case-studies/index.md create mode 100644 src/pages/developer-ethics/dark-patterns/index.md create mode 100644 src/pages/developer-ethics/ethical-breaches/index.md diff --git a/src/pages/agile/extreme-programming/index.md b/src/pages/agile/extreme-programming/index.md index 0c26139b289..9d169314420 100644 --- a/src/pages/agile/extreme-programming/index.md +++ b/src/pages/agile/extreme-programming/index.md @@ -3,13 +3,13 @@ title: Extreme Programming --- ## Extreme Programming -Extreme programming (XP) is a software development methodology which is intended to improve software quality and responsiveness to changing customer requirements.[1](https://en.wikipedia.org/wiki/Extreme_programming) +Extreme programming (XP) is a software development methodology which is intended to improve software quality and responsiveness to changing customer requirements.1 -The basic advantage of XP is that the whole process is visible and accountable. The developers will make concrete commitments about what they will accomplish, show concrete progress in the form of deployable software, and when a milestone is reached they will describe exactly what they did and how and why that differed from the plan. This allows business-oriented people to make their own business commitments with confidence, to take advantage of opportunities as they arise, and eliminate dead-ends quickly and cheaply.[2](http://wiki.c2.com/?ExtremeProgramming) +The basic advantage of XP is that the whole process is visible and accountable. The developers will make concrete commitments about what they will accomplish, show concrete progress in the form of deployable software, and when a milestone is reached they will describe exactly what they did and how and why that differed from the plan. This allows business-oriented people to make their own business commitments with confidence, to take advantage of opportunities as they arise, and eliminate dead-ends quickly and cheaply.2 -- Kent Beck XP-feedback #### More Information: -[Rules of Extreme Programming](http://www.extremeprogramming.org/rules.html) +Rules of Extreme Programming diff --git a/src/pages/agile/test-driven-development/index.md b/src/pages/agile/test-driven-development/index.md index 2610a8ccb28..91d7e08bdf0 100644 --- a/src/pages/agile/test-driven-development/index.md +++ b/src/pages/agile/test-driven-development/index.md @@ -20,11 +20,11 @@ Each new feature of your system should follow the steps above. #### More Information: -Agile Data's [Introduction to TDD](http://agiledata.org/essays/tdd.html) +Agile Data's Introduction to TDD -Wiki on [TDD](https://en.wikipedia.org/wiki/Test-driven_development) +Wiki on TDD -Martin Fowler [Is TDD Dead?](https://martinfowler.com/articles/is-tdd-dead/) +Martin Fowler Is TDD Dead? (A series of recorded conversations on the subject) - Kent Beck's book [Test Driven Development by Example](https://www.amazon.com/Test-Driven-Development-Kent-Beck/dp/0321146530) + Kent Beck's book Test Driven Development by Example diff --git a/src/pages/agile/the-agile-manifesto/index.md b/src/pages/agile/the-agile-manifesto/index.md index cfa63548752..c5ad15029ea 100644 --- a/src/pages/agile/the-agile-manifesto/index.md +++ b/src/pages/agile/the-agile-manifesto/index.md @@ -13,4 +13,4 @@ Manifesto for agile software development: #### More Information: -[Agile Manifesto](http://agilemanifesto.org/) +Agile Manifesto diff --git a/src/pages/algorithms/sorting-algorithms/index.md b/src/pages/algorithms/sorting-algorithms/index.md index 060997c350f..23744de5dc7 100644 --- a/src/pages/algorithms/sorting-algorithms/index.md +++ b/src/pages/algorithms/sorting-algorithms/index.md @@ -30,7 +30,7 @@ Sorting algorithms can be categorized based on the following parameters: This is the number of times the algorithm swaps elements to sort the input. `Selection Sort` requires the minimum number of swaps. 2. Based on Number of Comparisons -This is the number of times the algorithm compares elements to sort the input. Using [Big-O notation](https://guide.freecodecamp.org/computer-science/notation/big-o-notation/), the sorting algorithm examples listed above require at least `O(nlogn)` comparisons in the best case and `O(n^2)` comparisons in the worst case for most of the outputs. +This is the number of times the algorithm compares elements to sort the input. Using Big-O notation, the sorting algorithm examples listed above require at least `O(nlogn)` comparisons in the best case and `O(n^2)` comparisons in the worst case for most of the outputs. 3. Based on Recursion or Non-Recursion Some sorting algorithms, such as `Quick Sort`, use recursive techniques to sort the input. Other sorting algorithms, such as `Selection Sort` or `Insertion Sort`, use non-recursive techniques. Finally, some sorting algorithm, such as `Merge Sort`, make use of both recursive as well as non-recursive techniques to sort the input. diff --git a/src/pages/algorithms/sorting-algorithms/quick-sort/index.md b/src/pages/algorithms/sorting-algorithms/quick-sort/index.md index f63d1c1b24d..bed38483277 100644 --- a/src/pages/algorithms/sorting-algorithms/quick-sort/index.md +++ b/src/pages/algorithms/sorting-algorithms/quick-sort/index.md @@ -56,4 +56,4 @@ vector quick_sort(vector arr) { #### More Information: -- [Wikipedia](https://en.wikipedia.org/wiki/Quicksort) +- Wikipedia diff --git a/src/pages/bootstrap/bootstrap-glyphicon-components/index.md b/src/pages/bootstrap/bootstrap-glyphicon-components/index.md index 9dc39a2d62e..0bd588e818e 100644 --- a/src/pages/bootstrap/bootstrap-glyphicon-components/index.md +++ b/src/pages/bootstrap/bootstrap-glyphicon-components/index.md @@ -16,11 +16,11 @@ Use glyphicons in text, navigation, buttons, forms, or toolbars. ``` ## Note -Bootstrap 4 dropped Glyphicons. You can use [Font Awesome Icons](http://fontawesome.io/icons/) instead. +Bootstrap 4 dropped Glyphicons. You can use Font Awesome Icons instead. #### More Information: -[Official Bootstrap 3 docs on Glyphicons](https://getbootstrap.com/docs/3.3/components/#glyphicons) -[Glyphicons official website](https://glyphicons.com/) +Official Bootstrap 3 docs on Glyphicons +Glyphicons official website diff --git a/src/pages/bootstrap/index.md b/src/pages/bootstrap/index.md index 897b328bb4f..a6fe7355a40 100644 --- a/src/pages/bootstrap/index.md +++ b/src/pages/bootstrap/index.md @@ -42,11 +42,11 @@ Or, alternatively, you can download all of Bootstraps source files including Sas `bower install bootstrap#v4.0.0-beta` -(These are examples. You may want to check the [Bootstrap website](https://getbootstrap.com/) for the most up-to-date links) +(These are examples. You may want to check the Bootstrap website for the most up-to-date links) #### More Information: -Bootstrap has thorough documentation with many [examples](https://getbootstrap.com/docs/4.0/examples/) and an [HTML template for getting started](https://getbootstrap.com/docs/4.0/getting-started/introduction/). +Bootstrap has thorough documentation with many examples and an HTML template for getting started. -In addition, you can find both [free](https://bootswatch.com/) and [paid](https://themes.getbootstrap.com/) +In addition, you can find both free and paid themes that build on the Bootstrap framework to provide a more customized and stylish look. diff --git a/src/pages/cloud-development/index.md b/src/pages/cloud-development/index.md index b9ae88a7a62..dbccdd885d4 100644 --- a/src/pages/cloud-development/index.md +++ b/src/pages/cloud-development/index.md @@ -3,7 +3,7 @@ title: Cloud Development --- ## Cloud Development -This is a stub. Help our community expand it. +This is a stub. Help our community expand it. This quick style guide will help ensure your pull request gets accepted. diff --git a/src/pages/computer-hardware/motherboard/index.md b/src/pages/computer-hardware/motherboard/index.md index a9e70dc706e..12959a70079 100644 --- a/src/pages/computer-hardware/motherboard/index.md +++ b/src/pages/computer-hardware/motherboard/index.md @@ -9,6 +9,6 @@ A motherboard provides power and connectivity to the computer's components, and #### More Information: -* [Motherboard](https://www.computerhope.com/jargon/m/mothboar.htm) +* Motherboard diff --git a/src/pages/computer-hardware/ram/index.md b/src/pages/computer-hardware/ram/index.md index 9d6adc2b2cc..ee388eab2f1 100644 --- a/src/pages/computer-hardware/ram/index.md +++ b/src/pages/computer-hardware/ram/index.md @@ -4,7 +4,7 @@ title: RAM ## RAM RAM stands for random-access memory, alternatively referred to as **main memory**, **primary memory**, or **system memory** is a computer hardware where the data that your computer is currently working on is stored.
-Unlike hard drives RAM is a volatile memory and requires power to keep the data accessible. If the computer is turned off, all data contained in RAM is lost. New users often confuse RAM with disk drive space. See [memory](https://www.computerhope.com/jargon/m/memory.htm) definition for a comparison between memory and storage.
+Unlike hard drives RAM is a volatile memory and requires power to keep the data accessible. If the computer is turned off, all data contained in RAM is lost. New users often confuse RAM with disk drive space. See memory definition for a comparison between memory and storage.
#### Types of RAM: Over the evolution of the computer there have been different variations of RAM. Some of the more common examples are DIMM, RIMM, SIMM, SO-DIMM, and SOO-RIMM. Below is an example image of a 512 MB DIMM computer memory module, a typical piece of RAM found in desktop computers. This memory module would be installed into one of the memory slots on a motherboard. @@ -17,7 +17,7 @@ The speed rating of your RAM module is an expression of its data transfer rate. #### More Information: -* [RAM](http://www.webopedia.com/TERM/R/RAM.html). -* [Types of RAM](http://www.computermemoryupgrade.net/types-of-computer-memory-common-uses.html). +* RAM. +* Types of RAM. diff --git a/src/pages/computer-science/data-structures/stacks/index.md b/src/pages/computer-science/data-structures/stacks/index.md index 732c0087ca0..b4dad7c33e4 100644 --- a/src/pages/computer-science/data-structures/stacks/index.md +++ b/src/pages/computer-science/data-structures/stacks/index.md @@ -3,7 +3,7 @@ title: Stacks --- ## Stacks -This is a stub. Help our community expand it. +This is a stub. Help our community expand it. This quick style guide will help ensure your pull request gets accepted. diff --git a/src/pages/computer-science/databases/acid/index.md b/src/pages/computer-science/databases/acid/index.md index 944b5bc29bb..e91418941bb 100644 --- a/src/pages/computer-science/databases/acid/index.md +++ b/src/pages/computer-science/databases/acid/index.md @@ -19,5 +19,5 @@ This means that if two transactions execute at the same time, one transaction ca This means that once a transaction is complete, it will remain so, even in the event of a power loss or other errors. It guarantees that all of the changes are recorded to a non-volatile storage medium (such as a hard disk), and it makes a record of the completed transaction. ### More Information: -- ACID article: [Wikipedia](https://en.wikipedia.org/wiki/ACID) -- Video overview: [YouTube](https://www.youtube.com/watch?v=LSB4eceRsw8) +- ACID article: Wikipedia +- Video overview: YouTube diff --git a/src/pages/computer-science/what-is-an-api/index.md b/src/pages/computer-science/what-is-an-api/index.md index 2443224eb4e..6f030ebc7fb 100644 --- a/src/pages/computer-science/what-is-an-api/index.md +++ b/src/pages/computer-science/what-is-an-api/index.md @@ -1,7 +1,7 @@ --- -title: What Is an API +title: What Is an Api --- -## What Is an API +## What Is an Api This is a stub. Help our community expand it. @@ -9,7 +9,7 @@ This is a stub. Medium diff --git a/src/pages/css/class-selector/index.md b/src/pages/css/class-selector/index.md index 803af05b0c3..03ac9dcf561 100644 --- a/src/pages/css/class-selector/index.md +++ b/src/pages/css/class-selector/index.md @@ -39,6 +39,6 @@ h1.test, h2.test { ``` **Tips: No space between multiple classes.** #### More Information: -CSS Syntax and Selectors: [w3school](https://www.w3schools.com/css/css_syntax.asp) +CSS Syntax and Selectors: w3school diff --git a/src/pages/css/css3-borders-rounded-corners/index.md b/src/pages/css/css3-borders-rounded-corners/index.md index 8ed7decf951..db8a4a6704d 100644 --- a/src/pages/css/css3-borders-rounded-corners/index.md +++ b/src/pages/css/css3-borders-rounded-corners/index.md @@ -19,5 +19,5 @@ With CSS3, you can give any element "rounded corners", by using the `border-radi ### More Information: -- MDN Documentation: [MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/border-radius) -- Browser Support: [caniuse](http://caniuse.com/#search=border-radius) +- MDN Documentation: MDN +- Browser Support: caniuse diff --git a/src/pages/css/padding/index.md b/src/pages/css/padding/index.md index a523f9ea910..63b34dc9738 100644 --- a/src/pages/css/padding/index.md +++ b/src/pages/css/padding/index.md @@ -44,8 +44,8 @@ The padding property in CSS defines the innermost portion of the box model, crea It is effectively supported in all browsers (since IE6+, Firefox 2+, Chrome 1+ etc) ### More Information -- [W3C Working Draft](https://www.w3.org/TR/css3-box/#the-padding) -- [W3C CSS Level 2](https://www.w3.org/TR/CSS2/box.html#propdef-padding) -- [W3C CSS Level 1](https://www.w3.org/TR/CSS1/#padding) -- [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/CSS/padding) -- [CSS Tricks](https://css-tricks.com/almanac/properties/p/padding/) +- W3C Working Draft +- W3C CSS Level 2 +- W3C CSS Level 1 +- MDN Web Docs +- CSS Tricks diff --git a/src/pages/css/properties/background-color-property/index.md b/src/pages/css/properties/background-color-property/index.md index 9e8792f0d01..cf1758b5cac 100644 --- a/src/pages/css/properties/background-color-property/index.md +++ b/src/pages/css/properties/background-color-property/index.md @@ -34,6 +34,6 @@ div { `inherit` - Inherits this property from its parent element. #### More Information: -[MDN web docs](https://developer.mozilla.org/en-US/docs/Web/CSS/background-color?v=b) +MDN web docs diff --git a/src/pages/designer-tools/Experience-design/index.md b/src/pages/designer-tools/Experience-design/index.md index c9ba3b472a1..7e10dd6bc1c 100644 --- a/src/pages/designer-tools/Experience-design/index.md +++ b/src/pages/designer-tools/Experience-design/index.md @@ -22,12 +22,12 @@ Adobe Experience Design, also known as Adobe XD, is a prototyping tool for UX de #### More Information: -Official Website: [Adobe](https://www.adobe.com/in/products/experience-design.html) +Official Website: Adobe -XD Guru: [xdguru.com](https://www.xdguru.com/) +XD Guru: xdguru.com -Adobe XD vs Sketch: [Sitepoint](https://www.sitepoint.com/adobe-xd-sketch-will-result-best-ux/) +Adobe XD vs Sketch: Sitepoint -Why Prototyping with Adobe XD is the Most-Complete Design Solution: [Sitepoint](https://www.sitepoint.com/prototyping-with-adobe-xd/) +Why Prototyping with Adobe XD is the Most-Complete Design Solution: Sitepoint -And here's a playlist of 36 videos to help you get started in Adobe XD: [Youtube](https://youtu.be/HqQtYIMnWhM) +And here's a playlist of 36 videos to help you get started in Adobe XD: Youtube diff --git a/src/pages/developer-ethics/case-studies/index.md b/src/pages/developer-ethics/case-studies/index.md new file mode 100644 index 00000000000..ab19ffe1111 --- /dev/null +++ b/src/pages/developer-ethics/case-studies/index.md @@ -0,0 +1,27 @@ +--- +title: Case Studies +--- +## Case Studies + +The Software Engineering Ethics Research Institute of the Department of Computer and Information Sciences at East Tenesee State University published a series of Case Studies to help sensitize practicing software developers and students to the various types of ethical dilemmas they may face. [The International Standard for Professional Software +Development and Ethical Responsibility] (http://seeri.etsu.edu/TheSECode.htm) forms the basis for much of the analysis in each case. + +Cases: + +* [**Big Brother Spyware**] (http://seeri.etsu.edu/SECodeCases/ethicsC/BigBrother.htm) – Raises the issues of the tension between privacy, security, and whistle blowing in a post 11 September environment. + +* [**Computerized Patient Records**] (http://seeri.etsu.edu/SECodeCases/ethicsC/Computerized%20Patient%20Records.htm) – The case uses patient records to examine the developer’s responsibility for information security. It evaluates a series of alternatives. + +* [**Death By Wire**] (http://seeri.etsu.edu/SECodeCases/ethicsC/DeathByWire.htm) – The case address issues that arise from the shift of control from mechanically based systems to purely electronic/computer systems. It explores a situation where this process has been extended to heavy vehicles. It also looks at what happens when control of safety critical equipments is turned over to a computer. + +* [**Digital Wallets and Whistle Blowing**] (http://seeri.etsu.edu/SECodeCases/ethicsC/DigitalWallets.htm) – This is based on a real case involving security and includes an analysis of the decision related to when and how to whistle blow. + +* [**For Girls Only**] (http://seeri.etsu.edu/SECodeCases/ethicsC/ForGirlsOnly.htm) – This case looks at a real case of gender bias in the development of software. + +* [**Nano-Technology: Swallow That Chip**] (http://seeri.etsu.edu/SECodeCases/ethicsC/NanoTechnology.htm) – This case uses the vehicle of nano-technology to explore ways to address privacy and security issues that face software developers... + +* [**Patriot Missile Case**] (http://seeri.etsu.edu/SECodeCases/ethicsC/PatriotMissile.htm) – This piece examines the importance of configuration management and effective design as they relate to the Patriot Missile Disaster. + +-- +#### More Information +Additional information is available through the [Software Engineering Ethics Research Institute] (http://seeri.etsu.edu) \ No newline at end of file diff --git a/src/pages/developer-ethics/dark-patterns/index.md b/src/pages/developer-ethics/dark-patterns/index.md new file mode 100644 index 00000000000..8a8f3022a23 --- /dev/null +++ b/src/pages/developer-ethics/dark-patterns/index.md @@ -0,0 +1,32 @@ +--- +title: Dark Patterns +--- +## Dark Patterns + +Dark Patterns are common patterns used to deceive the users of a website or web application. + +Examples include: + +* **Bait and Switch** – A user sets out to do one thing, but a different, undesirable thing happens instead. + +* [**Disguised Ads**] (https://darkpatterns.org/types-of-dark-pattern/disguised-ads) – Adverts disguised as other kinds of content or navigation, in order to get users to click on them. + +* [**Forced Continuity**] (https://darkpatterns.org/types-of-dark-pattern/forced-continuity) – Silently charging a user's credit card without warning at the end of a free trial. + +* [**Friend Spam**] (https://darkpatterns.org/types-of-dark-pattern/friend-spam) – A website or app asks for a user's email or social media permissions under the pretence it will be used for a desirable outcome (e.g. finding friends), but then spams all the user's contacts in a message that claims to be from that user. + +* [**Hidden Costs**] (https://darkpatterns.org/types-of-dark-pattern/hidden-costs) – At the last step of a checkout process, only to discover some unexpected charges appear, e.g. delivery charges, tax, etc. that were not disclosed prior to processing the user's payment. + +* [**Misdirection**] (https://darkpatterns.org/types-of-dark-pattern/misdirection) – The design purposefully focuses a users' attention on one thing in order to distract their attention from another. + +* [**Price Comparison Prevention**] (https://darkpatterns.org/types-of-dark-pattern/price-comparison-prevention) – An online retailer makes it hard for visitor's to compare the price of an item with another item, so they cannot make an informed decision. + +* [**Privacy Zuckering**] (https://darkpatterns.org/types-of-dark-pattern/privacy-zuckering) – Users are tricked into publicly sharing more information about themselves than they really intended to. Named after Facebook CEO Mark Zuckerberg. + +* [**Roach Motel**] (https://darkpatterns.org/types-of-dark-pattern/roach-motel) – The design makes it very easy for users to get into a certain situation, but then makes it hard for them to get out of it (e.g. a subscription). + +* [**Sneak Into Basket**] (https://darkpatterns.org/types-of-dark-pattern/sneak-into-basket) – A user attempts to purchase something, but somewhere in the purchasing journey the site sneaks an additional item into their basket, often through the use of an opt-out radio button or checkbox on a prior page. + +* [**Trick Questions**] (https://darkpatterns.org/types-of-dark-pattern/trick-questions) – Users are made to respond to a question, which, when glanced upon quickly appears to ask one thing, but if read carefully, asks another thing entirely. + +A catalog of Dark Patterns along with a continuously updated list of real-world examples is mainatained at [darkpatterns.org] (https://darkpatterns.org). \ No newline at end of file diff --git a/src/pages/developer-ethics/ethical-breaches/index.md b/src/pages/developer-ethics/ethical-breaches/index.md new file mode 100644 index 00000000000..aaeb24cd570 --- /dev/null +++ b/src/pages/developer-ethics/ethical-breaches/index.md @@ -0,0 +1,18 @@ +--- +title: Ethical Breaches +--- +## Ethical Breaches + +There have been a number of well publicized cases in which software was used to deceive users or even break the law. At the heart of these cases is a breach of ethics on the part of one or more developers. Such cases include: + +* [**Uber Greyball**] (http://www.businessinsider.com/uber-greyball-app-vtos-authorities-2017-3?op=1) – a tool created by ride-sharing company Uber that collected data from Uber's app to identify and evade officials in multiple cities. + +* [**Volkswagon Emission Scandal**] (https://en.wikipedia.org/wiki/Volkswagen_emissions_scandal) – Volkswagen intentionally programmed turbocharged direct injection (TDI) diesel engines to activate some emissions controls only during laboratory emissions testing. The programming caused the vehicles' nitrogen oxide output to meet US standards during regulatory testing but emit up to 40 times more nitrogen oxide in real-world driving. + +* [**Zenefits Insurance Violations**] (http://www.techwire.net/news/zenefits-fined-7-million-for-california-insurance-violations.html) – Former Zenefits CEO, Parker Conrad, crafted a browser extension that allowed its brokers to fake that they had completed a required 52-hour online training course that insurance agents must take to become licensed in California. + +-- +#### More Information + What do Uber, Volkswagen and Zenefits have in common? They all used hidden code to break the law. +[10+ things you can do to avoid ethical breaches] (http://www.techrepublic.com/blog/10-things/10-plus-things-you-can-do-to-avoid-ethical-breaches/) +[Programmers are having a huge discussion about the unethical and illegal things they’ve been asked to do] (http://uk.businessinsider.com/programmers-confess-unethical-illegal-tasks-asked-of-them-2016-11?op=1) \ No newline at end of file diff --git a/src/pages/developer-ethics/index.md b/src/pages/developer-ethics/index.md index 53fe1761296..ec50319b278 100644 --- a/src/pages/developer-ethics/index.md +++ b/src/pages/developer-ethics/index.md @@ -3,10 +3,37 @@ title: Developer Ethics --- ## Developer Ethics -In this section, we'll have guides to a wide variety of concepts related to developer ethics. These include ethical frameworks like Uncle Bob Martin's "The Programmer's Oath." +Developer Ethics describes the field of ethics as it is applied to the behavior of software developers. - +According to The Internet Encyclopedia of Philosophy, the field of ethics (or moral philosophy) involves "systematizing, defending, and recommending concepts of right and wrong." -We will expand this section to include philosophical arguments, such as those addressed in Bill Sourour's The code I’m still ashamed of. +Over the years a number of organizations and individuals have attempted to codify developer ethics into a variety of oaths, pledges, and codes of conduct. -We will also include case studies of famous lapses in developer ethics, such as those discussed in Quincy Larson's article What do Uber, Volkswagen and Zenefits have in common? They all used hidden code to break the law. \ No newline at end of file +Examples include: + +* [**The International Standard for Professional Software Development and Ethical Responsibility**] (http://seeri.etsu.edu/TheSECode.htm) by the IEEE-CS/ACM Joint Task Force on Software Engineering Ethics and Professional Practices + +* [**The Ten Commandments of Computer Ethics**] (http://computerethicsinstitute.org/publications/tencommandments.html) by the Computer Ethics Institute + +* [**The Pledge of the Computing Professional**] (http://pledge-of-the-computing-professional.org/home-page/the-oath) + +* [**The Trustworthy Coder's Pledge**] (https://medium.com/@BillSourour/the-trustworthy-coders-pledge-aa5ba046c5aa) by Bill Sourour + +* [**The Programmer's Oath**] (https://www.youtube.com/watch?v=36NgPu9OyRM&list=PLWKjhJtqVAbno-B4RmJHCDO0ZUKC2tpUQ) by "Uncle Bob" Martin + +* [**The "Never Again" Pledge**] (http://neveragain.tech) + +Common themes appearing throughout these examples include a commitment to honesty, integrity, and fairness. + +To date, since most software developers do not belong to – and are not governed by – any official order, guild, association, or society, no single, codified ethical standard has been widely adopted. + +-- + +#### More Information: +* [Computer and Information Ethics] (https://plato.stanford.edu/archives/win2014/entries/ethics-computer/) entry in the Stanford Encyclopedia of Philosophy. + +* [Computer Ethics] (https://en.wikipedia.org/wiki/Computer_ethics) entry in WikiPedia + +* [CSE 302 - Professional Ethics for Computer Science] (http://www3.cs.stonybrook.edu/~mueller/teaching/cse302/) – outline and study materials for a course given in the Computer Science department at Stony Brook University's College of Engineering and Applied Sciences. + +* [A Very Short History of Computer Ethics] (https://web.archive.org/web/20080418122849/http://www.southernct.edu/organizations/rccs/resources/research/introduction/bynum_shrt_hist.html) – article from the Summer 2000 issue of the American Philosophical Association’s Newsletter on Philosophy and Computing \ No newline at end of file diff --git a/src/pages/developer-ethics/the-programmers-oath/index.md b/src/pages/developer-ethics/the-programmers-oath/index.md index 74a218329b9..79c1fb8ba12 100644 --- a/src/pages/developer-ethics/the-programmers-oath/index.md +++ b/src/pages/developer-ethics/the-programmers-oath/index.md @@ -17,7 +17,7 @@ The Programmers Oath is a an oath created by Robert C. Martin, that are the guid >8. I will produce estimates that are honest both in magnitude and precision. I will not make promises without certainty. >9. I will never stop learning and improving my craft. -[A web series on the freeCodeCamp channel](https://www.youtube.com/watch?v=36NgPu9OyRM) breaks down what the oath means, and how to follow the oath. +A web series on the freeCodeCamp channel breaks down what the oath means, and how to follow the oath. ### Promise 1 >1. I will not produce harmful code. diff --git a/src/pages/html/attributes/script-src-attribute/index.md b/src/pages/html/attributes/script-src-attribute/index.md index 2a17ff55801..f356c8af8ef 100644 --- a/src/pages/html/attributes/script-src-attribute/index.md +++ b/src/pages/html/attributes/script-src-attribute/index.md @@ -38,5 +38,5 @@ This example links to a jQuery file. #### More Information: -[MDN Article on the HTML +``` - +In the simple example above, when a user clicks on the button they will see an alert in their browser showing `Button was clicked!`. -#### More Information: - +### Adding `onclick` dynamically +The `onclick` event can also be programmatically added to any element using the following code in the following example: + +```javascript +

click on this element.

+ +``` +In the above example, when a user clicks on the `paragraph` element in the `html`, they will see an alert showing `onclick Event triggered`. +#### More Information: +[MDN](https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onclick) From 0888d6421473133a0e98836e1d7b81300997ba88 Mon Sep 17 00:00:00 2001 From: Chris Thierauf Date: Tue, 10 Oct 2017 12:40:35 -0400 Subject: [PATCH 33/89] C: Added appendix, helloWorld overhaul (#632) * HelloWorld Overhaul * Added Appendix * Update appendix.md * Update index.md --- src/pages/c/appendix.md | 41 ++++++++++++++++++ src/pages/c/index.md | 94 ++++++++++++++++++++++++++++++++--------- 2 files changed, 115 insertions(+), 20 deletions(-) create mode 100644 src/pages/c/appendix.md diff --git a/src/pages/c/appendix.md b/src/pages/c/appendix.md new file mode 100644 index 00000000000..182b0a6f427 --- /dev/null +++ b/src/pages/c/appendix.md @@ -0,0 +1,41 @@ +--- +title: Appendix +--- +# C: An Appendix +Because C is such a low-level language, there are a lot of terms that come up that aren't found in a lot of other languages. Here's an appendix to making understanding them easier. + +## Compilation +The compilation is the process of taking the human-readable code and turning it into machine-readable code. This process is performed by a compiler. + +## Compiler +A compiler is a program that compiles code, meaning it changes it from something machine-readable into something human-readable. + +## Debugging/Debugger +Debugging is the process of removing errors ("bugs") from your code. A debugger is a helpful tool that makes that easier. + +## GNU+Linux +GNU+Linux is the technically accurate term for what is commonly referred to as "Linux". Linux is a kernel- it's a set of programs that allow software to interact with hardware. When combined with GNU, it becomes an operating system, which allows a person to interact with it. + +## GUI +Graphical User Interface. A GUI will allow you to interact with a program by pointing and clicking rather than having to type in commands. + +## Header Files +Header files are libraries that exist in the top (header) of your C program. + +## IDE +Integrated Development Environment. It's an editor for code and will have useful tools for making writing code easier, like a debugger. + +## Human-readable +The human-readable code is code that can be read by a person- it's not in binary or machine code. + +## Libraries +Libraries are useful sets of code that give more functions and features in the language. + +## Machine Code +Machine code is the code that the machine can understand. Remember that computers use numbers, not English, to run. + +## Newline +A newline is what gets printed when you hit Enter, and is an example of a whitespace character. + +## Whitespace +Whitespace is the characters that you don't see when you type but are there anyway. For example, you can't see spaces, but there is a lot here. Newlines are also whitespace characters, as are tabs. diff --git a/src/pages/c/index.md b/src/pages/c/index.md index 1c8a9524a72..0a4e7b6ea92 100644 --- a/src/pages/c/index.md +++ b/src/pages/c/index.md @@ -4,13 +4,24 @@ title: C # Hello World! - Your first C Program +## Getting the most out of this course +Make sure that you're comfortable with all of the concepts in this part of the guide before moving on. Getting your first program running is important because it will allow you to follow along with the examples, which is another good thing to do- practice makes perfect! Concepts that might be confusing will have an annotation that links to an appendix. If you don't understand a concept, make sure that you consult the appendix for more information. + +## Course Goal +The goals of this course are to teach the C language to beginners. Ideally, someone who has never touched a computer language before will be able to know C by following these guides. However, they will still be useful to more experienced programmers by including a summary at the end of each article. Although the content taught here is transferable to microcontrollers like the Arduino, it is not the focus of this guide. + ## What is C? -C is a general purpose programming language which was invented by Dennis Ritchie between 1969 and 1973 at Bell Labs, and it has been used to develop the Linux Kernel. +C is a general purpose programming language invented by Dennis Ritchie between 1969 and 1973 at Bell Labs. Since then, it has been used to create things like the Linux Kernel, which allows software to interact with hardware on Linux-based operating systems. It can do this, and other low-level operations, because it was designed to be very close to machine code while still being human-readable. Because of this, it provides direct access to computer memory and hardware. This makes it very useful in hardware and robotics applications where having access to those features quickly is important. + +C, like other low-level languages, requires compilation. The compilation process takes the C code that can be read by a person and turns it into code that can be read and executed by a computer. Compilation requires a compiler, which can either be used from the command line or can be used in an IDE. -It was designed to provide low-level access to memory, to provide language constructs that map efficiently to machine instructions, and to require minimal run-time support. Along with C++ is widely used for micro controler programming and IOT such as Arduino. +If you would prefer to use the command line, consider `gcc`. It can be found by default on GNU+Linux operating systems and on Mac, and is easy to get on Windows. For beginners, however, having an IDE may be more comfortable. Consider CodeBlocks or XCode if you're interested in being able to write and run code from a GUI. + +Now that you have that background, let's start with our 'Hello, World' program. 'Hello, World' is a traditional way of getting started with a language: it shows that we can write code and make it run, so it's a good place to start! ## Hello world in C + ```C #include @@ -21,45 +32,88 @@ int main(void) } ``` -Let's break down the program step by step. +Let's break this program down step-by-step. -First we have: +First is the `#include`: ```C #include ``` -Which is the command for the compiler to include the stdio library that contain among other things the "I/O" funtions such as printf. +This is an instruction to the compiler to find and include a set of header files. Header files contain additional code that we can use. In this case, the compiler has been instructed to include ``, which contains all kinds of useful functions like `printf()`. We'll get into detail about what functions are later, but for now just remember that a function is a collection of code that we can use. ```C int main(void) { } ``` - This is the declaration of the *main funtion* that is the first piece of code that is going to be executed when you run the program. The *int* before *main* indicate that the funtion is going to return an integral number (usually 0) when it has finished it's execution and the *void* inside the parenthesis mean that the funtion doesn't take any parameters.Finally the *{ }* symbols mark the beginning and the end of the funtion. +This code declares the main function. The main function is special- it will always get called and is always the 'main' part of your program. If this isn't in your program, your program can't run and won't compile. + +Starting the function declaration with `int` means that this function will give an `int` value when it's done running through its code- it's this function's output. `int` is the 'integer' data type, and integers are whole numbers like -3, 0, or 18. So we know that this code will run, and when it's done, it will give us back an integer. By convention, this integer is 0. + +Next is `main`. `main` is the name of this function, and as you learned earlier, it's important to have a `main` function because your program won't work without it. `main` is followed by `(void)`. This tells the compiler that this function doesn't take any parameters, meaning that it has no input. + +This might not make a lot of sense right now, but you'll be learning more about this when you start reading about functions in C later. For now, just remember that `main` is required for your C program, it isn't taking any input, and it's giving a number as its output. + +Finally, there are the brackets: `{` and `}`. These mark the beginning and end of the function. The open curly bracket (`{`) marks the beginning, and the close curly bracket (`}`) marks the end. Everything between the two is within the function. + +Now let's look at the meat of the program: + ```C -printf("Hello World\n"); + printf("Hello, World!\n"); ``` -We arrive to the most important part of the program, the *printf( )* funtion which print the data passed as an argument into the screen. -In this case we have *"Hello World \n"* where we use the *" "* to indicate that *Hello World* is a string (text) and *\n* to display a new line.Finally we end the line wiht a semicolon *;* -Finally, we safely terminate the program with: +`printf` is a function that takes text and prints it to the screen. The parenthesis indicates what information we want the `printf` function to take and print to the screen. We show that this is a string we want printed by surrounding it in quotes "like this". +Notice the \n found within the quotes- this tells the `printf` function to print a newline. A newline is what gets printed when you hit enter on your keyboard. Without explicitly telling C to print a newline, everything will be printed on the same line. + +Finally, the printf() statement is concluded with a semicolon (`;`). This shows that this line of code is over. Without it, the compiler doesn't know where one line ends and another begins, so it's important to include. + +The program ends with a return statement: ```C return 0; ``` +This shows that the function is over and that it should end by giving a value of 0 to whatever made it run. When you're running code on your computer, this is good to have because it allows other programs to interact with yours in a better way. -Be very carefull to add the *;* at the end of the statment because if you forget it the computer wouldn´t know where the command finish and the compiler would raise an error. +As before, this line ends with a semicolon to indicate that the line has completed. -## Additional considerations +## Compilation and Running +You can save your hello world file as whatever you want, but it needs to end with the .c file extension. In this example, the file has been named "helloworld.c", because that is a clear name with a .c file extension. -You may require some software to write and execute C/C++ code. I recommend using CodeBlocks for Windows and Linux, and XCode for Mac. +There are many ways to compile and get C code running on your computer. Here are a few: -* For Windows: Download Here - Use the link with the GNU/GCC compiler for windows. +#### Compilation and running from the command line with GCC +If you're running Mac or GNU+Linux, you've already got GCC installed. -* For Mac: Download for Mac Here +In order to run your C program, it needs to be compiled. In order to compile from the command line using gcc, run the following command from your terminal: +```shell +gcc -o helloworld ./helloworld.c +``` +`gcc` is the Gnu C Compiler, and it will compile the C file we give it into a program that can be run by your computer. -* For Linux install the build-essentials and codeblocks packages with the package manager of your distribution. -In Ubuntu, Debian and Linux Mint: -```bash -sudo apt-get install codeblocks build-essentials +`-o helloworld` tells GCC that you want the compiled file (the output of gcc) to be a file called "helloworld". The final part of the command tells GCC where the C file to be compiled can be found. If you aren't comfortable with navigating from the command line, this step will be hard, but that's okay- it's easy to learn and come back, or you can try from an IDE. + +Once you've got it compiled, run the following command: +```shell +./helloworld ``` + +If everything has gone well, you should see `Hello, World!` printed to the screen. + +#### Compilation and running C with CodeBlocks +[Codeblocks can be downloaded from here.](http://www.codeblocks.org/downloads/26) +Make a new program with `file` -> `new` -> `file`, select C/C++ source, select C as your language, and then copy over the helloworld.c text that you read through earlier. Compile and run the code with `Build` -> `Build and Run`. + +#### Compilation and running C with XCode +[XCode can be downloaded from here.](https://developer.apple.com/xcode/) +Make a new program with `File` -> `New` -> `Project` -> `OS X`. Then, select "New Command Line Tool". Name it whatever you want and select C as the language. + +To run the code, click `Product` -> `Run`. + +# Before you go on... + +## A review +* C is useful because it's small, fast, and has access to low-level operations. Because of this, it gets used a lot in robotics, operating systems, and consumer electronics, but not in things like webpages. +* A C program has a few critical parts: + * The include statement, which tells the C compiler where to find additional code that will be used in the program + * The main function, which is where the code will first be executed and is required in order to compile + * Stuff within that main function which will get executed, including a return statement that closes the program and gives a value to the program that called it +* C needs to be compiled in order to run. From 645f893234d357db304367da28b653081d25cd8f Mon Sep 17 00:00:00 2001 From: Jason Arnold Date: Tue, 10 Oct 2017 12:44:45 -0400 Subject: [PATCH 34/89] JavaScript: Add array filter guide (#644) * Add array filter guide Add array filter guide. * Add syntax highlighting to code block * Update index.md --- .../array/array-prototype-filter/index.md | 20 ++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/pages/javascript/standard-objects/array/array-prototype-filter/index.md b/src/pages/javascript/standard-objects/array/array-prototype-filter/index.md index 5be7546e7db..ab9692cae71 100644 --- a/src/pages/javascript/standard-objects/array/array-prototype-filter/index.md +++ b/src/pages/javascript/standard-objects/array/array-prototype-filter/index.md @@ -3,13 +3,23 @@ title: Array.prototype.filter --- ## Array.prototype.filter -This is a stub. Help our community expand it. +When the 'filter' method is run against an array it returns another array containing items that pass a Boolean test. -This quick style guide will help ensure your pull request gets accepted. +In this example, the students array is filtered and the return value is another array containing any student object where the grade value is greater than or equal to 90. - +```javascript +var students = [ + { name: 'Quincy', grade: 96 }, + { name: 'Jason', grade: 84 }, + { name: 'Alexis', grade: 100 }, + { name: 'Sam', grade: 65 }, + { name: 'Katie', grade: 90 } +]; -#### More Information: - +students.filter(student => student.grade >= 90) +// [ { name: 'Quincy', grade: 96 }, { name: 'Alexis', grade: 100 }, { name: 'Katie', grade: 90 } ] +``` +#### More Information: +[MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter) From 724d1fef908cb8ab166e0dfe3b181223b15a08bc Mon Sep 17 00:00:00 2001 From: David Daly Date: Tue, 10 Oct 2017 17:54:14 +0100 Subject: [PATCH 35/89] Add JavaScript onload article (#646) * Add JavaScript onload article Add initial article for JavaScript `onload` event, with examples and a link to the MDN page for more details. * Update index.md --- src/pages/javascript/onload-event/index.md | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/pages/javascript/onload-event/index.md b/src/pages/javascript/onload-event/index.md index 73cbd153d8a..6f639b7f041 100644 --- a/src/pages/javascript/onload-event/index.md +++ b/src/pages/javascript/onload-event/index.md @@ -2,14 +2,23 @@ title: Onload Event --- ## Onload Event +The `onload` event is used to execute a JavaScript function immediately after a page has been loaded. -This is a stub. Help our community expand it. +### Example: +```javascript + -This quick style guide will help ensure your pull request gets accepted. + +``` - +In the above example, as soon as the web page has loaded, the `myFunction` function will be called, showing the `Page finished loading` alert to the user. -#### More Information: - +the `onload` event is most often used within the `` element to execute the script. If it is attached to the ``, the script will run once the web page has completely loaded all content (images, script files, CSS files, etc.). +#### More Information: +[MDN](https://developer.mozilla.org/en-US/docs/Web/API/GlobalEventHandlers/onload) From cd22e7ef9c8f9f77c2ad3f9dffb0f5df61716f3e Mon Sep 17 00:00:00 2001 From: Joe Date: Tue, 10 Oct 2017 09:58:14 -0700 Subject: [PATCH 36/89] Create Acceptance Criteria stub (#649) * Create Acceptance Criteria stub First draft with links * Rename acceptance-criteria to acceptance-criteria.mdx * Rename acceptance-criteria.mdx to acceptance-criteria.md * Update acceptance-criteria.md --- src/pages/agile/acceptance-criteria.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/pages/agile/acceptance-criteria.md diff --git a/src/pages/agile/acceptance-criteria.md b/src/pages/agile/acceptance-criteria.md new file mode 100644 index 00000000000..36d663ff647 --- /dev/null +++ b/src/pages/agile/acceptance-criteria.md @@ -0,0 +1,20 @@ +--- +title: Acceptance Criteria +--- +## Acceptance Criteria + +The User Story, as an item in your backlog, is a placeholder for a conversation. In this conversation, +the Product Owner and the Delivery Team reach an understanding on the desired outcome. + +The Acceptance Criteria tells the Delivery Team how the code should behave. Avoid writing the **"How"** of the User Story; keep to the **"What"**. +If the team is following Test Driven Development (TDD), it may provide the framework for the automated tests. +The Acceptance Criteria will be the beginnnings of the test plan for the QA team. + +Most importantly, if the story does not meet each of the Acceptance Criteria, then the Product Owner should not be accepting the story at the end of the iteration. + + +#### More Information: + +Nomad8 provides an [FAQ on Acceptance Criteria](https://nomad8.com/acceptance_criteria/) + +Leading Agile on [Acceptance Criteria](https://www.leadingagile.com/2014/09/acceptance-criteria/) From 5d97f3dd159a9f852485c55e24208f24b0269e17 Mon Sep 17 00:00:00 2001 From: Ankit Tiwari Date: Tue, 10 Oct 2017 22:45:48 +0530 Subject: [PATCH 37/89] Fix a bug in Python tuple guide (#712) * Fix a bug in python complex number page * was not visible, fixed it * Add syntax highlighting * Fix a bug in Python tuple guide * Added tuple's basic info * Removed a link which caused the page to break * Update index.md --- .../python/data-structures/tuples/index.md | 61 +++++++++---------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/src/pages/python/data-structures/tuples/index.md b/src/pages/python/data-structures/tuples/index.md index 881a784aace..07b28ee93a1 100644 --- a/src/pages/python/data-structures/tuples/index.md +++ b/src/pages/python/data-structures/tuples/index.md @@ -1,14 +1,14 @@ --- -title: The Python Tuples +title: The Tuples --- -**TODO: `Tuple` basic info** +## The Tuples -Python Docs - Tuples +A tuple is a sequence of Python objects. Tuples are immutable which means they cannot be modified after creation, unlike lists. **Creation:** An empty `tuple` is created using a pair of round brackets, `()`: - +```shell >>> empty_tuple = () >>> print(empty_tuple) () @@ -16,9 +16,9 @@ An empty `tuple` is created using a pair of round brackets, `()`: >>> len(empty_tuple) 0 - +``` A `tuple` with elements is created by separating the elements with commas (surrounding round brackets, `()`, are optional with exceptions): - +```shell >>> tuple_1 = 1, 2, 3 # Create tuple without round brackets. >>> print(tuple_1) (1, 2, 3) @@ -35,9 +35,9 @@ A `tuple` with elements is created by separating the elements with commas (surro >>> tuple_4 = (1, 2, 3,) # Trailing comma in round brackets is also optional. >>> print(tuple_4) (1, 2, 3) - +``` A `tuple` with a single element must have the trailing comma (with or without round brackets): - +```shell >>> not_tuple = (2) # No trailing comma makes this not a tuple. >>> print(not_tuple) 2 @@ -55,11 +55,11 @@ A `tuple` with a single element must have the trailing comma (with or without ro (2,) >>> type(also_tuple) - +``` Round brackets are required in cases of ambiguity (if the tuple is part of a larger expression): > Note that it is actually the comma which makes a tuple, not the parentheses. The parentheses are optional, except in the empty tuple case, or when they are needed to avoid syntactic ambiguity. For example, `f(a, b, c)` is a function call with three arguments, while `f((a, b, c))` is a function call with a 3-tuple as the sole argument. - +```shell >>> print(1,2,3,4,) # Calls print with 4 arguments: 1, 2, 3, and 4 1 2 3 4 >>> print((1,2,3,4,)) # Calls print with 1 argument: (1, 2, 3, 4,) @@ -68,15 +68,13 @@ Round brackets are required in cases of ambiguity (if the tuple is part of a lar (1, 2, False) >>> (1, 2, 3) == (1, 2, 3) # Use surrounding round brackets when ambiguous. True - +``` A `tuple` can also be created with the `tuple` constructor: - -Python Docs - Tuple - +```shell >>> empty_tuple = tuple() >>> print(empty_tuple) () - >>> tuple_from_list = tuple(1,2,3,4]) + >>> tuple_from_list = tuple([1,2,3,4]) >>> print(tuple_from_list) (1, 2, 3, 4) >>> tuple_from_string = tuple("Hello campers!") @@ -87,39 +85,39 @@ A `tuple` can also be created with the `tuple` constructor: the iterable, >>> a_tuple is b_tuple # the tuple argument is returned. True - +``` **Accessing elements of a `tuple`:** Elements of `tuples` are accessed and index the same way that `lists` are. - +```shell >>> my_tuple = 1, 2, 9, 16, 25 >>> print(my_tuple) (1, 2, 9, 16, 25) - +``` _Zero indexed_ - +```shell >>> my_tuple[0] 1 >>> my_tuple[1] 2 >>> my_tuple[2] 9 - +``` _Wrap around indexing_ - +```shell >>> my_tuple[-1] 25 >>> my_tuple[-2] 16 - +``` **Packing and Unpacking:** The statement `t = 12345, 54321, 'hello!'` is an example of tuple packing: the values `12345`, `54321` and `'hello!'` are packed together in a tuple. The reverse operation is also possible: - +```shell >>> x, y, z = t - +``` This is called, appropriately enough, sequence unpacking and works for any sequence on the right-hand side. Sequence unpacking requires that there are as many variables on the left side of the equals sign as there are elements in the sequence. Note that multiple assignment is really just a combination of tuple packing and sequence unpacking. - +```shell >>> t = 1, 2, 3 # Tuple packing. >>> print(t) (1, 2, 3) @@ -142,11 +140,11 @@ This is called, appropriately enough, sequence unpacking and works for any seque Traceback (most recent call last): File "", line 1, in ValueError: too many values to unpack (expected 2) - +``` **Immutable:** `tuples` are immutable containers, guaranteeing **which** objects they contain will not change. It does **not** guarantee that the objects they contains will not change: - +```shell >>> a_list = [] >>> a_tuple = (a_list,) # A tuple (immutable) with a list (mutable) element. >>> print(a_tuple) @@ -155,11 +153,11 @@ This is called, appropriately enough, sequence unpacking and works for any seque >>> a_list.append("Hello campers!") >>> print(a_tuple) # Element of the immutable is mutated. (['Hello campers!'],) - +``` **Uses:** Functions can only return a single value, however, a heterogenuous `tuple` can be used to return multiple values from a function. One example is the built-in `enumerate` function that returns an iterable of heterogenuous `tuples`: - +```shell >>> greeting = ["Hello", "campers!"] >>> enumerator = enumerate(greeting) >>> enumerator.next() @@ -167,5 +165,6 @@ Functions can only return a single value, however, a heterogenuous `tuple` can b (0, 'Hello') >>> enumerator.__next__() (1, 'campers!') - -[Python Docs - Tuples and Sequences \ No newline at end of file +``` +### More Inforamtion: +[Python Docs - Tuples](https://docs.python.org/3/library/stdtypes.html#tuples) From 712c205d98bc7027f7f5bdc28134638ab3c18058 Mon Sep 17 00:00:00 2001 From: Peregrin Garet Date: Tue, 10 Oct 2017 13:17:58 -0400 Subject: [PATCH 38/89] Update JS variable declaration explanation (#705) * Update JS variable declaration explanation Added more details to the JavaScript variable declarations explanation manual. The original version explained camel case, but in recent years there's been a fair amount of thought about var vs let vs const, and I think it's worth noting here that JavaScript is dynamically typed since users coming from a statically typed language might be confused when declaring about where how variable type declaration occurs. * Update index.md --- .../declare-javascript-variables/index.md | 60 +++++++++++++++++-- 1 file changed, 56 insertions(+), 4 deletions(-) diff --git a/src/pages/javascript/tutorials/declare-javascript-variables/index.md b/src/pages/javascript/tutorials/declare-javascript-variables/index.md index 9760b766093..1b912be598f 100644 --- a/src/pages/javascript/tutorials/declare-javascript-variables/index.md +++ b/src/pages/javascript/tutorials/declare-javascript-variables/index.md @@ -1,8 +1,60 @@ --- -title: Declare JavaScript Variables +title: Declare Variables --- -When we store data in a data structure, we call it a variable. JavaScript variables are written in `camel case`. An example of camel case is: `camelCase`. -You can declare a variable this way +# Declare Variables - var myName = "Rafael"; \ No newline at end of file +JavaScript variable declarations can be sorted into three distinct components: the variable type, the variable name, and the variable value. +```js + var myName = "Rafael"; +``` +Let's break the above line of code into the pieces that make it up: +```js + var/const/let +``` +JavaScript variables can have three declaration types: var, const, and let. Var-type variables are global, if declared outside a function they can be accessed by any JS file (or the console), and if created within a function they are accessible regardless of block scope. Let-type variables are limited in scope to their block. See the example below for the difference. +```js + function varTest() { + var x = 1; + if (true) { + var x = 2; // same variable! + console.log(x); // 2 + } + console.log(x); // 2 + } + + function letTest() { + let x = 1; + if (true) { + let x = 2; // different variable + console.log(x); // 2 + } + console.log(x); // 1 + } +``` +Const-type variables have the same scope as let variables (block scope), but are immutable. Whatever value a const-type variable is to be assigned, must happen when the variable is declared, and JavaScript will thrown an error if the variable is changed later. +```js + const genre = "non-fiction"; + console.log(genre); // "non-fiction"; + genre = "fantasy"; // error +``` +Now that we can determine what the variable type is, let's take a look at the name. JavaScript variable names are written in `camel case` format. An example of camel case is: `camelCase`. In the context of our example: +```js + myName +``` +The name is also we'll access the variable again later: +```js + console.log(myName); // "Rafael" +``` +Finally, our value: +```js + "Rafael" +``` +JavaScript is dynamically typed, which means any given variable can represent any given data type at any given time. For example: +```js + var example = "This is an example"; + example = [0, 1, 2, 3] + example = {test: "Result"} + example = 5 +``` +All those statements are perfectly valid - JavaScript variables can jump from string to array to object to integer. From 3a6a439c998b40211d4e6d61bfbbfa989c0bdcd0 Mon Sep 17 00:00:00 2001 From: Laura Shapiro Date: Tue, 10 Oct 2017 13:26:38 -0400 Subject: [PATCH 39/89] Array.prototype.pop (#672) * from stub to article * Update index.md * Math PI * Update index.md * Update index.md --- .../array/array-prototype-pop/index.md | 24 ++++++++++++++----- .../standard-objects/math/math-pi/index.md | 13 ++++++---- 2 files changed, 26 insertions(+), 11 deletions(-) diff --git a/src/pages/javascript/standard-objects/array/array-prototype-pop/index.md b/src/pages/javascript/standard-objects/array/array-prototype-pop/index.md index babf07462d1..ca2c70d25cc 100644 --- a/src/pages/javascript/standard-objects/array/array-prototype-pop/index.md +++ b/src/pages/javascript/standard-objects/array/array-prototype-pop/index.md @@ -1,15 +1,27 @@ --- title: Array.prototype.pop --- -## Array.prototype.pop -This is a stub. Help our community expand it. +# Array.prototype.pop -This quick style guide will help ensure your pull request gets accepted. +The `pop()` method removes the last element from and changes the length of an array. The return value of the method is the removed element, *not* the new array. - +**Syntax** +```js + arr.pop() +``` +## Description -#### More Information: - +The `pop` method removes the last element from an array and returns that value to the caller. + +## Examples +```js +var array = [1, 2, 3, 4] +array.pop() // 4 +array // [1, 2, 3] +[].pop() // undefined +``` +#### More Information: +[MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop) diff --git a/src/pages/javascript/standard-objects/math/math-pi/index.md b/src/pages/javascript/standard-objects/math/math-pi/index.md index 506df236697..d1cb1512e7e 100644 --- a/src/pages/javascript/standard-objects/math/math-pi/index.md +++ b/src/pages/javascript/standard-objects/math/math-pi/index.md @@ -3,13 +3,16 @@ title: Math PI --- ## Math PI -This is a stub. Help our community expand it. +``Math.PI`` is a static property of the Math object. It represents the mathematical constant defined as the ratio of a circle's circumference to its diameter. It is approximately 3.14149, and is often represented by the Greek letter π. -This quick style guide will help ensure your pull request gets accepted. - +![pi made of pi](https://c1.staticflickr.com/2/1207/3352784321_0d648bec78.jpg) -#### More Information: - +## Examples +```js +Math.PI \\ 3.141592653589793 +``` +#### More Information: +[MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/PI) From 017ced012315fa58b28cd802508c8a241b1c1cdc Mon Sep 17 00:00:00 2001 From: Maninder Pal Singh Date: Tue, 10 Oct 2017 10:31:19 -0700 Subject: [PATCH 40/89] Fixed syntax section of the article (#720) * Fixed syntax section of the article Syntax section was not rendering correctly on the live site at https://guide.freecodecamp.org/css/padding Therefore, it needs to fix a part of the example code. * Update index.md --- src/pages/css/padding/index.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/css/padding/index.md b/src/pages/css/padding/index.md index 63b34dc9738..115f0ee76a8 100644 --- a/src/pages/css/padding/index.md +++ b/src/pages/css/padding/index.md @@ -8,9 +8,9 @@ The `padding` CSS property sets the padding area on all four sides of an element Padding values are set using lengths or percentages or `inherit` keyword, and cannot accept negative values. The initial, or default, value for all padding properties is 0. While you can use `inherit` keyword but it can not be used along with a length value. ## Syntax -``` +```css .element { - padding: || || || + padding: [padding-top] || [padding-right] || [padding-bottom] || [padding-left]; } ``` @@ -20,7 +20,7 @@ This property may be specified using one, two, three, or four values. - When three values are specified, the first padding applies to the top, the second to the left and right, the third to the bottom. - When four values are specified, the paddings apply to the top, right, bottom, and left in that order (clockwise). -``` +```css /* Apply to all four sides */ padding: 1em; From de76b0dc4217cd85ca9bb2ba54865bb6480a2441 Mon Sep 17 00:00:00 2001 From: Laura Shapiro Date: Tue, 10 Oct 2017 13:59:56 -0400 Subject: [PATCH 41/89] JavaScript - Array.prototype.indexOf: updated from stub to article (#668) * updated from stub to article * Update index.md --- .../array/array-prototype-indexof/index.md | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src/pages/javascript/standard-objects/array/array-prototype-indexof/index.md b/src/pages/javascript/standard-objects/array/array-prototype-indexof/index.md index 05e4889c237..d9d79724236 100644 --- a/src/pages/javascript/standard-objects/array/array-prototype-indexof/index.md +++ b/src/pages/javascript/standard-objects/array/array-prototype-indexof/index.md @@ -1,15 +1,41 @@ --- title: Array.prototype.indexOf --- + ## Array.prototype.indexOf -This is a stub. Help our community expand it. +The `indexOf()` method returns the first index at which a given element can be found in the array. If the element is not present, it returns -1. + +**Syntax** +```javascript + arr.indexOf(searchElement[, fromIndex]) +``` + +## Parameters + +* **searchElement** Element for which you are looking + +* **fromIndex** Optional. The index at which you want to start the search at. Ifthe fromIndex is greater than or equal to the array's length, the array is not searched and the method returns -1. If the fromIndex is a negative number, it considered an offset from the end of the array (the array is still searched forwards from there). The default value is 0, which means the entire array is searched. + + +## Description -This quick style guide will help ensure your pull request gets accepted. +The `indexOf` method takes each array element in ascending index order and checks it against `searchElement` using strict equality (`===`). Once it finds an element that returns `true`, it returns its index. +## Examples +```javascript +var array = [1, 2, 4, 1, 7] - +array.indexOf(1); // 0 +array.indexOf(7); // 4 +array.indexOf(6); // -1 +array.indexOf('1'); // -1 +array.indexOf('hello'); // -1 +array.indexOf(1, 2); // 3 +array.indexOf(1, -3); // 3 +``` -#### More Information: - +### More Information: +[MDN link](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf) +[MSDN Link](https://docs.microsoft.com/en-us/scripting/javascript/reference/indexof-method-array-javascript) From 5b589abe3daa6716db9453b4ec3242e881617ba8 Mon Sep 17 00:00:00 2001 From: dharanee dharan Date: Wed, 11 Oct 2017 00:28:55 +0530 Subject: [PATCH 42/89] Added contents to Data structures --- src/pages/computer-science/data-structures/index.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pages/computer-science/data-structures/index.md b/src/pages/computer-science/data-structures/index.md index 611b0a7f101..b8030979f00 100644 --- a/src/pages/computer-science/data-structures/index.md +++ b/src/pages/computer-science/data-structures/index.md @@ -3,13 +3,15 @@ title: Data Structures --- ## Data Structures -This is a stub. Help our community expand it. +Data Structure is a way of collecting and organising data in such a way that we can perform operations on these data in an effective way. Data Structures is about rendering data elements in terms of some relationship, for better organization and storage. For example, we have data player's name "Virat" and age 26. Here "Virat" is of String data type and 26 is of integer data type. -This quick style guide will help ensure your pull request gets accepted. + We can organize this data as a record like Player record. Now we can collect and store player's records in a file or database as a data structure. For example: "Dhoni" 30, "Gambhir" 31, "Sehwag" 33 + +In simple language, Data Structures are structures programmed to store ordered data, so that various operations can be performed on it easily. It represents the knowledge of data to be organized in memory. It should be designed and implemented in such a way that it reduces the complexity and increases the effieciency. - #### More Information: +* [Data Structures](http://www.studytonight.com/data-structures/introduction-to-data-structures) From 0b0091ba9fdd3dccfd0609ca47812607dc6242ea Mon Sep 17 00:00:00 2001 From: Carlos Vigil Date: Wed, 11 Oct 2017 00:54:30 -0400 Subject: [PATCH 43/89] cleanup vim pages --- src/pages/vim/index.md | 2 +- src/pages/vim/modes/index.md | 63 ++++++++++++++++---------- src/pages/vim/useful-commands/index.md | 32 +++++++------ 3 files changed, 59 insertions(+), 38 deletions(-) diff --git a/src/pages/vim/index.md b/src/pages/vim/index.md index 35e480752fc..bd3ef457fed 100644 --- a/src/pages/vim/index.md +++ b/src/pages/vim/index.md @@ -1,7 +1,7 @@ --- title: Vim --- -## Vim +# Vim Vim is a highly configurable text editor built to make creating and changing any kind of text very efficient. It is included as "vi" with most UNIX systems and with Apple OS X. diff --git a/src/pages/vim/modes/index.md b/src/pages/vim/modes/index.md index 05ec6ad1378..079389d6250 100644 --- a/src/pages/vim/modes/index.md +++ b/src/pages/vim/modes/index.md @@ -4,36 +4,53 @@ title: Modes in Vim # Vim Modes -Because vim is focused on changing existing code just as much as writing new code, it is split into several modes that each have different purposes. +Because vim is focused on changing existing code just as much as writing new +code, it is split into several modes that each have different purposes. ### Normal Mode -When you open vim, normal mode is where you will be and where you will spend most time when using vim. In normal mode, keyboard keys don't type letters. Instead they can: +When you open vim, normal mode is where you will be and where you will spend +most time when using vim. In normal mode, keyboard keys don't type letters. + +Instead they can: - Move the cursor - Delete/Replace text - Copy/Paste text - Control several windows/buffers ### Insert Mode -This is the second most used mode. You can enter it by using an insert command from normal mode. These include: -- 'i' for 'insert', switches to insert mode where the cursor is -- 'a' for 'append', switches to insert mode 1 character after the cursor -- 'I', moves the cursor to the beginning of the line and inserts -- 'A', moves the cursor to the end of the line and inserts -There are so many more ways of inserting text in vim that can't be listed here but these are the simplest -Once in insert mode, typing inserts characters before the cursor. To leave insert mode and return to normal mode, press or ctrl-[ +This is the second most used mode. You can enter it by using an insert command +from normal mode. + +These include: +- `i` for 'insert', switches to insert mode where the cursor is +- `a` for 'append', switches to insert mode 1 character after the cursor +- `I` moves the cursor to the beginning of the line and inserts +- `A` moves the cursor to the end of the line and inserts +There are so many more ways of inserting text in vim that can't be listed here +but these are the simplest +Once in insert mode, typing inserts characters before the cursor. To leave +insert mode and return to normal mode, press `` or `ctrl-[` ### Visual Mode -Visual mode it used to select text, similar to how clicking and dragging with a mouse behaves. Press 'v' to enter visual mode, this begins the selection where the cursor is, then move the cursor to the end of what you want to select and now you can execute a command over the selecting text. -For example, after selecting text, press 'd' to delete the selected text or 'y' to copy it. - -### Ex Mode -Ex mode has a wide variety of commands and can do things that normal mode can't do as easily. To enter ex mode type ':' from normal mode and then type your command which should appear at the bottom of the window. -For example, to do a global find and replace type ':%s/foo/bar/g' to replace all 'foo' with 'bar' -- ':' Enters ex mode -- '%' Means accross all lines -- 's' Means substitute -- '/foo' is regex to find things to replace -- '/bar/ is regex to replace things with -- '/g' means global, otherwise it would only execute once per line - -Vim has a number of other methods used more rarely, but these four are used most in my experience. +Visual mode it used to select text, similar to how clicking and dragging with a +mouse behaves. Press 'v' to enter visual mode, this begins the selection where +the cursor is, then move the cursor to the end of what you want to select and +now you can execute a command over the selecting text. +For example, after selecting text, press 'd' to delete the selected text or 'y' +to copy it. + +### Command Mode +Command mode has a wide variety of commands and can do things that normal mode +can't do as easily. To enter command mode type ':' from normal mode and then +type your command which should appear at the bottom of the window. +For example, to do a global find and replace type `:%s/foo/bar/g` to replace +all 'foo' with 'bar' +- `:` Enters command mode +- `%` Means accross all lines +- `s` Means substitute +- `/foo` is regex to find things to replace +- `/bar/` is regex to replace things with +- `/g` means global, otherwise it would only execute once per line + +Vim has a number of other methods that you can read about in the help +documentation, `:h` or `:help`. diff --git a/src/pages/vim/useful-commands/index.md b/src/pages/vim/useful-commands/index.md index d4560d053c1..78f8f495948 100644 --- a/src/pages/vim/useful-commands/index.md +++ b/src/pages/vim/useful-commands/index.md @@ -1,23 +1,27 @@ --- title: Useful Commands --- -Here you can find various commands that help explain the methodology behind Vi. +## Exiting Vi, Vim, Nvim, Gvim +1. Press escape to get you into "normal" mode +2. Type `:q`, press enter. If you receive an error try `:q!` -## Modes -Most likely you'll find yourself in "normal" mode, it allows you to enter commands using the colon `:` key. +**OR** +- Type ZZ (save and quit) +- Close your terminal +- Shut down your computer + +## Bare minimum functionality +Most likely you'll find yourself in "normal" mode, it allows you to enter commands by pressing the colon `:` key. To get here from other modes you can type `ctrl + c` or `escape`. -To edit text and move around in a way you may be familiar with press `i`, for "insert" mode. -Depending on the configuration of settings you may be able to move around with the arrow keys in "insert" mode. -Likewise, depending on the configuration, you may enter a file browser by typing and entering the command `:e .` in "normal" mode. The 'e' stands for edit, and the period for the file or directory. +To edit text and move around in a familiar way press `i`, for "insert" mode. +Try to move around with the arrow keys in "insert" mode. -## Exiting Vi, Vim, Nvim, Gvim -For the first two press escape to get you into "normal" mode -- Type `:q`, press enter - - if you receive an error `:q!` enter -- Type ZZ -- Close your terminal -- Shut down your computer -- Dispose of your computer +Depending on the configuration, you may enter a file browser by typing and entering the command `:e .` in "normal" mode. The 'e' stands for edit, and the period for the file or directory. + +## I Want to Learn Vim! +Start by pressing `escape` to check if you're in normal mode, press colon `:`, type `Tutor`, and press `enter`. + +Read the rest of our Vim Guides to get a better understanding of this powerful editor. \ No newline at end of file From 2d956d0df5aa0a5b605d34d460919926b8eb09d3 Mon Sep 17 00:00:00 2001 From: Ben Gubler Date: Wed, 11 Oct 2017 09:11:34 -0600 Subject: [PATCH 44/89] fixed duplicate img articles: issue #670 (#760) * fixed duplicate img articles: issue #670 * fixed title --- src/pages/html/elements/images/index.md | 6 ---- src/pages/html/elements/img-tag/index.md | 28 ++++++++++++++++--- src/pages/html/images/index.md | 35 ------------------------ 3 files changed, 24 insertions(+), 45 deletions(-) delete mode 100644 src/pages/html/elements/images/index.md delete mode 100644 src/pages/html/images/index.md diff --git a/src/pages/html/elements/images/index.md b/src/pages/html/elements/images/index.md deleted file mode 100644 index 5b46c4dd3de..00000000000 --- a/src/pages/html/elements/images/index.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -title: Images ---- -#### Draft of Article: - -This article should cover the HTML `img` element as well as the related attributes (`src`, `alt`, and perhaps `title`) \ No newline at end of file diff --git a/src/pages/html/elements/img-tag/index.md b/src/pages/html/elements/img-tag/index.md index 9e4fb9654d4..7319933a6ae 100644 --- a/src/pages/html/elements/img-tag/index.md +++ b/src/pages/html/elements/img-tag/index.md @@ -3,13 +3,33 @@ title: Img Tag --- ## Img Tag -This is a stub. Help our community expand it. + +A simple HTML Image element can be included in an HTML document like this: -This quick style guide will help ensure your pull request gets accepted. +```html +this is a cool picture +``` + +`alt` tags provide alternate text for an image. One use of the `alt` tag is for visually impaired people using a screen reader; they can be read the `alt` tag of the image in order to understand the image's meaning. + +Note that the path to the image file can be either relative or absolute. Also, remember that the `img` element is self-closing, meaning that it does not close with the `` tag and instead closes with just a single `>`. + +Example: + +```html +my picture +``` + +(This is assuming that the html file is at https://example.com/index.html, so it's in the same folder as the image file) + +is the same as: + +```html +my picture +``` - #### More Information: - +MDN diff --git a/src/pages/html/images/index.md b/src/pages/html/images/index.md deleted file mode 100644 index 97911de9c66..00000000000 --- a/src/pages/html/images/index.md +++ /dev/null @@ -1,35 +0,0 @@ ---- -title: Images ---- -## Images - - -A simple HTML Image element can be included in an HTML document like this: - -```html -this is a cool picture -``` - -`alt` tags provide alternate text for an image. One use of the `alt` tag is for visually impaired people using a screen reader; they can be read the `alt` tag of the image in order to understand the image's meaning. - -Note that the path to the image file can be either relative or absolute. Also, remember that the `img` element is self-closing, meaning that it does not close with the `` tag and instead closes with just a single `>`. - -Example: - -```html -my picture -``` - -(This is assuming that the html file is at https://example.com/index.html, so it's in the same folder as the image file) - -is the same as: - -```html -my picture -``` - - -#### More Information: - - -MDN From 0ee483f62aab1eb14754cfe9c7473e287790e28d Mon Sep 17 00:00:00 2001 From: Dhanushu Anumanpalli Prabhakaran Date: Thu, 12 Oct 2017 01:27:50 +0530 Subject: [PATCH 45/89] Corrections (#661) Logistic regression is a classification algorithm. Updated explanations. --- src/pages/machine-learning/glossary/index.md | 29 ++++++++++++-------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/src/pages/machine-learning/glossary/index.md b/src/pages/machine-learning/glossary/index.md index d551af0683b..287598e452f 100644 --- a/src/pages/machine-learning/glossary/index.md +++ b/src/pages/machine-learning/glossary/index.md @@ -6,19 +6,26 @@ title: Glossary A quick one or two sentences describing common terms. See individual pages for more details. -- **machine learning** - intersection of statistics and computer science in - order to teach computers to perform tasks without explicitly being programmed -- **regression** - estimate the result of combining relationships among - variables; some regression techniques include linear regression and logistic - regression -- **statistical learning** - the use of machine learning with the goal of +- **Machine Learning** - Intersection of statistics and computer science in + order to teach computers to perform tasks without explicitly being programmed. +- **Statistical Learning** - the use of machine learning with the goal of statistical inference, whereby you make conclusions of the data rather than focus on prediction accuracy -- **supervised learning** - a type of learning where you give the computer data - with labels on them and you wish to accurately predict or guess the labels of - the data -- **unsupervised learning** - asking the computer to explore and identify - patterns within your data and common techniques include clustering +- **Supervised Learning** - Using historical data to predict the future. Example: Using historical data of prices at which houses were sold to predict the price in which your house will be sold. Regression and Classification come under supervised learning. +- **Unsupervised Learning** - Finding patterns in unlabelled data. Example: Grouping customers by purchasing behaviour. Clustering comes under unsupervised learning. +- **Regression** - A machine learning technique used to predict continous values. Linear Regression is one of the most popular regression algorithm. +- **Classification** - A machine learning technique used to predict discrete values. Logistic Regression is one of the most popular classification algorithm. +``` +f: x -> y + +Here 'f' is a function that takes 'x' as input and produces 'y' as output. + +If the output value 'y' is a real number / continous value then the function +is a regression technique. + +If the output value 'y' is a discrete / categorical value then the function is a classification technique. +``` +- **Clustering** - Grouping of unlabelled data. Identifying patterns using statistics. ### More Information: From 4193f5ae26656e747b3a90643bc18ac382978063 Mon Sep 17 00:00:00 2001 From: Ahmed Al-Obaidi Date: Thu, 12 Oct 2017 02:05:09 +0300 Subject: [PATCH 46/89] JavaScript: create "function invocation" page (#651) * Add function invocation article * Fix whitespace and headings --- .../javascript/function-invocation/index.md | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/pages/javascript/function-invocation/index.md b/src/pages/javascript/function-invocation/index.md index 7db6562c339..75ab3f5042d 100644 --- a/src/pages/javascript/function-invocation/index.md +++ b/src/pages/javascript/function-invocation/index.md @@ -2,14 +2,34 @@ title: Function Invocation --- ## Function Invocation +The code inside a function is executed when the function is invoked. It is common to use the term "call a function" instead of "invoke a function". -This is a stub. Help our community expand it. +Functions must be in scope when they are called. The scope of a function is the function in which it is declared, or the entire program if it is declared at the top level. -This quick style guide will help ensure your pull request gets accepted. +```javascript +function myFunction(a, b) { + return a * b; +} +myFunction(10, 2); // Function invocation, will return 20 +``` - +### Invoking a Function as a Method +In JavaScript, you can define functions as object methods. -#### More Information: - +The following example creates an object (`myObject`), with two properties (`firstName` and `lastName`), and a method (`fullName`): + +```javascript +var myObject = { + firstName:"John", + lastName: "Doe", + fullName: function () { + return this.firstName + " " + this.lastName; + } +} +myObject.fullName(); // Function invoked as a method, will return "John Doe" +``` + +### More Information: +- Function documentation: [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions) From 0ded76559cef79c6ec12418d8fbac4cfba4c6642 Mon Sep 17 00:00:00 2001 From: John Kennedy Date: Thu, 12 Oct 2017 00:11:34 +0100 Subject: [PATCH 47/89] Added CSS Box model article (#650) * Added CSS Box model article * Corrected image links * fixed inline code markdown * update index --- src/pages/css/the-box-model/index.md | 32 ++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 7 deletions(-) diff --git a/src/pages/css/the-box-model/index.md b/src/pages/css/the-box-model/index.md index 4e19a1572d6..396e1c5963f 100644 --- a/src/pages/css/the-box-model/index.md +++ b/src/pages/css/the-box-model/index.md @@ -1,15 +1,33 @@ --- -title: The Box Model +title: Box Model --- -## The Box Model +## Box Model -This is a stub. Help our community expand it. +Understanding the CSS Box Model is crucial to being able to correctly layout a web page. -This quick style guide will help ensure your pull request gets accepted. +When a browser renders (draws) a web page each element, for example, a piece of text or an image, is drawn as a rectangular box following the rules of the CSS Box Model. - +At the center of the box is the content itself, which takes up a certain height and width. This region is known as the **Content Area**. The size of the content area can be automatically determined, or you can explicitly set the size of height and width. (see note below regarding `box-sizing`) + +![Content Area Image](https://raw.githubusercontent.com/johnkennedy9147/Resources/master/CSS%20Box%20Model%20Images/content%20area.jpg) + +Around the Content Area, this is a region known as **Padding Area**. The size of the padding can be the same all around, or you can set individually for the top, bottom, left and right padding. If you are using a background for the element, the background will extend into the Padding Area. + + +![Padding Area Image](https://raw.githubusercontent.com/johnkennedy9147/Resources/master/CSS%20Box%20Model%20Images/padding%20area.jpg) + +Next, there is a **Border Area**. This creates a border around the element and its padding. You can set thickness, color, and style of the border. Style options include none, solid, dashed, dotted and several others. (see note below regarding `box-sizing`) -#### More Information: - +![Border Area Image](https://raw.githubusercontent.com/johnkennedy9147/Resources/master/CSS%20Box%20Model%20Images/border%20area.jpg) + +Finally, there is the **Margin Area**. This creates clear space around the element, padding, and border. Again you can individually set top, bottom, left and right margins. Under certain circumstances margin collapsing occurs and the margins between adjacent elements may be shared. + + +![Margin Area Image](https://raw.githubusercontent.com/johnkennedy9147/Resources/master/CSS%20Box%20Model%20Images/margin%20area2.jpg) + +**`Box-Sizing` Property** +The default for this property is `content-box`. If you use the default then the box model will allow the author to specify the size of the content area. However, it is possible to use these to instead specify the size of the border area. This is done by changing `box-sizing` property to `border-box`. This can sometimes make layouts easier. You can set the `box-sizing` property per element as desired. + +#### More Information: From fa4c52f37bd80a352bfdef683a458c900c645d93 Mon Sep 17 00:00:00 2001 From: Kyle Galbraith Date: Wed, 11 Oct 2017 16:13:41 -0700 Subject: [PATCH 48/89] Add explanation of SQL injection (#655) * Add SQL injection article * Edit whitespace --- src/pages/sql/sql-injection/index.md | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/pages/sql/sql-injection/index.md b/src/pages/sql/sql-injection/index.md index 3be810a9de1..45cb1d38461 100644 --- a/src/pages/sql/sql-injection/index.md +++ b/src/pages/sql/sql-injection/index.md @@ -2,14 +2,19 @@ title: SQL Injection --- ## SQL Injection +SQL injection is a malicious technique that is meant to compromise or destroy databases. It is one of the most common web-hacking techniques. -This is a stub. Help our community expand it. +SQL injection is performed by placing malicious code in SQL statements via an input. -This quick style guide will help ensure your pull request gets accepted. +The following example is a code snippet that will retrieve a user from a database based on an `AccountId`. - +``` +passedInAccountId = getRequestString("AccountId"); +sql = "select * from Accounts where AccountId = " + passedInAccountId; +``` -#### More Information: - +SQL injection can be used to compromise this code by injecting a `1=1;` statement for `AccountId`. +`https://www.foo.com/get-user?AccountId="105 OR 1=1;"` +`1=1` will always evaluate to `TRUE`. This will cause the executed code to output all of the Accounts table. From 15d4b426135e841e1ef3b5f540396ad5aec23428 Mon Sep 17 00:00:00 2001 From: Kyle Galbraith Date: Wed, 11 Oct 2017 16:31:22 -0700 Subject: [PATCH 49/89] Add join interview questions for SQL (#656) * Add join interview questions for SQL article * Fix heading sizes --- .../sql/sql-interview-questions/index.md | 29 +++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/src/pages/sql/sql-interview-questions/index.md b/src/pages/sql/sql-interview-questions/index.md index 2e406f2f9f4..80a4ec1974c 100644 --- a/src/pages/sql/sql-interview-questions/index.md +++ b/src/pages/sql/sql-interview-questions/index.md @@ -3,13 +3,32 @@ title: SQL Interview Questions --- ## SQL Interview Questions -This is a stub. Help our community expand it. +### What is an inner join in SQL? +This is the default type of join if no join is specified. It retuns all rows in which there is at least one match in both tables. +```sql +SELECT * FROM A x JOIN B y ON y.aId = x.Id +``` -This quick style guide will help ensure your pull request gets accepted. +### What is a left join in SQL? +A left join returns all rows from the left table, and the matched rows from the right table. Rows in the left table will be returned even if there was no match in the right table. The rows from the left table with no match in the right table will have `null` for right table values. +```sql +SELECT * FROM A x LEFT JOIN B y ON y.aId = x.Id +``` - +### What is a right join in SQL? +A right join returns all rows from the right table, and the matched rows from the left table. Opposite of a left join, this will return all rows from the right table even where there is no match in the left table. Rows in the right table that have no match in the left table will have `null` values for left table columns. +```sql +SELECT * FROM A x RIGHT JOIN B y ON y.aId = x.Id +``` -#### More Information: - +### What is a full join in SQL? +A full join returns all rows for which there is a match in either of the tables. So if there are rows in the left table that do not have matches in the right table, those will be included. As well as if there are rows in the right table that do not have matches in the left table, those will be included. +```sql +SELECT Customers.CustomerName, Orders.OrderID +FROM Customers +FULL OUTER JOIN Orders +ON Customers.CustomerID=Orders.CustomerID +ORDER BY Customers.CustomerName +``` From 49265341ea43196ad5e36a8bdf08b7802906e056 Mon Sep 17 00:00:00 2001 From: Laura Shapiro Date: Wed, 11 Oct 2017 20:01:51 -0400 Subject: [PATCH 50/89] JavaScript - add String.prototype.indexOf article --- .../string/string-prototype-indexof/index.md | 31 ++++++++++++++++--- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/src/pages/javascript/standard-objects/string/string-prototype-indexof/index.md b/src/pages/javascript/standard-objects/string/string-prototype-indexof/index.md index cf9b80223a3..8338c54c888 100644 --- a/src/pages/javascript/standard-objects/string/string-prototype-indexof/index.md +++ b/src/pages/javascript/standard-objects/string/string-prototype-indexof/index.md @@ -2,14 +2,35 @@ title: String.prototype.indexOf --- ## String.prototype.indexOf +The `indexOf()` method returns the first index at which a given element can be found in the array. If the element is not present, it returns -1. -This is a stub. Help our community expand it. +**Syntax** +```javascript +str.indexOf(searchValue[, fromIndex]) +``` -This quick style guide will help ensure your pull request gets accepted. +### Parameters +* **searchValue** Substring for which you are looking. If this is empty (`''`) and there is no `fromIndex` parameter, this will return 0. - +* **fromIndex** Optional. The index at which you want to start the search. If the `fromIndex` value is greater than or equal to the string's length, the string is not searched and the method returns -1. If the `searchValue` is an empty string (`''`) and the `fromIndex` is less than the string's length, it will return the `fromIndex`; otherwise, it will return the string's length. (A negative number will be treated as though there is no argument.) -#### More Information: - +### Description +The `indexOf()` method checks the string from left to right. The index of the first character is 0; the index of the last character is ``string.length - 1``. The method checks each substring against `searchValue` using strict equality (`===`), which means this method is case sensitive. Once it finds a substring that returns `true`, it returns the index of its first character. +### Examples +```javascript +'Blue Whale'.indexOf('Blue'); // returns 0 +'Blue Whale'.indexOf('Blute'); // returns -1 +'Blue Whale'.indexOf('Whale', 0); // returns 5 +'Blue Whale'.indexOf('Whale', 5); // returns 5 +'Blue Whale'.indexOf('Whale', 7); // returns -1 +'Blue Whale'.indexOf(''); // returns 0 +'Blue Whale'.indexOf('', 9); // returns 9 +'Blue Whale'.indexOf('', 10); // returns 10 +'Blue Whale'.indexOf('', 11); // returns 10 +'Blue Whale'.indexOf('blue'); // returns -1 +``` +### More Information: +- MDN documentation: [MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/indexOf) +- MSDN documentation: [MSDN](https://docs.microsoft.com/en-us/scripting/javascript/reference/indexof-method-string-javascript) From 86d0eaf6fd4c23bbd5feb3618541cf393046b1aa Mon Sep 17 00:00:00 2001 From: Christoph Flick Date: Thu, 12 Oct 2017 02:35:04 +0200 Subject: [PATCH 51/89] Added syntax highlighting to all files under java (#711) * Added java syntax coloring and fixed minor code style issues * changed tabs to spaces * added syntax highlighting for java/arrays * minor code style fix * fix some stuff --- src/pages/java/arrays/index.md | 55 ++-- src/pages/java/basic-operations/index.md | 5 +- src/pages/java/classes-and-objects/index.md | 60 +++-- src/pages/java/constructors/index.md | 78 +++--- src/pages/java/control-flow/index.md | 100 ++++---- src/pages/java/data-types/index.md | 28 +- src/pages/java/infinite-loops/index.md | 30 +-- src/pages/java/inheritance-basics/index.md | 62 ++--- src/pages/java/inheritance/index.md | 142 +++++----- src/pages/java/instanceof-operator/index.md | 10 +- src/pages/java/interfaces/index.md | 242 ++++++++++-------- src/pages/java/loop-types-dowhile/index.md | 31 +-- src/pages/java/loop-types-for-each/index.md | 25 +- src/pages/java/loop-types-for/index.md | 27 +- src/pages/java/loop-types-while/index.md | 31 ++- .../loops-break-control-statement/index.md | 56 ++-- .../loops-continue-control-statement/index.md | 42 +-- src/pages/java/loops-dowhile/index.md | 12 +- src/pages/java/loops-for/index.md | 32 ++- src/pages/java/loops-while/index.md | 30 ++- src/pages/java/methods/index.md | 12 +- src/pages/java/strings/index.md | 18 +- src/pages/java/variables/index.md | 17 +- 23 files changed, 629 insertions(+), 516 deletions(-) diff --git a/src/pages/java/arrays/index.md b/src/pages/java/arrays/index.md index 7d5a8a46fa9..af18f85471f 100644 --- a/src/pages/java/arrays/index.md +++ b/src/pages/java/arrays/index.md @@ -7,50 +7,67 @@ An Array is used to store a collection of data of similar datatype. Arrays alway **Syntax:** - dataType[] name_of_array; // preferred way. - or - dataType name_of_array[]; // works but not preferred way +```java +dataType[] name_of_array; // preferred way. +``` +or +```java +dataType name_of_array[]; // works but not preferred way +``` ## Code snippets of above syntax: - double[] list; //preferred way. - or - double list[]; //works but not preferred way. +```java +double[] list; //preferred way. +``` +or +```java +double list[]; //works but not preferred way. +``` -Note: The style `double list[]` is not preferred as it comes from the C/C++ language and was adopted in Java to accommodate C/C++ programmers. +Note: The style `double list[]` is not preferred as it comes from the C/C++ language and was adopted in Java to accommodate C/C++ programmers. Additionally it's more readable: you can read that it's a "dobule array named list" other than "a double called list that is an array" ## Creating Arrays: - dataType[] name_of_array = new dataType[arraySize]; +```java +dataType[] name_of_array = new dataType[arraySize]; +``` ## Code snippets of the above syntax: - double[] List = new double[10]; +```java +double[] List = new double[10]; +``` ## Another way to create an Array: - dataType[] name_of_array = {value0, value1, ..., valuek}; +```java +dataType[] name_of_array = {value0, value1, ..., valuek}; +``` ## Code snippets of above syntax: - double[] list = {1, 2, 3, 4}; +```java +double[] list = {1, 2, 3, 4}; +``` _Example of code:_ - int[] a = new int[] {4,5,6,7,8}; //declare array - for (int i=0; iRun Code Output: - +``` 4 5 6 7 8 - -Source: Java Arrays \ No newline at end of file +``` +Source: Java Arrays diff --git a/src/pages/java/basic-operations/index.md b/src/pages/java/basic-operations/index.md index 70a70690c1b..166fed558c9 100644 --- a/src/pages/java/basic-operations/index.md +++ b/src/pages/java/basic-operations/index.md @@ -18,6 +18,7 @@ While most of the operations are self explanatory, the Conditional (Ternary) Ope `expression that results in boolean output ? return this value if true : return this value if false` For e.g: - +```java int x = 10; - int y = (x == 10) ? 5 : 9; <-- y will equal 5 since the expression x == 10 evaluates to true \ No newline at end of file + int y = (x == 10) ? 5 : 9; // y will equal 5 since the expression x == 10 evaluates to true +``` \ No newline at end of file diff --git a/src/pages/java/classes-and-objects/index.md b/src/pages/java/classes-and-objects/index.md index cb615b31dd3..80b38022253 100644 --- a/src/pages/java/classes-and-objects/index.md +++ b/src/pages/java/classes-and-objects/index.md @@ -9,36 +9,42 @@ Think of a `Class` as a blueprint for creating something concrete. A `Class` tel Objects are _instances_ of a class. All objects are instances of a certain class. Imagine a class being a "template", which every Object copies to. When you create an Object, basically it creates a new object on the blueprint of a class. Now lets look at this from a little piece of code : - // Car class - public class Car { - // car name - private String name; - // car mannufacturer name - private String manufacturerName; - // constructor - public Car(String name, String man) { - this.name = name; - this.manufacturerName = man; - } - // getter method - public String getName() { - return name; - } - // getter method - public String getManufacturerName() { - return manufacturerName; - } - - //setter method - public void setName(String name){ - this.name = name; - } +```java +// Car class +public class Car { + // car name + private String name; + + // car mannufacturer name + private String manufacturerName; + + // constructor + public Car(String name, String man) { + this.name = name; + this.manufacturerName = man; } + + // getter method + public String getName() { + return name; + } + + // getter method + public String getManufacturerName() { + return manufacturerName; + } + + //setter method + public void setName(String name){ + this.name = name; + } +} - Car modelS = new Car("Model S","Tesla"); +Car modelS = new Car("Model S","Tesla"); - System.out.println("Full Car Name = " + modelS.getManufacturerName() + " " + modelS.getName()); - // prints Tesla Model S +System.out.println("Full Car Name = " + modelS.getManufacturerName() + " " + modelS.getName()); +// prints Tesla Model S +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code diff --git a/src/pages/java/constructors/index.md b/src/pages/java/constructors/index.md index e5aed2e4fc5..b4d84e30611 100644 --- a/src/pages/java/constructors/index.md +++ b/src/pages/java/constructors/index.md @@ -9,21 +9,25 @@ That's when we use either **getter** (e.g., getName()) / **setter** (e.g., setNa When you write a class without any constructor, then Java assumes it has a default constructor : - public class Car { - private String name; - } +```java +public class Car { + private String name; +} - Car modelS = new Car(); +Car modelS = new Car(); +``` This initializing with no parameters is a way of calling the default constructor. You can also have a default constructor written yourself this way : - public class Car { - private String name; +```java +public class Car { + private String name; - public Car() { - name = "Tesla"; - } + public Car() { + name = "Tesla"; } +} +``` Then, when calling `new Car()`, the variable `name` will get auto-initialized to `"Tesla"`. @@ -41,24 +45,26 @@ Hence, the purpose of using `constructors` is to provide: Let's look at another example. Say, Honda (the car manufacturer), wants all its cars to be named `Honda `. In order to enforce this, we might represent this using a class as follows: - public class Car { +```java +public class Car { - private String name; + private String name; - //Constructor. - public Car(String model){ - this.name = "Honda " + model; - } + //Constructor. + public Car(String model){ + this.name = "Honda " + model; + } - public String getName(){ - return this.name; - } + public String getName(){ + return this.name; + } - public static void main(String args[]){ - Car car = new Car("Civic"); - System.out.println( car.getName() ); - } + public static void main(String args[]){ + Car car = new Car("Civic"); + System.out.println( car.getName() ); } +} +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code @@ -68,28 +74,30 @@ Why is this important? There are times when you'd want `one and only one` instan Assume you need a class to represent a Bank. You wouldn't want people to create instance of `Bank` ever. So, you design your class: - public class Bank { - - private static Bank instance; - - private Bank(){ +```java +public class Bank { - } + private static Bank instance; + + private Bank(){ + } - public static Bank getInstance(){ - if(null==instance){ - instance = new Bank(); - } - return instance; + public static Bank getInstance(){ + if(null == instance){ + instance = new Bank(); } - + return instance; } +} +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code Notice that the constructor is `private`. This enforces the fact that no one else is allowed to create an `instance` of the Bank. In fact, if in another class, you try: - Bank account = new Bank(); //-> throws a compilation error: Bank() has private access in Bank. +```java +Bank account = new Bank(); //-> throws a compilation error: Bank() has private access in Bank. +``` So, the only way to gain access to the instance is by using `Bank.getInstance()`. Such instances are called `Singleton` since you get exactly one instance (per VM to be precise) throughout the life of your application. \ No newline at end of file diff --git a/src/pages/java/control-flow/index.md b/src/pages/java/control-flow/index.md index cee695bf6b7..71d8877efb0 100644 --- a/src/pages/java/control-flow/index.md +++ b/src/pages/java/control-flow/index.md @@ -8,42 +8,52 @@ Control flow statements are exactly what the term means. They are statements tha Primarily, Java has the following constructs for flow control: * `if` - - if( ) { - //code enters this block if the above expression is 'true' - } + ```java + if( ){ + //code enters this block if the above expression is 'true' + } + ``` * `if...else` - - if( ){ - //execute this block if the expression is 'true' - - } else{ - //execute this block if the expression is 'false' - } + ```java + if( ){ + //execute this block if the expression is 'true' + } else{ + //execute this block if the expression is 'false' + } + ``` * `switch` Switch is an alternative for the `if...else` construct when there are multiple values and cases to check against. - switch( ){ - case : - break; - case : - default: - } +```java +switch( ){ + case : + + break; + case : + + default: + +} +``` Note: The program flow `falls through` the next `case` if the `break` statement is missing. For e.g. Let's say you say the standard 'Hello' to everyone at office, but you are extra nice to the girl who sits next to you and sound grumpy to your boss. The way to represent would be something like: - - switch(person){ - case 'boss' : soundGrumpy(); - break; - case 'neighbour' : soundExtraNice(); - case 'colleague': soundNormal(); - break; - default : - soundNormal(); - } +```java +switch(person){ + case 'boss': + soundGrumpy(); + break; + case 'neighbour': + soundExtraNice(); + case 'colleague': + soundNormal(); + break; + default: + soundNormal(); +} +``` Note: The `default` case runs when none of the `case` matches. Remember that when a case has no `break` statement, it `falls through` to the next case and will continue to the subsequent `cases` till a `break` is encountered. @@ -57,25 +67,27 @@ If you have less than 25 bucks, you get yourself a cup of coffee. If you have mo One of the ways to represent this will be: - int cash = 50; - String company = "friends"; - - if(cash<25){ - getCoffee(); - }else if(cash<60){ - getDecentMeal(); - }else if(cash<100){ - getDecentMeal(); - getGlassOfWine(); - } else { - - switch(company){ - case "wife" : candleLitDinner(); +```java +int cash = 50; +String company = "friends"; + +if(cash<25){ + getCoffee(); +} else if(cash < 60){ + getDecentMeal(); +} else if(cash < 100){ + getDecentMeal(); + getGlassOfWine(); +} else { + switch(company){ + case "wife": + candleLitDinner(); break; - case "friends" : meetFriendsAtSportsBar(); + case "friends": + meetFriendsAtSportsBar(); break; - } - } +} +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code \ No newline at end of file diff --git a/src/pages/java/data-types/index.md b/src/pages/java/data-types/index.md index 4c2cd1ad105..5886615c1fa 100644 --- a/src/pages/java/data-types/index.md +++ b/src/pages/java/data-types/index.md @@ -142,23 +142,23 @@ Apart from primitive data types there are reference variables created using cons Example : - class Box{ +```java +class Box{ - int length,breadth,height; + int length, breadth, height; - Box() - { - length=5; - breadth=3; - height=2; - } + public Box(){ + length=5; + breadth=3; + height=2; } +} - class demo{ +class demo{ - public static void main(String args[]) - { - Box b0x1 = new Box(); //box1 is the reference variable - char[] arr = new char[10]; //arr is the reference variable + public static void main(String args[]) { + Box box1 = new Box(); //box1 is the reference variable + char[] arr = new char[10]; //arr is the reference variable } - } \ No newline at end of file +} +``` \ No newline at end of file diff --git a/src/pages/java/infinite-loops/index.md b/src/pages/java/infinite-loops/index.md index 6c9ea3b9398..5df6a79e7b8 100644 --- a/src/pages/java/infinite-loops/index.md +++ b/src/pages/java/infinite-loops/index.md @@ -5,21 +5,19 @@ title: Java Infinite Loops If you want your loop to go on infinitely, you can use the `while`, `do while` and `for` statement. - // Infinite For Loop - for ( ; ; ) - { - // your code here - } +```java +// Infinite For Loop +for ( ; ; ){ + // your code here +} - // Infinite While Loop - while (true) - { - // your code here - } +// Infinite While Loop +while (true){ + // your code here +} - // Infinite Do While Loop - do - { - // your code here - } - while (true); \ No newline at end of file +// Infinite Do While Loop +do{ + // your code here +} while (true); +``` \ No newline at end of file diff --git a/src/pages/java/inheritance-basics/index.md b/src/pages/java/inheritance-basics/index.md index 0e160f93a22..5244d9d8ea2 100644 --- a/src/pages/java/inheritance-basics/index.md +++ b/src/pages/java/inheritance-basics/index.md @@ -7,41 +7,43 @@ So great you have successfully created a Car class. But, wait, aren't Tesla cars Solution : **Inheritance**. Java provides a neat way to "inherit" parent properties : - public class Car { - - private String name; - private String manufacturerName; - - public Car(String name, String man) { - this.name = name; - this.manufacturerName = man; - } - // Getter method - public String getName() { - return name; - } - // Getter method - public String getManufacturerName() { - return manufacturerName; - } - } +```java +public class Car { + + private String name; + private String manufacturerName; - public class ElectricCar extends Car { + public Car(String name, String man) { + this.name = name; + this.manufacturerName = man; + } + // Getter method + public String getName() { + return name; + } + // Getter method + public String getManufacturerName() { + return manufacturerName; + } +} - public ElectricCar(String name, String man) { - super(name, man); - } +public class ElectricCar extends Car { - public void charge() { - System.out.println("Charging ..."); - } + public ElectricCar(String name, String man) { + super(name, man); } - ElectricCar modelS = new ElectricCar("Model S","Tesla"); - // prints Tesla - System.out.println(modelS.getManufacturerName()); - // prints Charging ... - modelS.charge(); + public void charge() { + System.out.println("Charging ..."); + } +} + +ElectricCar modelS = new ElectricCar("Model S","Tesla"); +// prints Tesla +System.out.println(modelS.getManufacturerName()); +// prints Charging ... +modelS.charge(); +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code diff --git a/src/pages/java/inheritance/index.md b/src/pages/java/inheritance/index.md index 73c1206171a..1f4543653a2 100644 --- a/src/pages/java/inheritance/index.md +++ b/src/pages/java/inheritance/index.md @@ -12,31 +12,35 @@ Thus, inheritance gives Java the cool capability of _re-using_ code, or share co Let's describe it with the classic example of a `Vehicle` class and a `Car` class : - public class Vehicle { - public void start() { - // starting the engine - } - - public void stop() { - // stopping the engine - } +```java +public class Vehicle { + public void start() { + // starting the engine } - public class Car extends Vehicle { - int numberOfSeats = 4; + public void stop() { + // stopping the engine + } +} + +public class Car extends Vehicle { + int numberOfSeats = 4; - public int getNumberOfSeats() { - return numberOfSeats; - } + public int getNumberOfSeats() { + return numberOfSeats; } +} +``` Here we can see the `Car` class inheriting the properties of the `Vehicle` class. So, we dont have to write the same code of `start()` and `stop()` for `Car` as well, as those properties come from its parent. Yes, objects created from the `Car` class _also_ have those properties! - Car tesla = new Car(); +```java +Car tesla = new Car(); - tesla.start(); +tesla.start(); - tesla.stop(); +tesla.stop(); +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code @@ -59,23 +63,29 @@ Therefore, whenever you need to share some common bit of code to some more class In Java, it is possible to reference a subclass as an _instance_ of its superclass. It is called _Polymorphism_ in Object Oriented Programming, the ability of an object to take on many forms. For example, `Car` class object can be referenced as a `Vehicle` class instance like this : - Vehicle car = new Car(); +```java +Vehicle car = new Car(); +``` Although, the opposite is not possible : - Car car = new Vehicle(); // ERROR +```java +Car car = new Vehicle(); // ERROR +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code Since you can reference a Java subclass as a superclass instance, you can cast a subclass object easily to a superclass instance. It may be possible to cast a superclass object into a subclass type, but _only if the object is really an instance of subclass_. So keep this in mind : - Car car = new Car(); - Vehicle vehicle = car; // upcasting - Car car2 = (Car)vechile; //downcasting +```java +Car car = new Car(); +Vehicle vehicle = car; // upcasting +Car car2 = (Car)vechile; //downcasting - Bike bike = new Bike(); // say Bike is also a subclass of Vehicle - Vehicle v = bike; // upcasting, no problem here. - Car car3 = (Car)bike; // Compilation Error : as bike is NOT a instance of Car +Bike bike = new Bike(); // say Bike is also a subclass of Vehicle +Vehicle v = bike; // upcasting, no problem here. +Car car3 = (Car)bike; // Compilation Error : as bike is NOT a instance of Car +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code @@ -85,20 +95,22 @@ Now you know how to share code through parent-child relationship. But, what if, Java lets you _override_ or redefine the methods defined in the superclass. For example, your `Car` class has a different implementation of `start()` than the parent `Vehicle`, so you do this : - public class Vehicle { - public void start() { - System.out.println("Vehicle start code"); - } +```java +public class Vehicle { + public void start() { + System.out.println("Vehicle start code"); } +} - public class Car extends Vehicle { - public void start() { - System.out.println("Car start code"); - } - } +public class Car extends Vehicle { + public void start() { + System.out.println("Car start code"); + } +} - Car car = new Car(); - car.start(); // "Car start code" +Car car = new Car(); +car.start(); // "Car start code" +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code @@ -115,20 +127,22 @@ Annotations in Java is a good coding practice, but they are not a necessity. The Funny you ask about it! Just use the keyword `super` : - public class Vehicle() { - public void start() { - System.out.println("Vehicle start code"); - } +```java +public class Vehicle() { + public void start() { + System.out.println("Vehicle start code"); } +} - public class Car extends Vehicle { - public void run() { - super.start(); - } - } +public class Car extends Vehicle { + public void run() { + super.start(); + } +} - Car car = new Car(); - car.run(); // "Vehicle start code" +Car car = new Car(); +car.run(); // "Vehicle start code" +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code @@ -138,31 +152,35 @@ Funny you ask about it! Just use the keyword `super` : Using the `instanceof` keyword. Having lots of classes and subclasses it would be a little confusing to know which class is a subclass of which one in runtime. So, we can use `instanceof` to determine whether a class is actually a subclass of a superclass or not. - Car car = new Car(); +```java +Car car = new Car(); - boolean flag = car instanceof Vehicle; // true in this case! +boolean flag = car instanceof Vehicle; // true in this case! +``` ## Constructors & Inheritance As mentioned earlier, constructors cannot be directly inherited by a subclass. Although, a subclass is _required_ to call its parent's constructor as the first thing in its own constructor. How? You guessed it, using `super` : - public class Vehicle { - public Vehicle() { - // constructor - } - public void start() { - System.out.println("Vehicle start code"); - } +```java +public class Vehicle { + public Vehicle() { + // constructor + } + public void start() { + System.out.println("Vehicle start code"); } +} - public class Car extends Vehicle { - public Car() { - super(); - } - public void run() { - super.start(); - } +public class Car extends Vehicle { + public Car() { + super(); } + public void run() { + super.start(); + } +} +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code diff --git a/src/pages/java/instanceof-operator/index.md b/src/pages/java/instanceof-operator/index.md index 139bb4071ee..7fe82078da2 100644 --- a/src/pages/java/instanceof-operator/index.md +++ b/src/pages/java/instanceof-operator/index.md @@ -5,7 +5,9 @@ title: Java Docs Instanceof Operator The `instanceof` operator allows you to check the validity of a `IS A` relationship. If at any point of time, we are not sure about this and we want to validate this at runtime, we can do the following: - //assuming vehicle is an instance of Class `Car` the expression inside the 'if' will return true - if( vehicle instanceof Car ) { - //do something if vehicle is a Car - } \ No newline at end of file +```java +//assuming vehicle is an instance of Class `Car` the expression inside the 'if' will return true +if(vehicle instanceof Car){ + //do something if vehicle is a Car +} +``` \ No newline at end of file diff --git a/src/pages/java/interfaces/index.md b/src/pages/java/interfaces/index.md index 1313ed0faeb..fbcc3ef3bb7 100644 --- a/src/pages/java/interfaces/index.md +++ b/src/pages/java/interfaces/index.md @@ -5,22 +5,26 @@ title: Java Docs Interfaces Interface in Java is a bit like the Class, but with a significant difference : an `interface` can _only_ have method signatures and fields. That means, an Interface cannot contain the implementation of any method, just its signature, i.e. the name, parameters and exceptions of the method. For example : - public interface Vehicle { - public String licensePlate = ""; - public void start(); - public void stop(); - } +```java +public interface Vehicle { + public String licensePlate = ""; + public void start(); + public void stop(); +} +``` The interface above contains one field and two methods. Alone, it is not of much use, but they are usually used along with Classes. How? Simple, you have to make sure some class `implements` it. - public class Car implements Vehicle { - public void start() { - System.out.println("starting engine..."); - } - public void stop() { - System.out.println("stopping engine..."); - } +```java +public class Car implements Vehicle { + public void start() { + System.out.println("starting engine..."); + } + public void stop() { + System.out.println("stopping engine..."); } +} +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code @@ -30,37 +34,41 @@ Now, there is a **ground rule** : The Class must implement **all** of the method Once you create a Java Class which `implements` any Interface, the object instance can be referenced as an instance of the Interface. Similar concept as of Inheritance instantiation. - // following our previous example +```java +// following our previous example - Vehicle tesla = new Car(); +Vehicle tesla = new Car(); - tesla.start(); // starting engine ... +tesla.start(); // starting engine ... +``` But, you **cannot** create an instance of an Interface itself. You must create instance of some class implementing an Interface to reference it. Think of interfaces as a blank contract form, or a template. What can you do with this feature? Polymorphism! You can use only interfaces to refer to object instances! - class Truck implements Vehicle { - public void start() { - System.out.println("starting truck engine..."); - } - public void stop() { - System.out.println("stopping truck engine..."); - } +```java +class Truck implements Vehicle { + public void start() { + System.out.println("starting truck engine..."); } + public void stop() { + System.out.println("stopping truck engine..."); + } +} - class Starter { - // static method, can be called without instantiating the class - public static void startEngine(Vehicle vehicle) { - vehicle.start(); - } +class Starter { + // static method, can be called without instantiating the class + public static void startEngine(Vehicle vehicle) { + vehicle.start(); } +} - Vehicle tesla = new Car(); - Vehicle tata = new Truck(); +Vehicle tesla = new Car(); +Vehicle tata = new Truck(); - Starter.startEngine(tesla); // starting engine ... - Starter.startEngine(tata); // starting truck engine ... +Starter.startEngine(tesla); // starting engine ... +Starter.startEngine(tata); // starting truck engine ... +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code @@ -68,26 +76,28 @@ What can you do with this feature? Polymorphism! You can use only interfaces to Yes, you can implement multiple Interfaces in a single class. While in [Inheritance](//forum.freecodecamp.com/t/java-docs-inheritance) within Classes you were restricted to inherit only one class, here you can extend any number of interfaces. But do not forget to implement _all_ of the methods of all the Interfaces, otherwise compilation will fail! - public interface GPS { - public void getCoordinates(); - } +```java +public interface GPS { + public void getCoordinates(); +} - public interface Radio { - public void startRadio(); - public void stopRadio(); - } +public interface Radio { + public void startRadio(); + public void stopRadio(); +} - public class Smartphone implements GPS,Radio { - public void getCoordinates() { - // return some coordinates - } - public void startRadio() { - // start Radio - } - public void stopRadio() { - // stop Radio - } +public class Smartphone implements GPS,Radio { + public void getCoordinates() { + // return some coordinates + } + public void startRadio() { + // start Radio } + public void stopRadio() { + // stop Radio + } +} +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code @@ -106,36 +116,38 @@ Suppose, you wrote an open source library, which contains an Interface. Say, you Thankfully, Java 8 now provides us `default` methods of Interfaces. A `default` method _can_ contain its own implementation _directly_ within the Interface! So, if a Class does not implement a default method, the compiler will take the implementation mentioned within the Interface. Nice, isn't it? So in your library, you may add any number of default methods in interfaces without the fear of breaking anything! - public interface GPS { - public void getCoordinates(); - default public void getRoughCoordinates() { - // implementation to return coordinates from rough sources - // such as wifi & mobile - System.out.println("Fetching rough coordinates..."); - } +```java +public interface GPS { + public void getCoordinates(); + default public void getRoughCoordinates() { + // implementation to return coordinates from rough sources + // such as wifi & mobile + System.out.println("Fetching rough coordinates..."); } +} - public interface Radio { - public void startRadio(); - public void stopRadio(); - } +public interface Radio { + public void startRadio(); + public void stopRadio(); +} - public class Smartphone implements GPS,Radio { - public void getCoordinates() { - // return some coordinates - } - public void startRadio() { - // start Radio - } - public void stopRadio() { - // stop Radio - } - - // no implementation of getRoughCoordinates() +public class Smartphone implements GPS,Radio { + public void getCoordinates() { + // return some coordinates + } + public void startRadio() { + // start Radio } + public void stopRadio() { + // stop Radio + } + + // no implementation of getRoughCoordinates() +} - Smartphone motoG = new Smartphone(); - motog.getRoughCoordinates(); // Fetching rough coordinates... +Smartphone motoG = new Smartphone(); +motog.getRoughCoordinates(); // Fetching rough coordinates... +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code @@ -143,34 +155,36 @@ Thankfully, Java 8 now provides us `default` methods of Interfaces. A `default` Awesome question. In that case, if you do not provide the implementation in the Class, poor compiler will get confused and simply fail! You have to provide a default method implemention within the Class also. There is also a nifty way using `super` to call which implementation you like : - public interface Radio { - // public void startRadio(); - // public void stopRadio(); +```java +public interface Radio { + // public void startRadio(); + // public void stopRadio(); - default public void next() { - System.out.println("Next from Radio"); - } + default public void next() { + System.out.println("Next from Radio"); } +} - public interface MusicPlayer { - // public void start(); - // public void pause(); - // public void stop(); +public interface MusicPlayer { + // public void start(); + // public void pause(); + // public void stop(); - default public void next() { - System.out.println("Next from MusicPlayer"); - } + default public void next() { + System.out.println("Next from MusicPlayer"); } +} - public class Smartphone implements Radio, MusicPlayer { - public void next() { - // Suppose you want to call MusicPlayer next - MusicPlayer.super.next(); - } +public class Smartphone implements Radio, MusicPlayer { + public void next() { + // Suppose you want to call MusicPlayer next + MusicPlayer.super.next(); } +} - Smartphone motoG = new Smartphone(); - motoG.next(); // Next from MusicPlayer +Smartphone motoG = new Smartphone(); +motoG.next(); // Next from MusicPlayer +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code @@ -178,31 +192,35 @@ Awesome question. In that case, if you do not provide the implementation in the It is also possible in Java for an Interface to _inherit_ another Interface, by using, you guessed it, `extends` keyword : - public interface Player { - public void start(); - public void pause(); - public void stop(); - } +```java +public interface Player { + public void start(); + public void pause(); + public void stop(); +} - public interface MusicPlayer extends Player { - default public void next() { - System.out.println("Next from MusicPlayer"); - } +public interface MusicPlayer extends Player { + default public void next() { + System.out.println("Next from MusicPlayer"); } +} +``` That means, the Class implementing `MusicPlayer` Interface has to implement _all_ methods of `MusicPlayer` as well as `Player` : - public class SmartPhone implements MusicPlayer { - public void start() { - System.out.println("start"); - } - public void stop() { - System.out.println("stop"); - } - public void pause() { - System.out.println("pause"); - } +```java +public class SmartPhone implements MusicPlayer { + public void start() { + System.out.println("start"); + } + public void stop() { + System.out.println("stop"); + } + public void pause() { + System.out.println("pause"); } +} +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code diff --git a/src/pages/java/loop-types-dowhile/index.md b/src/pages/java/loop-types-dowhile/index.md index c9cfa9ddc35..0e730504fad 100644 --- a/src/pages/java/loop-types-dowhile/index.md +++ b/src/pages/java/loop-types-dowhile/index.md @@ -5,28 +5,29 @@ title: Java Loop Types Dowhile The `do while` is very similar to the `while` loop in the way it works, but is _exit controlled_ (unlike the `for` and `while` loops which are _entry controlled_), that is, the truth value of its `expression` is evaluated after the execution of `Statements`. - do - { - // Statements - } - while (expression); +```java +do { + // Statements +} while (expression); +``` This kind of loop is particularly useful if you want your `Statements` to be executed at least once, irrespective of what `expression` evaluates to. You want to do this if you are initializing a variable inside your loop and plan on using its value later. - int iter_DoWhile = 20; - do - { - System.out.print (iter_DoWhile + " "); +```java +int iter_DoWhile = 20; +do{ + System.out.print(iter_DoWhile + " "); - // Increment the counter - iter_DoWhile++; - } - while(iter_DoWhile < 10); - System.out.println ("iter_DoWhile Value: " + iter_DoWhile); + // Increment the counter + iter_DoWhile++; +} while(iter_DoWhile < 10); +System.out.println("iter_DoWhile Value: " + iter_DoWhile); +``` Output: - +``` 20 iter_DoWhile Value: 21 +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code \ No newline at end of file diff --git a/src/pages/java/loop-types-for-each/index.md b/src/pages/java/loop-types-for-each/index.md index ac4627c675e..9bf366cf8b2 100644 --- a/src/pages/java/loop-types-for-each/index.md +++ b/src/pages/java/loop-types-for-each/index.md @@ -5,24 +5,27 @@ title: Java Loop Types for Each Also called the enhanced for loop, it is an extremely useful and simple way to iterate over each item in a collection, arrays as well as objects that implement the Iterable interface. - for (object : iterable) - { - // Statements - } +```java +for (object : iterable){ + // Statements +} +``` The loop is read as - for each element in the `iterable` (could be an array, collectable etc.). The `object` type must match the element type of the `iterable`. - int[] number_list = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; +```java +int[] number_list = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - for (int numbers : number_list) - { - System.out.print (numbers + " "); - //Iterated 10 times, numbers 0,1,2...9 - } +for (int numbers : number_list){ + System.out.print (numbers + " "); + //Iterated 10 times, numbers 0,1,2...9 +} +``` Output: - +``` 0 1 2 3 4 5 6 7 8 9 +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code diff --git a/src/pages/java/loop-types-for/index.md b/src/pages/java/loop-types-for/index.md index 753a6e2a6ef..626d3a7e87e 100644 --- a/src/pages/java/loop-types-for/index.md +++ b/src/pages/java/loop-types-for/index.md @@ -5,26 +5,29 @@ title: Java Loop Types for The `for` loop give you a compact way to iterate over a range of values. - for (initialization; expression; increment) - { - // Statements - } +```java +for (initialization; expression; increment){ + // Statements +} +``` * `initialization` - Initializes the loop and is executed just once, at the beginning. * `expression` - Evaluated at the beginning of each iteration. If the `expression` evaluates to `true`, `Statements` will get executed. * `increment` - Invoked after each iteration through the loop. You can increase/decrease the value of variables here. - int iter_For; - for (iter_For = 0; iter_For < 10; iter_For++) - { - System.out.print (iter_For + " "); - // Iterated 10 times, iter_For 0,1,2...9 - } - System.out.println("iter_For Value: " + fooFor); +```java +int iter_For; +for (iter_For = 0; iter_For < 10; iter_For++){ + System.out.print(iter_For + " "); + // Iterated 10 times, iter_For 0,1,2...9 +} +System.out.println("iter_For Value: " + fooFor); +``` Output: - +``` 0 1 2 3 4 5 6 7 8 9 iter_For Value: 10 +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code \ No newline at end of file diff --git a/src/pages/java/loop-types-while/index.md b/src/pages/java/loop-types-while/index.md index fe73973d7e9..37ea09bff8d 100644 --- a/src/pages/java/loop-types-while/index.md +++ b/src/pages/java/loop-types-while/index.md @@ -5,26 +5,29 @@ title: Java Loop Types While The `while` statement evaluates the `expression` (which must return a boolean value), and if it is `true`, the `Statements` get executed. - while (expression) - { - // Statements - } +```java +while (expression){ + // Statements +} +``` In the following example, the `expression` is given by `iter_While < 10`. As we increment `iter_While` by `1` each time the loop is executed, the `while` loop will keep going till `iter_While` reaches `10`. - int iter_While = 0; - while (iter_While < 10) - { - System.out.print (iter_While + " "); - // Increment the counter - // Iterated 10 times, iter_While 0,1,2...9 - iter_While++; - } - System.out.println ("iter_While Value: " + iter_While); +```java +int iter_While = 0; +while (iter_While < 10){ + System.out.print (iter_While + " "); + // Increment the counter + // Iterated 10 times, iter_While 0,1,2...9 + iter_While++; +} +System.out.println ("iter_While Value: " + iter_While); +``` Output: - +``` 0 1 2 3 4 5 6 7 8 9 iter_While Value: 10 +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code \ No newline at end of file diff --git a/src/pages/java/loops-break-control-statement/index.md b/src/pages/java/loops-break-control-statement/index.md index 35b9acbf8f8..f79f1863e81 100644 --- a/src/pages/java/loops-break-control-statement/index.md +++ b/src/pages/java/loops-break-control-statement/index.md @@ -5,48 +5,48 @@ title: Java Loops Break Control Statement Terminates the loop and starts the execution of the code that immediately follows the loop. If you have nested loops, the `break` statement will only end the loop in which it is placed. - for (int i = 0; i < 10; i++) // Loop 1 - { - for (int j = 0; j < 10; j++) // Loop 2 - { - if (i == 5 && j == 5) - { - break; - // Will terminate Loop 2, but Loop 1 will keep going - } +```java +for (int i = 0; i < 10; i++){ // Loop 1 + for (int j = 0; j < 10; j++){ // Loop 2 + if (i == 5 && j == 5){ + break; + // Will terminate Loop 2, but Loop 1 will keep going } } +} +``` But if you do want to break out of the outer loop too, you can use a label to exit: - loop1: // This is a label - for (int i = 0; i < 10; i++) // Loop 1 - { - for (int j = 0; j < 10; j++) // Loop 2 - { - if (i == 5 && j == 5) - { - break loop1; - // Will break out of Loop 1, instead of just breaking out of Loop 2 - } +```java +loop1: // This is a label +for (int i = 0; i < 10; i++){ // Loop 1 + for (int j = 0; j < 10; j++){ // Loop 2 + if (i == 5 && j == 5){ + break loop1; + // Will break out of Loop 1, instead of just breaking out of Loop 2 } } +} +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code `break` statements can be particulary useful while searching for an element in an array. Using `break` in the following code improves efficiency as the loop stops as soon as the element we are looking for (`searchFor`) is found, instead of going on till the end of `arrayInts` is reached. - int j = 0; - int[] arrayOfInts = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; - int searchFor = 5; +```java +int j = 0; +int[] arrayOfInts = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; +int searchFor = 5; - for (int i : arrayOfInts) - { - if (arrayOfInts[j] == searchFor) - break; - j++; +for(int i : arrayOfInts){ + if (arrayOfInts[j] == searchFor){ + break; } + j++; +} - System.out.println("j = " + j); +System.out.println("j = " + j); +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code \ No newline at end of file diff --git a/src/pages/java/loops-continue-control-statement/index.md b/src/pages/java/loops-continue-control-statement/index.md index 34dfee88027..31ae03ccb21 100644 --- a/src/pages/java/loops-continue-control-statement/index.md +++ b/src/pages/java/loops-continue-control-statement/index.md @@ -5,14 +5,14 @@ title: Java Loops Continue Control Statement The `continue` statement makes a loop skip all the following lines after the continue and jump ahead to the beginning of the next iteration. In a `for` loop, control jumps to the update statement, and in a `while` or `do while` loop, control jumps to the boolean expression/condition. - for (int j = 0; j < 10; j++) - { - if (j == 5) - { - continue; - } - System.out.print (j + " "); +```java +for (int j = 0; j < 10; j++){ + if (j == 5){ + continue; } + System.out.print (j + " "); +} +``` The value of `j` will be printed for each iteration, except when it is equal to `5`. The print statement will get skipped because of the `continue` and the output will be: @@ -20,22 +20,24 @@ The value of `j` will be printed for each iteration, except when it is equal to Say you want to count the number of `i`s in a the word `mississippi`. Here you could use a loop with the `continue` statement, as follows: - String searchWord = "mississippi"; +```java +String searchWord = "mississippi"; - // max stores the length of the string - int max = searchWord.length(); - int numPs = 0; +// max stores the length of the string +int max = searchWord.length(); +int numPs = 0; - for (int i = 0; i < max; i++) - { - // We only want to count i's - skip other letters - if (searchWord.charAt(i) != 'i') - continue; - - // Increase count_i for each i encountered - numPs++; +for(int i = 0; i < max; i++){ + // We only want to count i's - skip other letters + if (searchWord.charAt(i) != 'i'){ + continue; } - System.out.println("numPs = " + numPs); + // Increase count_i for each i encountered + numPs++; +} + +System.out.println("numPs = " + numPs); +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code \ No newline at end of file diff --git a/src/pages/java/loops-dowhile/index.md b/src/pages/java/loops-dowhile/index.md index bc00a2188ce..ef7c2d7c49e 100644 --- a/src/pages/java/loops-dowhile/index.md +++ b/src/pages/java/loops-dowhile/index.md @@ -7,11 +7,13 @@ The `do..while` loop is a special case of the `while` loop wherein the group of Can you guess the output of the following code snippet? - int i=10; - do{ - System.out.println("The value of i is " + i); - i--; - }while( i >= 10 ); +```java +int i = 10; +do{ + System.out.println("The value of i is " + i); + i--; +} while(i >= 10); +``` `Remember` : The condition of a `do-while` loop is checked After the code body is executed once. diff --git a/src/pages/java/loops-for/index.md b/src/pages/java/loops-for/index.md index 199542ab63d..52ec3ea8ff9 100644 --- a/src/pages/java/loops-for/index.md +++ b/src/pages/java/loops-for/index.md @@ -7,24 +7,28 @@ There are 2 of these: 1. Normal `for` loop -`java -for( initialize variable; condition; modify variable ){ -//perform action -}` +```java +for(initialize variable; condition; modify variable){ + //perform action +} +``` For e.g. -`java -for(int i=0; i<10; i++){ -System.out.println("The value of is : " + i); -}` +```java +for(int i = 0; i < 10; i++){ + System.out.println("The value of is : " + i); +} +``` -1. Enhanced `for` loop +1. Enhanced `for` loop / forEach loop Well, this came into existence in Java 5\. It helps when you are required to iterate over a list of items and perform some action like so: -`java -//assuming nameList is a List of names that are actually Strings -for( String name : nameList ){ -SYstem.out.println(name); -}` \ No newline at end of file +```java +// assuming nameList is a List of names that are actually Strings +Iterable nameList = ... +for(String name : nameList ){ + System.out.println(name); +} +``` \ No newline at end of file diff --git a/src/pages/java/loops-while/index.md b/src/pages/java/loops-while/index.md index e73b6fa59b8..50cfb76123e 100644 --- a/src/pages/java/loops-while/index.md +++ b/src/pages/java/loops-while/index.md @@ -5,21 +5,27 @@ title: Java Loops While The `while` loop executes a group of statements / single statement till a condition evaluates to `true`. For instance: - while(some_condition_is_true){ - //do something - } +```java +while(some_condition_is_true){ + //do something +} +``` `Note`: For the `while` loop to start executing, you'd require the condition to be true. However, to exit the loop you must do something as given below (otherwise the loop will execute forever. Practically, it will run till the JVM runs out of memory). - while(i<10){ - System.out.println("i :"+ i); - i++; //<- This ensures that value of i in the while condition will become more than 10 at some point thereby breaking the condition and exiting the loop. - } +```java +while(i<10){ + System.out.println("i :" + i); + i++; //<- This ensures that value of i in the while condition will become more than 10 at some point thereby breaking the condition and exiting the loop. +} +``` Can you now guess the output of the following snippet? - int i = 0; - while( i < 10 ){ - System.out.println("Value of i is : " + i); - i++; - } \ No newline at end of file +```java +int i = 0; +while( i < 10 ){ + System.out.println("Value of i is : " + i); + i++; +} +``` \ No newline at end of file diff --git a/src/pages/java/methods/index.md b/src/pages/java/methods/index.md index 22da76c643d..d20a7f472b1 100644 --- a/src/pages/java/methods/index.md +++ b/src/pages/java/methods/index.md @@ -5,12 +5,14 @@ title: Java Docs Methods `getName()` and `getManufacturerName()` are two "Getter" methods we have used here. Notice, unlike JavaScript, we **have** to define the return type of any method we write, otherwise it will fail at compile time. If you do not want a method to return anything, use `void` return type. - public class Car { - private String name; +```java +public class Car { + private String name; - public void changeName() { - name = "Tesla"; - } + public void changeName() { + name = "Tesla"; } +} +``` As with any other language, methods (or functions, if you are here from JS world) are used often for their modularity and reusability. \ No newline at end of file diff --git a/src/pages/java/strings/index.md b/src/pages/java/strings/index.md index b24e2d09471..c8a8d238dbb 100644 --- a/src/pages/java/strings/index.md +++ b/src/pages/java/strings/index.md @@ -5,8 +5,10 @@ title: Java Docs Strings Strings, as you might be already aware, are a sequence of characters. In Java, a `String` is an `Object`. - String course = "FCC"; - System.out.println( course instanceof Object); //<- This prints 'true' +```java +String course = "FCC"; +System.out.println(course instanceof Object); // <- This prints 'true' +``` You can create a String in the following ways: @@ -19,12 +21,14 @@ Well, using the `new` keyword gurantees that a new `String` object will be creat The following snippet will make things more clearer. The objective is to understand: How many String objects are created? - String str = "This is a string"; - String str2 = "This is a string"; - String str3 = new String("This is a string"); +```java +String str = "This is a string"; +String str2 = "This is a string"; +String str3 = new String("This is a string"); - System.out.println( str == str2 ); //This prints true - System.out.println( str == str3 ); //This prints false +System.out.println(str == str2); // This prints true +System.out.println(str == str3); // This prints false +``` The answer is: 2 String objects are created. diff --git a/src/pages/java/variables/index.md b/src/pages/java/variables/index.md index b80d57827e1..a8d60b7e8eb 100644 --- a/src/pages/java/variables/index.md +++ b/src/pages/java/variables/index.md @@ -15,11 +15,12 @@ We made a distinction between **Wrapper Type** and general **Object Type** for a Typically you can declare variables using the following syntax : - //Primitive Data Type - - int i = 10; - - // Object Data Type - //initiates an Float object with value 1.0 - // variable myFloat now points to the object - Float myFloat = new Float(1.0); \ No newline at end of file +```java +//Primitive Data Type +int i = 10; + +// Object Data Type +// initiates an Float object with value 1.0 +// variable myFloat now points to the object +Float myFloat = new Float(1.0); +``` \ No newline at end of file From df77577a564990b4a126a0a30be9b8b011e1f0a0 Mon Sep 17 00:00:00 2001 From: David Daly Date: Thu, 12 Oct 2017 01:57:02 +0100 Subject: [PATCH 52/89] Add initial article for Gulp (JavaScript content) (#736) * Add initial article for Gulp (JavaScript content) * Update index.md --- src/pages/developer-tools/gulp/index.md | 37 ++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/src/pages/developer-tools/gulp/index.md b/src/pages/developer-tools/gulp/index.md index bac6c0c56c3..167bf59312b 100644 --- a/src/pages/developer-tools/gulp/index.md +++ b/src/pages/developer-tools/gulp/index.md @@ -2,14 +2,43 @@ title: Gulp --- ## Gulp +`Gulp` is a JavaScript task runner that is used for automating various tasks that are parts of a JavaScript development workflow. +It is used to run tasks that you have programmed, and its main use case is to perform repetitive actions that are used as a path of the build process for a JavaScript project. -This is a stub. Help our community expand it. +### Why Gulp is Useful +These tasks often include things like `code minification` (removing whitespace from html files and shortening variable names to make the file size smaller) and `css bundling` (Converting multiple CSS files into one for distribution with your app), which are needed to optimize code to load fast in a web browser. -This quick style guide will help ensure your pull request gets accepted. +The reason that `Gulp` is useful in the above situations is that the minification and bundling process needs to potentially happen with every change. It would not be efficient to do this manually with every change, which is where a tool like `Gulp`, that does this automatically is a great tool for JavaScript developers. - +As well as the relatively simple examples above, `Gulp` has hundreds of plugins to enable it to automate more complex tasks. These tasks can include things like: + +- Running unit tests to test your code is working correctly. +- Refreshing your web browser any time a file is saved, allowing your changes to be viewed instantly. +- Conversion of `SASS` / `LESS` to `CSS`, so that it can be used in a browser. +- Optimising images to create `web friendly` versions with lower file sizes for speed. + +### How to use Gulp +To start using `Gulp`, the first step is to install it using `npm`. After it is installed, a `gulpfile.js` has to be created. This `gulpfile` is a file that contains all the `Gulp` tasks that should run as part of your automated process. The tasks are written in JavaScript. Below is a very simple example of a `gulpfile`, which takes any `CSS` files from the `client/templates` folder, minifies them and puts the minified file in the `build/css` folder. + +```javascript +var gulp = require('gulp'); +var minifyCSS = require('gulp-csso'); + +gulp.task('css', function(){ + return gulp.src('client/templates/*.css') + .pipe(minifyCSS()) + .pipe(gulp.dest('build/css')) +}); +``` + +To run this gulp task, all you would have to do is type `gulp css` in a terminal in your project root. + +Gulpfiles can have multiple tasks per file, and tasks can also be split up into multiple files for an organization. This, along with the 100's of plugins available make it a very flexible and useful framework for JavaScript developers. #### More Information: - +Gulp website + +Gulp github repository + From f44f8c887a365d2d95f2ff1f872a435258e82fc9 Mon Sep 17 00:00:00 2001 From: Vikram Bahl Date: Thu, 12 Oct 2017 09:01:25 +0800 Subject: [PATCH 53/89] add code samples for python string replace (#728) * add code samples for python string replace added code samples and links to documentation for python string replacement * fix --- .../python/string-replace-method/index.md | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/pages/python/string-replace-method/index.md b/src/pages/python/string-replace-method/index.md index bd25a38d708..82a3ef80dc1 100644 --- a/src/pages/python/string-replace-method/index.md +++ b/src/pages/python/string-replace-method/index.md @@ -3,13 +3,36 @@ title: String Replace Method --- ## String Replace Method -This is a stub. Help our community expand it. +The `str.replace(old, new, max)` is used to replace the substring `old` with the string `new` for a total of `max` times. This method returns a new copy of the string with the replacement. The original string `str` is unchanged. -This quick style guide will help ensure your pull request gets accepted. +#### Examples - +1. Replace all occurrences of `"is"` with `"WAS"` -#### More Information: - +```python +string = "This is nice. This is good." +newString = string.replace("is","WAS") +print(newString) +``` + +Output +```python +ThWAS WAS nice. ThWAS WAS good. +``` + +2. Replace the first 2 occurrences of `"is"` with `"WAS"` +```python +string = "This is nice. This is good." +newString = string.replace("is","WAS", 2) +print(newString) +``` + +Output +```python +ThWAS WAS nice. This is good. +``` + +#### More Information: +Read more about string replacement in the [Python docs](https://docs.python.org/2/library/string.html#string.replace) From d43d38ec02e943a55c1d3921723a666e1e5da187 Mon Sep 17 00:00:00 2001 From: Adam Marczyk Date: Thu, 12 Oct 2017 03:02:28 +0200 Subject: [PATCH 54/89] Bootstrap Dropdowns: Add my changes (#726) * Add my changes * Update index.md --- .../bootstrap/bootstrap-dropdowns/index.md | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/src/pages/bootstrap/bootstrap-dropdowns/index.md b/src/pages/bootstrap/bootstrap-dropdowns/index.md index c97f227dc3f..522f7ddd5b5 100644 --- a/src/pages/bootstrap/bootstrap-dropdowns/index.md +++ b/src/pages/bootstrap/bootstrap-dropdowns/index.md @@ -3,13 +3,36 @@ title: Bootstrap Dropdowns --- ## Bootstrap Dropdowns -This is a stub. Help our community expand it. +Bootstrap provides Dropdowns as a plugin for displaying lists of links. +The dropdown is a button which toggles displaying a list of links. -This quick style guide will help ensure your pull request gets accepted. +Bootstrap’s dropdowns are designed to be generic and applicable to a variety of situations. For instance, it is possible to create dropdowns that contain search fields or login forms. - +## Example -#### More Information: - +```html + +``` + + +## Example Explained +The *.dropdown* class indicates a dropdown menu. + +To open the dropdown menu, use a button or a link with a class of *.dropdown-toggle* and the *data-toggle="dropdown* attribute. +The *.caret* class creates a caret arrow icon (▼), which indicates that the button is a dropdown. + +Add the *.dropdown-menu* class to a unordered list element to actually build the dropdown menu. + +#### More Information: +https://getbootstrap.com/docs/4.0/components/dropdowns/ From 834cd8291db60ae71b5d706994e83a9fde02c29c Mon Sep 17 00:00:00 2001 From: Ritik Date: Thu, 12 Oct 2017 06:47:17 +0530 Subject: [PATCH 55/89] Fixed previous errors also added github GUI options and Material Design Lite CSS framework (#619) * added UIKit in CSS frameworks * changed a link * Added ``` to make code look like html * Minor typo fixed * Update index.md * Update index.md * Added MDL framework * Added MDL * Added GUI options for github * fixed a typo * fixed typo * added github GUI options and fixed errors in MDL * Update index.md --- .../css-framework-MaterialDesignLite/index.md | 31 +++++++++++++++++++ .../css-frameworks-UIkit/index.md | 4 +-- src/pages/git/GUI-options/index.md | 11 +++++++ 3 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 src/pages/css/css-frameworks/css-framework-MaterialDesignLite/index.md create mode 100644 src/pages/git/GUI-options/index.md diff --git a/src/pages/css/css-frameworks/css-framework-MaterialDesignLite/index.md b/src/pages/css/css-frameworks/css-framework-MaterialDesignLite/index.md new file mode 100644 index 00000000000..a7de6822c18 --- /dev/null +++ b/src/pages/css/css-frameworks/css-framework-MaterialDesignLite/index.md @@ -0,0 +1,31 @@ +--- +title: CSS Framework Material Design Lite +--- +# CSS Framework UIKit + +Material Design Lite lets you add a Material Design look and feel to your websites. It aims to optimize for cross-device use. + +## Getting Started + +Here is a simple HTML template which includes the latest compiled and minified CSS for the MDL library. + +```html + + + + + + + + + + + +``` + +We have used a CDN in this example, but you can checkout other ways of installing MDL [here](https://getmdl.io/started/index.html). + +### Learning Resources + +* The official documentation for MDL is available [here](https://getmdl.io/started/index.html). +* Checkout MDL's open source GitHub repository [here](https://github.com/google/material-design-lite). diff --git a/src/pages/css/css-frameworks/css-frameworks-UIkit/index.md b/src/pages/css/css-frameworks/css-frameworks-UIkit/index.md index c217eb5535f..5a0a35afeb4 100644 --- a/src/pages/css/css-frameworks/css-frameworks-UIkit/index.md +++ b/src/pages/css/css-frameworks/css-frameworks-UIkit/index.md @@ -28,5 +28,5 @@ We have used a CDN in this example, but you can checkout other ways of installin ### Learning Resources -* The official documentation for UIKit is available here. -* Checkout UIKit's open source GitHub repository here. +* The official documentation for UIKit is available here. +* Checkout UIKit's open source GitHub repository here. diff --git a/src/pages/git/GUI-options/index.md b/src/pages/git/GUI-options/index.md new file mode 100644 index 00000000000..3020f48a0ae --- /dev/null +++ b/src/pages/git/GUI-options/index.md @@ -0,0 +1,11 @@ +--- +title: GUI Options +--- +# GUI Options for GitHub + +Although mostly people prefer to use git as a clit tool but there are plenty of git gui based solutions available which are more user friendly. + +## List of Git GUI Based Solutions + +* **GitKraken**-GitKraken is the most popular Git GUI for Windows, Mac AND Linux.You can look [here](https://www.gitkraken.com/) to download the latest stable release of Kraken. +* **GitHub Desktop**-GitHub Desktop is the official git client application provided by GitHub.Github Desktop offers the most amazing GUI based experience to GitHub but it isn't available for Linux Users yet.Windows and Mac users can download the latest stable release [here](https://desktop.github.com/). From ffbbfcc7e3b2e4c249b3f9c114b1790f5b80479f Mon Sep 17 00:00:00 2001 From: Vikram Bahl Date: Thu, 12 Oct 2017 09:17:49 +0800 Subject: [PATCH 56/89] add info on python string split (#725) * add info on python string split add code samples on python string splitting * update string split in python The Travis CI buld didn't pass. The error was: Error: Error reading the frontmatter from "src/pages/python/string-split-method/index.md" I figure it maybe something to do with formatting. I have removed some quotes surrounded by backticks to see if this approach works. * update title * Update index.md --- src/pages/python/string-split-method/index.md | 68 +++++++++++++++++-- 1 file changed, 62 insertions(+), 6 deletions(-) diff --git a/src/pages/python/string-split-method/index.md b/src/pages/python/string-split-method/index.md index 10dd4472093..ed4fbdcc7c7 100644 --- a/src/pages/python/string-split-method/index.md +++ b/src/pages/python/string-split-method/index.md @@ -1,15 +1,71 @@ --- title: String Split Method --- -## String Split Method -This is a stub. Help our community expand it. +The `split()` function is commonly used for string splitting in Python. -This quick style guide will help ensure your pull request gets accepted. +#### The `split()` method - +Template: `string.split(separator, maxsplit)` -#### More Information: - +`separator`: The delimiter string. You split the string based on this character. For eg. it could be " ", ":", ";" etc +`maxsplit`: The number of times to split the string based on the `separator`. If not specified or -1, the string is split based on all occurrences of the `separator` +This method returns a list of substrings delimited by the `separator` + +#### Examples + +1) Split string on space: " " +```python +string = "freeCodeCamp is fun." +print(string.split(" ")) +``` +Output: +```python +['freeCodeCamp', 'is', 'fun.'] +``` + +2) Split string on comma: "," +```python +string = "freeCodeCamp,is fun, and informative" +print(string.split(",")) +``` +Output: +```python +['freeCodeCamp', 'is fun', ' and informative'] +``` + +3) No `separator` specified +```python +string = "freeCodeCamp is fun and informative" +print(string.split()) +``` +Output: +```python +['freeCodeCamp', 'is', 'fun', 'and', 'informative'] +``` +Note: If no `separator` is specified, then the string is stripped of __all__ whitespace + +```python +string = "freeCodeCamp is fun and informative" +print(string.split()) +``` +Output: +```python +['freeCodeCamp', 'is', 'fun', 'and', 'informative'] +``` + +3) Split string using `maxsplit`. Here we split the string on " " twice: +```python +string = "freeCodeCamp is fun and informative" +print(string.split(" ", 2)) +``` +Output: +```python +['freeCodeCamp', 'is', 'fun and informative'] +``` + +#### More Information + +Check out the [Python docs on string splitting](https://docs.python.org/2/library/stdtypes.html#str.split) From 37af504a2c863299056b328c0946f0f20981f0e8 Mon Sep 17 00:00:00 2001 From: Dylan Date: Wed, 11 Oct 2017 22:49:04 -0500 Subject: [PATCH 57/89] editing --- src/pages/security/social-engineering/index.md | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/pages/security/social-engineering/index.md b/src/pages/security/social-engineering/index.md index 4f21ddd2ab0..90d17f43b83 100644 --- a/src/pages/security/social-engineering/index.md +++ b/src/pages/security/social-engineering/index.md @@ -3,7 +3,7 @@ title: Social Engineering --- ## Social Engineering -Social Engineering is the art of gaining access to a secured system or resource by exploiting human behavior. It involves tricking people into breaking normal security procedures. Most attack vectors rely heavily on leveraging technical skills to find gaps in the security system. Social Engineering relies heavily on having a good understanding of human psychology. Thoroughly researching the target weeks before an attack makes social engineering a powerful tool in the hands of the attacker. +Social Engineering is the art of gaining access to a secured system or resource by exploiting human behavior. It involves tricking people into breaking normal security procedures. Most attack vectors rely heavily on leveraging technical skills to find gaps in the security system. Social Engineering relies heavily on having a good understanding of human psychology. Thoroughly researching the target before an attack makes social engineering a powerful tool in the hands of the attacker. #### Traits of a good Social Engineering Hacker @@ -11,23 +11,25 @@ Social Engineering is the art of gaining access to a secured system or resource * Intuitive understanding of human psychology * Charming and persuasive * Patient and observant -* Adept at predicting human behavior based on exploiting our need to be helpful, curious, greedy and vane +* Adept at predicting human behavior based on exploiting the human need to be helpful, curious, greedy and vain #### Some examples of Social Engineering hacks -* Baiting: Leaving a malware infected USB at a coffee shop in the hope that someone is curious enough to plug it in and check it out. Once the person plugs the USB in, malware is installed on their computer +* Baiting: Leaving a malware infected USB at a coffee shop in the hope that someone is curious enough to plug it in and check it out. Once the person plugs the USB in, malware is installed on their computer. -* Pretexting: Telling lies to gain access to private information. For eg, pretending to be a bank officer and ask people for personal information to 'confirm their account'. +* Pretexting: Telling lies to gain access to private information. An example would be impersonating a bank officer and asking people for personal information to 'confirm their account'. -* Phishing: Send an email which looks like it is from a trusted source to bait the user into clicking a link (to install malware) or replying with private information. +* Phishing: Sending an email which looks like it is from a trusted source to bait the user into clicking a link (to install malware) or replying with private information. #### More Information: Read on more information on social engineering hacks and steps you can take to protct yourself from one: [What is Social Engineering?](https://www.webroot.com/us/en/home/resources/tips/online-shopping-banking/secure-what-is-social-engineering) -[Protect yourself Social Engineering attacks](http://www.makeuseof.com/tag/protect-8-social-engineering-attacks/) -[7 best Social Engineering hacks](https://www.darkreading.com/the-7-best-social-engineering-attacks-ever/d/d-id/1319411?) + +[Protect Yourself from Social Engineering Attacks](http://www.makeuseof.com/tag/protect-8-social-engineering-attacks/) + +[7 Best Social Engineering Hacks Ever](https://www.darkreading.com/the-7-best-social-engineering-attacks-ever/d/d-id/1319411?) From 4fde90a652e7475077d72bc1d20fd05b318af1b3 Mon Sep 17 00:00:00 2001 From: Rich Date: Thu, 12 Oct 2017 08:46:54 -0500 Subject: [PATCH 58/89] Spelling corrections --- src/pages/html/attributes/a-href-attribute/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/html/attributes/a-href-attribute/index.md b/src/pages/html/attributes/a-href-attribute/index.md index 2e86d61b1ac..583b5de7f19 100644 --- a/src/pages/html/attributes/a-href-attribute/index.md +++ b/src/pages/html/attributes/a-href-attribute/index.md @@ -3,7 +3,7 @@ title: A Href Attribute --- ## A Href Attribute -The `` atrribute refers to a destination provided by a link. The `a` (anchor) tag is dead without the `` attribute. Sometimes in your workflow, you don't want a live link or you won't know the link destination yet. In this case, it's useful to set the `href` attribute to `"#"` to create a dead link. +The `` attribute refers to a destination provided by a link. The `a` (anchor) tag is dead without the `` attribute. Sometimes in your workflow, you don't want a live link or you won't know the link destination yet. In this case, it's useful to set the `href` attribute to `"#"` to create a dead link. For instance: @@ -20,7 +20,7 @@ For instance: ``` -The `` attributes is supported by all browsers. +The `` attribute is supported by all browsers. ### Examples ```html From ca2fd32fbea9ec13261bee2038b19a040acef6ec Mon Sep 17 00:00:00 2001 From: Beth Qiang Date: Thu, 12 Oct 2017 08:53:25 -0500 Subject: [PATCH 59/89] Add article for remote vs onsite --- .../remote-versus-onsite/index.md | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/pages/working-in-tech/remote-versus-onsite/index.md b/src/pages/working-in-tech/remote-versus-onsite/index.md index 5dae9e6b6c3..c2031896c2c 100644 --- a/src/pages/working-in-tech/remote-versus-onsite/index.md +++ b/src/pages/working-in-tech/remote-versus-onsite/index.md @@ -3,13 +3,28 @@ title: Remote Versus Onsite --- ## Remote Versus Onsite -This is a stub. Help our community expand it. +There are two main work environments: onsite and remote. -This quick style guide will help ensure your pull request gets accepted. +### Onsite Work - +Onsite work is what you might think of when you think of a 9-5 job. When you're onsite, you may either be in your company's office or at a client's office. Either way, you're in the same physical location as the rest of the people with whom you work. -#### More Information: - +### Remote Work + +Remote work occurs when team members work in separate physical locations. You can work from anywhere: your home (no commute!), a co-working space (sometimes paid for by your employer), or even a beach in Thailand. Often your only restriction is that you have internet access. + +Because in-person communication occurs less frequently (if at all), remote teams often rely more on communication software like Slack and Skype. + +Remote teams may host regular company retreats so team members can meet and hang out. + +### The "In-Between" + +Some companies are 100% onsite, and some are 100% remote. But, it's not unusual to find companies or teams that allow you to work remotely a day or two out of the week. This allows you to experience some of the benefits of remote work, without being remote all the time. + +Some companies also have a physical office where you can go to work if you'd like, but allow you to work wherever. + +### More Information: + +Quincy Larson on The Economics of Working Remotely: [Medium](https://medium.freecodecamp.org/the-economics-of-working-remotely-28d4173e16e2) From a9e2f0eedfc6d17929044a4be82da336f9c593e4 Mon Sep 17 00:00:00 2001 From: Rich Date: Thu, 12 Oct 2017 08:56:46 -0500 Subject: [PATCH 60/89] Correct syntax, formatting, and attribute --- src/pages/html/attributes/body-background-attribute/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/html/attributes/body-background-attribute/index.md b/src/pages/html/attributes/body-background-attribute/index.md index 43491e510a1..4509cceef02 100644 --- a/src/pages/html/attributes/body-background-attribute/index.md +++ b/src/pages/html/attributes/body-background-attribute/index.md @@ -3,7 +3,7 @@ title: Body Background Attribute --- ## Body Background Attribute -If you want to add the background image instead of a color, one solution is Background Attribute. It is specified a background image for an HTML document. +If you want to add a background image instead of a color, one solution is the `` attribute. It specifies a background image for an HTML document. Syntax: @@ -13,7 +13,7 @@ Syntax: Attribute: -`URL - URL for background image` +`background - URL for background image` Example: From 59a2423870c43a4ea6b5a02e2a377c06c1d24a60 Mon Sep 17 00:00:00 2001 From: dharanee dharan Date: Thu, 12 Oct 2017 19:32:50 +0530 Subject: [PATCH 61/89] Add Security->Backdoor article --- src/pages/security/backdoors/index.md | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/pages/security/backdoors/index.md b/src/pages/security/backdoors/index.md index a7f948b9e0b..0409ae10571 100644 --- a/src/pages/security/backdoors/index.md +++ b/src/pages/security/backdoors/index.md @@ -2,14 +2,20 @@ title: Backdoors --- ## Backdoors +A backdoor in software or a computer system is generally an undocumented portal that allows an administrator to enter the system to troubleshoot or do upkeep. But it also refers to a secret portal that hackers and intelligence agencies use to gain illicit access. -This is a stub. Help our community expand it. +A backdoor has multiple meanings. It can refer to a legitimate point of access embedded in a system or software program for remote administration. -This quick style guide will help ensure your pull request gets accepted. +Generally this kind of backdoor is undocumented and is used for the maintenance and upkeep of software or a system. Some administrative backdoors are protected with a hardcoded username and password that cannot be changed; though some use credentials that can be altered. Often, the backdoor's existence is unknown to the system owner and is known only to the software maker. Built-in administrative backdoors create a vulnerability in the software or system that intruders can use to gain access to a system or data. - +Attackers also can install their own backdoor on a targeted system. Doing so allows them to come and go as they please and gives them remote access to the system. Malware installed on systems for this purpose is often called a remote access Trojan, or a RAT, and can be used to install other malware on the system or exfiltrate data. -#### More Information: - +Backdoors of another sort gained notoriety in 2013 when NSA documents leaked to the media by whistleblower Edward Snowden revealed a decades-long effort by the spy agency, in partnership with Britain's GCHQ, to pressure companies into installing backdoors in their products. They particularly focused pressure on the makers of encryption systems. These secret backdoors allow the intelligence agencies to circumvent or undermine security protections and surreptitiously access systems and data. + +One of the most controversial backdoor cases involved the NSA's reported efforts to intentionally weaken an encryption algorithm known as the NIST SP800-90 Dual Ec Prng so that any data encrypted with the algorithm would be susceptible to cracking by the NSA. + +### More Information: +* What is a backdoor: [Incapsula](https://www.incapsula.com/web-application-security/backdoor-shell-attack.html) +* Backdoor article: [Wikipedia](https://en.wikipedia.org/wiki/Backdoor_(computing)) From 0f9f48a16633fbce8f98225e74c22375feff6968 Mon Sep 17 00:00:00 2001 From: Joe Date: Thu, 12 Oct 2017 07:18:41 -0700 Subject: [PATCH 62/89] Add Taskboard and Kanban article Images, external links for reference and online boards. * Edit more information link formatting --- .../agile/task-boards-and-kanban/index.md | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/src/pages/agile/task-boards-and-kanban/index.md b/src/pages/agile/task-boards-and-kanban/index.md index 819705cd290..8965ed31576 100644 --- a/src/pages/agile/task-boards-and-kanban/index.md +++ b/src/pages/agile/task-boards-and-kanban/index.md @@ -2,14 +2,29 @@ title: Task Boards and Kanban --- ## Task Boards and Kanban +Kanban is an excellent method both for teams doing software development and individuals tracking their personal tasks. -This is a stub. Help our community expand it. +Derived from the Japanese term for "signboard" or "billboard" to represent a signal, the key principal is to limit your work-in-progress (WIP) to a finite number of tasks at a given time. The amount that can be In Progress is determined by the team's (or individual's) constrained capacity. As one task is finished, that's the signal for you to move another task forward into its place. -This quick style guide will help ensure your pull request gets accepted. +Your Kanban tasks are displayed on the Task Board in a series of columns that show the state of the tasks. In its simplest form, three columns are used +- To Do +- Doing +- Done - +![Kanban Board Example](https://upload.wikimedia.org/wikipedia/commons/thumb/d/d3/Simple-kanban-board-.jpg/600px-Simple-kanban-board-.jpg) -#### More Information: - +*Image courtesy of [wikipedia](https://en.wikipedia.org/wiki/Kanban_board)* +But many other columns, or states, can be added. A software team may also include Waiting to Test, Complete, or Accepted, for example. +![More Complicated Example](https://mktgcdn.leankit.com/uploads/images/general/_2048xAUTO_fit_center-center/1-SmalDevelopmentTeamKanbanBoard-eb79376d.png) + +*Image courtesy of [leankit](https://leankit.com/learn/kanban/kanban-board-examples-for-development-and-operations/)* + +### More Information: +- What is Kanban: [Leankit](https://leankit.com/learn/kanban/what-is-kanban/) +- What is Kanban: [Atlassian](https://www.atlassian.com/agile/kanban) + +Some online boards +- [Trello](https://trello.com/) +- [KanbanFlow](https://kanbanflow.com) From ca1220c52e58cc08e8cda7c66ea22f147b1473b7 Mon Sep 17 00:00:00 2001 From: Mark Mitchell Date: Thu, 12 Oct 2017 15:30:22 +0100 Subject: [PATCH 63/89] Add agile story and complexity points article --- .../index.md | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/pages/agile/story-points-and-complexity-points/index.md b/src/pages/agile/story-points-and-complexity-points/index.md index 2daf5423db8..0bf58e7ccb7 100644 --- a/src/pages/agile/story-points-and-complexity-points/index.md +++ b/src/pages/agile/story-points-and-complexity-points/index.md @@ -3,13 +3,21 @@ title: Story Points and Complexity Points --- ## Story Points and Complexity Points -This is a stub. Help our community expand it. +In Scrum/Agile, the functionality of a product in development is explored by way of **stories** a user might tell about what they want from a product. A team uses **Story Points** when they estimate the amount of effort required to deliver a user story. -This quick style guide will help ensure your pull request gets accepted. +Notable features of story points are that they: - +* represent the contributions of the whole team +* do not equate directly to time the task might take +* are a rough measure for planning purposes - similar to orders of magnitude +* are assigned in a Fibonacci-like sequence: 0, 1, 2, 3, 5, 8, 13, 20, 40, 100 +* estimate the 'size' of stories *relative to each other* -#### More Information: - +The concept of story points can be quite elusive if you are new to Agile ways of doing things. You will find many online sources discussing story points in different ways, and it can be hard to get a clear idea of what they are and how they are used. +As you learn about the principles and terminology of practices like Scrum, the reasons for some of these properties will become apparent. The use of story points, especially in 'ceremonies' such as planning poker, is much easier to understand by observing or taking part than in a written explanation! +### More Information: +- User Stories: [freeCodeCamp](https://guide.freecodecamp.org/agile/user-stories) +- Common mistakes when using story points: [Medium](https://medium.com/bynder-tech/12-common-mistakes-made-when-using-story-points-f0bb9212d2f7) +- Planning Poker: [Mountain Goat Software](https://www.mountaingoatsoftware.com/agile/planning-poker) From 956a151d2698bca31686772e4fbc1f05ad7133de Mon Sep 17 00:00:00 2001 From: charlesinwald Date: Thu, 12 Oct 2017 10:40:10 -0400 Subject: [PATCH 64/89] Linux: add How to Use SFTP to Securely Transfer Files with a Remote Server (#706) --- .../index.md | 40 ++++++++++++++----- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/src/pages/linux/how-to-use-sftp-to-securely-transfer-files-with-a-remote-server/index.md b/src/pages/linux/how-to-use-sftp-to-securely-transfer-files-with-a-remote-server/index.md index 3e4d5cbfc2c..406beb726d6 100644 --- a/src/pages/linux/how-to-use-sftp-to-securely-transfer-files-with-a-remote-server/index.md +++ b/src/pages/linux/how-to-use-sftp-to-securely-transfer-files-with-a-remote-server/index.md @@ -1,15 +1,35 @@ --- -title: How to Use Sftp to Securely Transfer Files with a Remote Server +title: How to Use SFTP to Securely Transfer Files with a Remote Server --- -## How to Use Sftp to Securely Transfer Files with a Remote Server +## How to Use SFTP to Securely Transfer Files with a Remote Server +This article is a quick tutorial on how to use Secure File Transfer Protocol (SFTP) to exhange files with a server. This is useful for programming, as it allows you to code and test locally, and then send your work to the server when you are done. -This is a stub. Help our community expand it. - -This quick style guide will help ensure your pull request gets accepted. - - - -#### More Information: - +### Testing SSH +If you haven't already, test that you are able to SSH into the server. SFTP uses the Secure Shell (SSH) protocol, so if you are unable to SSH you probably won't be able to SFTP either. +```unix +ssh your_username@hostname_or_ip_address +``` +### Start SFTP Session +This uses the same syntax as SSH and opens a session in which you can transfer files. +```unix +sftp your_username@hostname_or_ip_address +``` +To list helpful commands: +```unix +help +``` +### Transfer files and folders +To download a file: +```unix +get +``` +To download a folder and its contents, use the "-r" flag (also works for uploading): +```unix +get -r +``` +To upload a file: +```unix +put +``` From 93abc5cedadebbf38a5eaa5d15899c1945ae6dbf Mon Sep 17 00:00:00 2001 From: Manpreet Krishan <13thThief@users.noreply.github.com> Date: Thu, 12 Oct 2017 22:57:27 +0530 Subject: [PATCH 65/89] Format the hyperlink (#359) * Format the hyperlink * fix stuff --- .../javascript/return-statements/index.md | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/pages/javascript/return-statements/index.md b/src/pages/javascript/return-statements/index.md index f81438237eb..2c360c49e21 100644 --- a/src/pages/javascript/return-statements/index.md +++ b/src/pages/javascript/return-statements/index.md @@ -5,26 +5,36 @@ title: Return Statement When a **return** statement is called in a function, the execution of this function is stopped. If specified, a given value is returned to the function caller. If the expression is omitted, `undefined` is returned instead. - return [[expression]]; - -[MDN link | MSDN link +```js + return expression; +``` ## Examples The following function returns the square of its argument, **x**, where **x** is a number. +```js function square(x) { return x * x; } - +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code The following function returns the product of its arguments, **arg1** and **arg2**. +```js function myfunction(arg1, arg2){ var r; r = arg1 * arg2; return(r); } +``` ![:rocket:](//forum.freecodecamp.com/images/emoji/emoji_one/rocket.png?v=2 ":rocket:") Run Code + + +#### More Information: + +MDN link + +MSDN link \ No newline at end of file From 2ddeebe4524fb56deef3cecaf88c5e3d5bca9177 Mon Sep 17 00:00:00 2001 From: Vikram Bahl Date: Fri, 13 Oct 2017 01:36:04 +0800 Subject: [PATCH 66/89] add examples for python substring from string (#690) * add examples for python substring from string added code samples and templates demonstrating slicing in python strings * Update index.md --- .../index.md | 98 ++++++++++++++++++- 1 file changed, 93 insertions(+), 5 deletions(-) diff --git a/src/pages/python/is-there-a-way-to-substring-a-string-in-python/index.md b/src/pages/python/is-there-a-way-to-substring-a-string-in-python/index.md index 4935cabd963..7109d100d1e 100644 --- a/src/pages/python/is-there-a-way-to-substring-a-string-in-python/index.md +++ b/src/pages/python/is-there-a-way-to-substring-a-string-in-python/index.md @@ -1,15 +1,103 @@ --- title: Is There a Way to Substring a String in Python --- + ## Is There a Way to Substring a String in Python -This is a stub. Help our community expand it. +Python offers many ways to substring a string. It is often called 'slicing'. + +It follows this template: + +```python +string[start: end: step] +``` +Where, + +`start`: The starting index of the substring. The character at this index is included in the substring. If _start_ is not included, it is assumed to equal to 0. + +`end`: The terminating index of the substring. The character at this index is _NOT_ included in the substring. If _end_ is not included, the substring goes from _start_ till the end of the string. + +`step`: Every 'step' character after the current character to be included. The default value is 1. If the _step_ value is omitted, it is assumed to equal to 1. + +#### Template + +`string[start:end]`: Get all characters from index _start_ to _end-1_ + +`string[:end]`: Get all characters from the beginning of the string to _end-1_ + +`string[start:]`: Get all characters from index _start_ to the end of the string + +`string[start:end:step]`: Get all characters from _start_ to _end-1_ discounting every _step_ character + + +#### Examples + +* **Get the first 5 characters of a string** + +```python +string = "freeCodeCamp" +print(string[0:5]) +``` +Output: +```shell +> freeC +``` + +Note: `print(string[:5])` returns the same result as `print(string[0:5])` + +* **Get a substring of length 4 from the 3rd character of the string** + +```python +string = "freeCodeCamp" +print(string[2:6]) +``` +Output: +```shell +> eeCo +``` + +* **Get the last character of the string** + +```python +string = "freeCodeCamp" +print(string[-1]) +``` +Output: +```shell +> p +``` + +Note: Python can handle negative indices. Index -1 represents the last character of the string, -2 represents the second to last character and so on... + +* **Get the last 5 characters of a string** -This quick style guide will help ensure your pull request gets accepted. +```python +string = "freeCodeCamp" +print(string[-5:]) +``` +Output: +```shell +> eCamp +``` - +* **Get a substring which contains all characters except the last 4 characters and the 1st character** -#### More Information: - +```python +string = "freeCodeCamp" +print(string[1:-4]) +``` +Output: +```shell +> reeCode +``` +* **Get every other character from a string** +```python +string = "freeCodeCamp" +print(string[::2]) +``` +Output: +```shell +> feCdCm +``` From 08373bf050c20988a22b7028748d951f6a05b10b Mon Sep 17 00:00:00 2001 From: Vikram Bahl Date: Fri, 13 Oct 2017 01:43:02 +0800 Subject: [PATCH 67/89] add code samples on python string join (#724) * add code samples on python string join added code samples on the different ways to join string based iterables in python * update title line added title: String Join Method to head of file * Update index.md --- src/pages/python/string-join-method/index.md | 35 +++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/src/pages/python/string-join-method/index.md b/src/pages/python/string-join-method/index.md index 6b4e56fec2f..021482052e9 100644 --- a/src/pages/python/string-join-method/index.md +++ b/src/pages/python/string-join-method/index.md @@ -3,13 +3,38 @@ title: String Join Method --- ## String Join Method -This is a stub. Help our community expand it. +The `str.join(iterable)` method is used to join all elements in an `iterable` with a specified string ```str```. -This quick style guide will help ensure your pull request gets accepted. +`iterable`: All iterables of string. Could a list of strings, tuple of string or even a plain string. - +#### Examples -#### More Information: - +1) Join a ist of strings with `":"` +```python +print ":".join(["freeCodeCamp", "is", "fun"]) +``` +Output +```shell +freeCodeCamp:is:fun +``` + +2) Join a tuple of strings with `" and "` +```python +print " and ".join(["A", "B", "C"]) +``` +Output +```shell +A and B and C +``` +3) Insert a `" "` after every character in a string +```python +print " ".join("freeCodeCamp") +``` +Output: +```shell +f r e e C o d e C a m p +``` +#### More Information: +[python documentation on string join](https://docs.python.org/2/library/stdtypes.html#str.join) From 844915ddf1817a995a1be9e369afa16ead2dfada Mon Sep 17 00:00:00 2001 From: Attaphong R Date: Fri, 13 Oct 2017 00:44:22 +0700 Subject: [PATCH 68/89] Add Rust language in the pages --- src/pages/rust/index.md | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 src/pages/rust/index.md diff --git a/src/pages/rust/index.md b/src/pages/rust/index.md new file mode 100644 index 00000000000..bee0698bb59 --- /dev/null +++ b/src/pages/rust/index.md @@ -0,0 +1,8 @@ +--- +title: Rust +--- +## Rust + +Rust is a systems programming language focused on three goals: safety, speed, and concurrency. It maintains these goals without having a garbage collector, making it a useful language for a number of use cases other languages aren’t good at: embedding in other languages, programs with specific space and time requirements, and writing low-level code, like device drivers and operating systems. + +For more information head to Rust's Homepage. From 503fd67f7f0f488f7c0785a492b3f61e3cd2556d Mon Sep 17 00:00:00 2001 From: Richard Vankoningsveld Date: Fri, 13 Oct 2017 03:53:33 +1000 Subject: [PATCH 69/89] Add Python string find method page (#722) * Add Python string find method page * Update index.md --- src/pages/python/string-find-method/index.md | 26 ++++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/pages/python/string-find-method/index.md b/src/pages/python/string-find-method/index.md index bad2db965ad..981cbf701fb 100644 --- a/src/pages/python/string-find-method/index.md +++ b/src/pages/python/string-find-method/index.md @@ -3,13 +3,29 @@ title: String Find Method --- ## String Find Method -This is a stub. Help our community expand it. +There are two options for finding a substring within a string in Python, `find()` and `rfind()`. -This quick style guide will help ensure your pull request gets accepted. +Each will return the position that the substring is found at. The difference between the two is that `find()` returns the lowest position, and `rfind()` returns the highest position. - +Optional start and end arguments can be provided to limit the search for the substring to within portions of the string. -#### More Information: - +Example: +```shell +>>> string = "Don't you call me a mindless philosopher, you overweight glob of grease!" +>>> string.find('you') +6 +>>> string.rfind('you') +42 +``` +If the substring is not found, -1 is returned. +```shell +>>> string = "Don't you call me a mindless philosopher, you overweight glob of grease!" +>>> string.find('you', 43) # find 'you' in string anywhere from position 43 to the end of the string +-1 +``` + +More Information: + +String methods [documentation](https://docs.python.org/3/library/stdtypes.html#string-methods). From f401da72c06078968b771f3b7c62d3908e73c6c6 Mon Sep 17 00:00:00 2001 From: Mike Frazier Date: Thu, 12 Oct 2017 15:30:54 -0600 Subject: [PATCH 70/89] Clean up styling of table (#859) * Clean up styling of table Fix link to MSDN page * Update index.md --- .../javascript/assignment-operators/index.md | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/src/pages/javascript/assignment-operators/index.md b/src/pages/javascript/assignment-operators/index.md index 21bbbad2eae..19830a52550 100644 --- a/src/pages/javascript/assignment-operators/index.md +++ b/src/pages/javascript/assignment-operators/index.md @@ -1,21 +1,18 @@ --- title: Assignment Operators --- -Assignment operators, as the name suggests, assign (or re-assign) values to a variable. While there are quite a few variations on the assignment operators, they all build off of the basic assignment operator. - -## Syntax - x = y; +# Assignment Operators - | Description | Necessity +Assignment operators, as the name suggests, assign (or re-assign) values to a variable. While there are quite a few variations on the assignment operators, they all build off of the basic assignment operator. ---------- | --------------------------------------------- | --------- -x | Variable | Required -= | Assignment operator | Required -y | Value to assign to variable | Required +## Syntax -MDN link -MSDN link.aspx) +`x = y;` | Description | Necessity +:---------:|:---------------------:|:---------: +`x` | Variable | Required +`=` | Assignment operator | Required +`y` | Value to assign to variable | Required ## Examples @@ -58,3 +55,9 @@ Unsigned right shift assignment | x >>>= y | x = x >>> y Bitwise AND assignment | x &= y | x = x & y Bitwise XOR assignment | x ^= y | x = x ^ y Bitwise OR assignment | x |= y | x = x | y + +### More Information: + +MDN link + +MSDN link From d43d327cff4bf07b09784db9a0783bf5fe8dbf91 Mon Sep 17 00:00:00 2001 From: Pragadheesh Date: Fri, 13 Oct 2017 03:05:11 +0530 Subject: [PATCH 71/89] Updated information on slicing arguments (#858) --- .../index.md | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/pages/python/is-there-a-way-to-substring-a-string-in-python/index.md b/src/pages/python/is-there-a-way-to-substring-a-string-in-python/index.md index 7109d100d1e..5ecb30ec30b 100644 --- a/src/pages/python/is-there-a-way-to-substring-a-string-in-python/index.md +++ b/src/pages/python/is-there-a-way-to-substring-a-string-in-python/index.md @@ -15,7 +15,7 @@ Where, `start`: The starting index of the substring. The character at this index is included in the substring. If _start_ is not included, it is assumed to equal to 0. -`end`: The terminating index of the substring. The character at this index is _NOT_ included in the substring. If _end_ is not included, the substring goes from _start_ till the end of the string. +`end`: The terminating index of the substring. The character at this index is _NOT_ included in the substring. If _end_ is not included, or if the specified value exceeds the string length, it is assumed to be equal to the length of the string by default. `step`: Every 'step' character after the current character to be included. The default value is 1. If the _step_ value is omitted, it is assumed to equal to 1. @@ -56,6 +56,8 @@ Output: > eeCo ``` +Please note that the start or end index may be a negative number. A negative index means that you start counting from the end of the string instead of the beginning (i.e from the right to left). Index -1 represents the last character of the string, -2 represents the second to last character and so on... + * **Get the last character of the string** ```python @@ -67,8 +69,6 @@ Output: > p ``` -Note: Python can handle negative indices. Index -1 represents the last character of the string, -2 represents the second to last character and so on... - * **Get the last 5 characters of a string** ```python @@ -91,6 +91,14 @@ Output: > reeCode ``` +#### More examples +```py +str = “freeCodeCamp” + +print str[-5:-2] # prints ‘eCa’ +print str[-1:-2] # prints ‘’ (empty string) +``` + * **Get every other character from a string** ```python From 9e39c0113956e9607e9e67b15385ff03c49059f1 Mon Sep 17 00:00:00 2001 From: Dylan Date: Thu, 12 Oct 2017 18:09:19 -0500 Subject: [PATCH 72/89] editing --- src/pages/html/elements/body/index.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pages/html/elements/body/index.md b/src/pages/html/elements/body/index.md index 1fa5f246634..58c669ebc21 100644 --- a/src/pages/html/elements/body/index.md +++ b/src/pages/html/elements/body/index.md @@ -3,9 +3,9 @@ title: Body --- ## Body -

The <body> tag contains the content for a webpage. Along with <head>, it is one of the two required elements of an HTML document. <body> must be the second child of an <html> element. There can only be one <body> element on a page. +

The `` tag contains the content for a webpage. Along with ``, it is one of the two required elements of an HTML document. `` must be the second child of an `` element. There can only be one `` element on a page. -The <body> element should contain all of a page's content, including all display elements. The <body> element can also contain <script> tags, generally scripts that must be run after a page's content has been loaded. +The `` element should contain all of a page's content, including all display elements. The `` element can also contain ` + + + + + + + + + + + + +

+ + + + +``` + +#### Understanding the Attributes and classes used : + +a) `data-toggle = "modal"` : It opens up the modal. + +b) `data-target` : It points to the Id of the modal to open up. + +c) `data-dismiss="modal"` : This causes the popup to close when clicked on close button. + +d) `.modal` class identifies the contents of `
` as a modal. + +e) `.modal-dialog` class sets the proper height and width of the dialog. + +f) `.modal-content` class styles the modal.It contains header,body and footer sections. + +g) `.modal-header` class denotes the header section of the modal (title and (×) button). + +h) `.modal-title` class styles the header of the modal with a proper height. + +i) `.modal-body` class styles the body of the modal(dialog/popup).It can have other markups like `

,,

tag for proper display (#882) * Remove opening

tag for proper display * Update index.md --- src/pages/html/elements/body/index.md | 32 ++++++++++++++------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/pages/html/elements/body/index.md b/src/pages/html/elements/body/index.md index 58c669ebc21..f0ea1b2574e 100644 --- a/src/pages/html/elements/body/index.md +++ b/src/pages/html/elements/body/index.md @@ -1,23 +1,25 @@ --- title: Body --- + ## Body - -

The `` tag contains the content for a webpage. Along with ``, it is one of the two required elements of an HTML document. `` must be the second child of an `` element. There can only be one `` element on a page. + +The `` tag contains the content for a webpage. Along with ``, it is one of the two required elements of an HTML document. `` must be the second child of an `` element. There can only be one `` element on a page. The `` element should contain all of a page's content, including all display elements. The `` element can also contain `