<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://classes.engineering.wustl.edu/cse330/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=James</id>
	<title>CSE330 Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="http://classes.engineering.wustl.edu/cse330/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=James"/>
	<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Special:Contributions/James"/>
	<updated>2026-11-15T21:53:48Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.34.4</generator>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2315</id>
		<title>Module 7</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7&amp;diff=2315"/>
		<updated>2017-04-07T01:28:37Z</updated>

		<summary type="html">&lt;p&gt;James: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
This module will be teaching “Angular JS,” a framework that works with Javascript and HTML to create a front-end of a website much easier and faster. It is part of the oft-used “MEAN stack,” which is a stack that entirely uses Javascript, for the database, back-end, and front-end. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Optional Reading == &lt;br /&gt;
To learn more about the MEAN stack, as well as using Git to do more than check out and commit repos, check out the old module 7 reference pages:&lt;br /&gt;
*[[Git]]&lt;br /&gt;
*[[Preparations]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignment ==&lt;br /&gt;
	In this assignment you will build an Angular website. To learn Angular, please view and complete [https://code.angularjs.org/1.4.7/docs/tutorial this] tutorial, and focus on steps 0-10.  The other steps and the tests at the bottom of each step are helpful and to master Angular you will need to learn these. However, for this module, you are not required to do these parts. &lt;br /&gt;
&lt;br /&gt;
	Now that you have finished the tutorial, we will make a coffee rating website!&lt;br /&gt;
&lt;br /&gt;
=== Setting up ===&lt;br /&gt;
	To help you get started, download a skeleton on which you will build your angular app on, called Angular-Seed. Go [https://github.com/angular/angular-seed/blob/master/README.md here] and follow the instruction to download the seed, naming your project ‘coffees’. &lt;br /&gt;
&lt;br /&gt;
'''Note:''' If you are running the Angular-Seed project from EC2, open the '''package.json''' file in the coffees directory&lt;br /&gt;
&lt;br /&gt;
Find the line that says&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -a localhost -p 8000 -c-1&amp;quot;, &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
and change it to&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&amp;quot;start&amp;quot;: &amp;quot;http-server -p 8000 -c-1&amp;quot;,&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will allow for connections other than just localhost. &lt;br /&gt;
&lt;br /&gt;
	'''Note''': Although you can ignore a lot of these files (the node directory, the karma files, view1/view2, etc), by downloading the seed you can get around issues such as creating the server (this does it for you), and if you were going to use a backend, having node all set up for you is really nice. &lt;br /&gt;
&lt;br /&gt;
Now that you’ve downloaded the seed, you will need to modify the following files: app.js, and index.html. Furthermore, you will add the following files: coffees.html, and reviews.html.&lt;br /&gt;
&lt;br /&gt;
=== Creating the Site ===&lt;br /&gt;
	&lt;br /&gt;
Your site will need to use ‘ngRoute’ with two views on top of index.html. One view (coffees.html) will be a list of all coffees in the database, sorted by name. There should be a search box at the top to find a particular coffee. Each listing in the table should include a brand, a name, a location, and a link to see the reviews of that coffee. Here’s what it should look like before CSS:&lt;br /&gt;
 &lt;br /&gt;
[[File:Coffees-bare (2).png|upright=2|thumb|center|coffees.html]]&lt;br /&gt;
&lt;br /&gt;
	Once you click the link, it should go to the second view (reviews.html). This should be another table, of all of the reviews for the coffee list. &lt;br /&gt;
	&lt;br /&gt;
&lt;br /&gt;
	Here’s what your reviews.html should look like before CSS:&lt;br /&gt;
&lt;br /&gt;
[[File:reviews-bare.png|thumb|upright=2|center|reviews.html]]&lt;br /&gt;
&lt;br /&gt;
	At all times, there should be a button at the top (not in either view, but in the main page) that takes you home (coffees.html). &lt;br /&gt;
In app.js, you will need to copy the following array into your controller:&lt;br /&gt;
&lt;br /&gt;
     $scope.coffees =&lt;br /&gt;
        [&lt;br /&gt;
        {'id': 1,&lt;br /&gt;
        'brand': &amp;quot;Average Andy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Regular Coffee',&lt;br /&gt;
        'country': 'Denmark',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
                {'rating': 3,&lt;br /&gt;
                'comment': &amp;quot;Could've been crispier&amp;quot;,&lt;br /&gt;
                'reviewer': &amp;quot;Chris P. Bacon&amp;quot;&lt;br /&gt;
                }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 2,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Mocha',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'What everyone should drink in the morning!',&lt;br /&gt;
        'reviewer': 'Earl Lee Riser'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'A genius of everything coffee',&lt;br /&gt;
        'reviewer': 'Bob'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 3,&lt;br /&gt;
        'brand': &amp;quot;We Did Our Best&amp;quot;,&lt;br /&gt;
        'name': 'Latte',&lt;br /&gt;
        'country': 'France',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': &amp;quot; a 'latte' yuckiness.&amp;quot;,&lt;br /&gt;
        'reviewer': 'Tim Burr'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 1,&lt;br /&gt;
        'comment': 'Is this even coffee?',&lt;br /&gt;
        'reviewer': 'Sue Flay'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 1,&lt;br /&gt;
        'comment': 'The grossest thing I have ever had.',&lt;br /&gt;
        'reviewer': 'Myles Long'&lt;br /&gt;
        },&lt;br /&gt;
         {'rating': 5,&lt;br /&gt;
        'comment': 'I dont know what the fuss is about, i dont think its too bad!',&lt;br /&gt;
        'reviewer': 'Sara Bellum'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        },&lt;br /&gt;
        {'id': 4,&lt;br /&gt;
        'brand': &amp;quot;Jimmy's Special Coffee&amp;quot;,&lt;br /&gt;
        'name': 'Americano',&lt;br /&gt;
        'country': 'America',&lt;br /&gt;
        'reviews': [&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'If I could rate it higher, I would!',&lt;br /&gt;
        'reviewer': 'Justin Case'&lt;br /&gt;
        },&lt;br /&gt;
        {'rating': 10,&lt;br /&gt;
        'comment': 'He does it again!',&lt;br /&gt;
        'reviewer': 'Eileen Dover'&lt;br /&gt;
        }&lt;br /&gt;
        ]&lt;br /&gt;
        }];&lt;br /&gt;
&lt;br /&gt;
This will be your “database,” as we are not going to use the “$http” dependency.&lt;br /&gt;
&lt;br /&gt;
=== Style ===&lt;br /&gt;
&lt;br /&gt;
Finally, use CSS (and, if you'd like to make it easier on yourself), UI Bootstrap (view the reference [https://angular-ui.github.io/bootstrap/ here] ), to make the site look pretty. &lt;br /&gt;
Although you’re allowed to use whatever CSS/Bootstrap you want, UI Bootstrap makes things really easy. For example, using stars in the rating directives to display ratings instead of a number.  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Please follow the installation instructions carefully. Type the following in your command file from the coffees directory:&lt;br /&gt;
           npm install -g bower&lt;br /&gt;
           bower install angular-bootstrap&lt;br /&gt;
&lt;br /&gt;
The following should be in your index.html *before you include app.js, but after you put the source files for bower_components/angular...* if you are using UI Bootstrap:&lt;br /&gt;
&lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css&amp;quot;&amp;gt; &lt;br /&gt;
          &amp;lt;link rel=&amp;quot;stylesheet&amp;quot; href=&amp;quot;https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
          &amp;lt;script src= &amp;quot;bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js&amp;quot; type=&amp;quot;text/javascript&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After installing and configuring your own css/bootstrap, your coffee site may look something like this (although it can look any way you want, this was just one person's design):&lt;br /&gt;
&lt;br /&gt;
[[File: Coffee-css.png|thumb|upright=2|none|Coffee page]]&lt;br /&gt;
[[File: Reviews-css.png|thumb|upright=2|none|Review page]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 55 points total.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0.''' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Google Angular Tutorial steps 0-10 (5 points)'''&lt;br /&gt;
#	 '''Completed coffee web application (50 points)'''&lt;br /&gt;
#*	Index.html (5 points)&lt;br /&gt;
#**	Working button with back to home button at all times (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	App.js (10 points)&lt;br /&gt;
#**	Set  up module ( 5 points)&lt;br /&gt;
#**	Controller (5 points)&lt;br /&gt;
#***	Have one or two controller(s) for the project ( 2 points)&lt;br /&gt;
#***	Use scope injection  (3 points)&lt;br /&gt;
#*	Coffees.html (15 points):&lt;br /&gt;
#**	List of all coffees sorted by name (3 points)&lt;br /&gt;
#**	Search bar, working correctly (4 points)&lt;br /&gt;
#**	Has Name, Brand, Location, and Review link all displayed in one table (3 points) &lt;br /&gt;
#**	Review link works, and takes you to another view (5 points)&lt;br /&gt;
#*	Reviews.html&lt;br /&gt;
#**	Reviews of correct coffee, and only correct coffee, are listed (10 points)&lt;br /&gt;
#**	All reviews are listed ( 2 points)&lt;br /&gt;
#**	Rating, comment, and commenter are listed in the same table. (3 points)&lt;br /&gt;
#*	BootStrapping&lt;br /&gt;
#**	Site looks good, intuitive, and professional ( 5 points)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
'''Creative Project Rubric'''&lt;br /&gt;
&lt;br /&gt;
You will also be submitting your Creative Project rubric alongside Module 7. Make a new repo &amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-CP-StudentID1-StudentID2, and place your Creative Project rubric in a README.md in that repository. &lt;br /&gt;
&lt;br /&gt;
Your Creative Project point breakdown should total to 95 points. An additional 5 points come from submitting the rubric on time. You may assign up to 20 points for the creative portion. &lt;br /&gt;
&lt;br /&gt;
The project itself, you will be using a new framework or technology of your choice to build a project. &lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>James</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_4&amp;diff=2306</id>
		<title>Module 4</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_4&amp;diff=2306"/>
		<updated>2017-03-27T14:22:27Z</updated>

		<summary type="html">&lt;p&gt;James: /* Write some Regular Expressions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
In Module 4, you will learn the fundamentals of Python, a popular scripting language, and Regular Expressions, which give you power in text processing.&lt;br /&gt;
&lt;br /&gt;
This article contains your assignments for Module 4.&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Python]]&lt;br /&gt;
* [[Regular Expressions]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Learn Python and Regular Expressions ===&lt;br /&gt;
&lt;br /&gt;
Up to this point in CSE 330, you have used only one programming language: PHP.  In Module 4, you will learn a new language: Python.  Before starting this assignment, you should look over the [[Python|online textbook article about Python]].  You should be using version 3 (or greater) of Python. Additionally, you may find it helpful to look over the [[Regular Expressions|online textbook article about Regular Expressions]].&lt;br /&gt;
&lt;br /&gt;
=== Write some Regular Expressions ===&lt;br /&gt;
&lt;br /&gt;
Please write regular expressions that do each the following:&lt;br /&gt;
&lt;br /&gt;
# Match the string &amp;quot;hello world&amp;quot; in a sentence&lt;br /&gt;
# Find all words in an input string that contain a triple vowel&lt;br /&gt;
# Match an input string that is '''entirely''' a flight code, of the format AA####, where '''AA''' is a two-letter uppercase airline code, and '''####''' is a three- or four-digit flight number&lt;br /&gt;
Examples:&lt;br /&gt;
   Note: text in ''[[red]]'' is matched by the regular expression. Each line is a separate test input string.&lt;br /&gt;
   Regex 1:  Programmers will often write ''[[hello world]]'' as their first project with a programming language.&lt;br /&gt;
   Regex 2:  The ''[[gooey]]'' peanut butter and jelly sandwich was a ''[[beauty]]''.&lt;br /&gt;
   Regex 3:  ''[[AA312]]''&lt;br /&gt;
             ''[[AA1298]]''&lt;br /&gt;
             ''[[NW1234]]''&lt;br /&gt;
             ''[[US443]]''&lt;br /&gt;
             US31344&lt;br /&gt;
             AA123 extratext&lt;br /&gt;
&lt;br /&gt;
            &lt;br /&gt;
&lt;br /&gt;
Save your regexes to a text file.  The TA will test them in regexpal on Demo Day.&lt;br /&gt;
&lt;br /&gt;
=== Baseball Stats Counter ===&lt;br /&gt;
&lt;br /&gt;
The St. Louis Cardinals are the most legendary baseball team in the national league.  In this exercise, you will be creating a Python script that reads box scores from a file and computes the Cardinals' players' batting averages in a particular season.&lt;br /&gt;
&lt;br /&gt;
==== Tips and Instructions ====&lt;br /&gt;
&lt;br /&gt;
* You should write a Python script file to solve this problem.&lt;br /&gt;
* You should use a regular expression to parse players' names, at-bats, hits, and runs from the input file.&lt;br /&gt;
* You may want to create a class to hold and compute information about each player.&lt;br /&gt;
* Your file should take one command-line argument: the path to an input file.  If no path is given, your program should print a usage message.&lt;br /&gt;
&lt;br /&gt;
==== Input ====&lt;br /&gt;
&lt;br /&gt;
Sample input files may be found here: http://classes.engineering.wustl.edu/cse330/content/cardinals/&lt;br /&gt;
&lt;br /&gt;
The top of the file contains a citation, and what follows is an entire season of Cardinals Baseball box scores.  Each game starts with a title; for example:&lt;br /&gt;
&lt;br /&gt;
 === St.Louis Cardinals vs. Chicago Cubs, 1940-04-19 ===&lt;br /&gt;
&lt;br /&gt;
What follows are the performance of each player in that game.  The format of each line is as follows:&lt;br /&gt;
&lt;br /&gt;
 XXX batted # times with # hits and # runs&lt;br /&gt;
&lt;br /&gt;
where '''XXX''' is the player's name (you may assume that the name is unique), and each '''#''' are integers representing the number of &amp;quot;at bats&amp;quot;, the number of &amp;quot;hits&amp;quot;, and the number of &amp;quot;runs&amp;quot;, respectively.&lt;br /&gt;
&lt;br /&gt;
==== Output ====&lt;br /&gt;
&lt;br /&gt;
Your script needs to output all players' batting average across the season.  A player's batting average is that player's total hits divided by that player's total at-bats throughout the entire season.  For example, Johnny Hopp was at bat 149 times in 1940, and he had 41 hits, so his batting average was 0.275.&lt;br /&gt;
&lt;br /&gt;
Each line in the output should have the format:&lt;br /&gt;
&lt;br /&gt;
 XXX: #.###&lt;br /&gt;
&lt;br /&gt;
where '''XXX''' is the player's name, and '''#.###''' is the player's batting average, '''rounded''' (not truncated) to three decimal places.&lt;br /&gt;
&lt;br /&gt;
The players should be sorted by batting average, with the highest batting average on top.  If two players have the exact same batting average (before rounding occurs), the order between those two players is unimportant.&lt;br /&gt;
&lt;br /&gt;
For example, the correct output for the 1940 season is:&lt;br /&gt;
&amp;lt;!-- Jimmy Brown was 0.280 and Ira Hutchinson was 0.125 --&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Pepper Martin: 0.316&lt;br /&gt;
Walker Cooper: 0.316&lt;br /&gt;
Johnny Mize: 0.314&lt;br /&gt;
Ernie Koy: 0.310&lt;br /&gt;
Enos Slaughter: 0.306&lt;br /&gt;
Joe Medwick: 0.304&lt;br /&gt;
Terry Moore: 0.304&lt;br /&gt;
Joe Orengo: 0.286&lt;br /&gt;
Jimmy Brown: 0.280&lt;br /&gt;
Marty Marion: 0.279&lt;br /&gt;
Don Gutteridge: 0.276&lt;br /&gt;
Johnny Hopp: 0.275&lt;br /&gt;
Creepy Crespi: 0.273&lt;br /&gt;
Mickey Owen: 0.265&lt;br /&gt;
Bill DeLancey: 0.250&lt;br /&gt;
Don Padgett: 0.242&lt;br /&gt;
Stu Martin: 0.238&lt;br /&gt;
Eddie Lake: 0.222&lt;br /&gt;
Hal Epps: 0.214&lt;br /&gt;
Lon Warneke: 0.209&lt;br /&gt;
Harry Walker: 0.185&lt;br /&gt;
Max Lanier: 0.179&lt;br /&gt;
Bill McGee: 0.178&lt;br /&gt;
Carl Doyle: 0.174&lt;br /&gt;
Mort Cooper: 0.157&lt;br /&gt;
Clyde Shoun: 0.145&lt;br /&gt;
Carden Gillenwater: 0.130&lt;br /&gt;
Bob Bowman: 0.067&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 50 points total.&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. ''' &lt;br /&gt;
&lt;br /&gt;
Upload your baseball code, a file with your Regular expressions, and a screenshot of your python output onto bitbucket, and we will use the time-stamps to determine late-penalties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-201343)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# '''Regular Expressions (15 Points):'''&lt;br /&gt;
#* Regular Expression 1 Correct (5 points)&lt;br /&gt;
#* Regular Expression 2 Correct (5 points)&lt;br /&gt;
#* Regular Expression 3 Correct (5 points)&lt;br /&gt;
# '''Baseball Stats Counter (35 Points):'''&lt;br /&gt;
#* Solution is written entirely in Python (8 points)&lt;br /&gt;
#* Correct usage of a regular expression to parse each line of the input file (8 points)&lt;br /&gt;
#* Script prints a usage message if a command line argument is not present (4 points)&lt;br /&gt;
#* Output is correct for the 1940 test case (15 points)&lt;br /&gt;
#*: ''This includes sorting and rounding.''&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 4]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>James</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Node.JS&amp;diff=2305</id>
		<title>Node.JS</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Node.JS&amp;diff=2305"/>
		<updated>2017-03-27T00:39:00Z</updated>

		<summary type="html">&lt;p&gt;James: /* Node.js Conventions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;AJAX is a useful technology for web applications that need to pull periodic updates from your server.  But what do you do when you have thousands of clients all requesting data that changes real-time?  A PHP+AJAX approach could choke without a lot of effort on your part.  It is situations like these that Node.js comes to the rescue. Node.js is a web framework, made in JavaScript, that's become extremely popular over the last few years.&lt;br /&gt;
&lt;br /&gt;
In general, JavaScript frameworks are very trendy right now; it can be hard to keep up with the new cool thing. In fact, there's a joke website https://dayssincelastjavascriptframework.com/, that &amp;quot;tracks&amp;quot; how long it's been since a new framework has come out.&lt;br /&gt;
&lt;br /&gt;
== Non-Blocking I/O ==&lt;br /&gt;
&lt;br /&gt;
You dabbled in the concept of non-blocking I/O when you implemented AJAX in the previous JavaScript module.  Node.js uses this execution model at its core.&lt;br /&gt;
&lt;br /&gt;
The core idea is the use of '''''anonymous functions''''' as ''callbacks'' for processing the results of intensive operations.  Consider the pseudo-code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// Blocking I/O Pseudo-Code&lt;br /&gt;
&lt;br /&gt;
var data = database.query(&amp;quot;select * from news&amp;quot;);&lt;br /&gt;
print data[0].title;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The above pseudo-code queries a database, saves the result of the query in a variable named ''data'', and then prints out the first title in ''data''.  The problem arises when multiple clients all want to access the server at the same time.  ''In a blocking I/O model, a client needs to wait until all other clients are finished before it can start its process.''  With intensive operations and thousands of clients, this can easily crash your server!&lt;br /&gt;
&lt;br /&gt;
The solution is to use ''non-blocking I/O''.  Consider this revised pseudo-code:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// Non-Blocking I/O Pseudo-Code&lt;br /&gt;
&lt;br /&gt;
database.query(&amp;quot;select * from news&amp;quot;, function(data){&lt;br /&gt;
	print data[0].title;&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The revised pseudo-code achieves the same end result as the first version.  However, ''it allows other clients to perform tasks while this process is waiting for the database to be queried!''  The code occurs in two parts: first, we start the query.  Second, ''when the query is complete'', our '''anonymous callback function''' is executed.  In Node.js, callback functions are usually passed one or more parameters.&lt;br /&gt;
&lt;br /&gt;
Better yet, with non-blocking I/O, you have no concurrency issues, because everything runs in just one thread.  Nifty!&lt;br /&gt;
&lt;br /&gt;
== Installing Node.js ==&lt;br /&gt;
&lt;br /&gt;
You can get Node.js from yum or apt-get, but the versions are going to be out dated.  Remember that Node.js is a rapidly changing framework, so a version of Node from last year is going to be drastically different than a version of Node today.&lt;br /&gt;
&lt;br /&gt;
The unofficial instructions for installing Node.js can be found here: https://gist.github.com/isaacs/579814&lt;br /&gt;
&lt;br /&gt;
There are several choices, but my favorite is probably ''use-nave-no-shell.sh''.&lt;br /&gt;
&lt;br /&gt;
The instructions at the above link have a couple bugs.  If you run this sequence of commands, Node and NPM will install correctly:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ mkdir ~/.nave&lt;br /&gt;
$ cd ~/.nave&lt;br /&gt;
$ wget http://github.com/isaacs/nave/raw/master/nave.sh&lt;br /&gt;
$ sudo ln -s $PWD/nave.sh /usr/local/bin/nave&lt;br /&gt;
$ chmod a+x nave.sh&lt;br /&gt;
$ sudo chown -R $USER:$USER /usr/local&lt;br /&gt;
$ nave usemain stable&lt;br /&gt;
$ curl -L https://www.npmjs.org/install.sh | sh&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Your First Node.js Application: Hello World ==&lt;br /&gt;
&lt;br /&gt;
Let's try running the example application given on the front page of nodejs.org:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
var http = require('http');&lt;br /&gt;
http.createServer(function (req, res) {&lt;br /&gt;
	res.writeHead(200, {&lt;br /&gt;
		'Content-Type': 'text/plain'&lt;br /&gt;
	});&lt;br /&gt;
	res.end('Hello World\n');&lt;br /&gt;
}).listen(3456);&lt;br /&gt;
console.log('Server running at http://localhost:3456/');&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Paste the example into a file named `hello.js`, and then run it by calling `node hello.js`.  You should now be able to see your Hello World by visiting your server at port 3456!  (Press ^C to stop the application.)  '''Note:''' If you're running the code from your EC2 instance, you will need to open port 3456.&lt;br /&gt;
&lt;br /&gt;
Let's walk through each line in the above example.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;var http = require('http');&amp;lt;/code&amp;gt; enables us to use Node's built-in HTTP server.  We've been spoiled that languages like PHP automatically load all of the libraries that we need.  However, '''''most functionality in Node.js is NOT loaded by default.'''''  When you want to use any non-fundamental feature of Node, you need to ''require'' it into a variable, as this example does with the HTTP package.  You should be familiar with this concept when you needed to use ArrayList and other specialty packages in Java in CSE 132.&lt;br /&gt;
* &amp;lt;code&amp;gt;http.createServer(function (req, res) { ... }).listen(3456);&amp;lt;/code&amp;gt; uses the HTTP server API to listen for HTTP connections on port 3456.  The anonymous callback function will be called whenever a connection is made.&lt;br /&gt;
* &amp;lt;code&amp;gt;res.writeHead(200, { 'Content-Type': 'text/plain' });&amp;lt;/code&amp;gt; specifies the Content-Type header to be &amp;quot;text/plain&amp;quot;.&lt;br /&gt;
* &amp;lt;code&amp;gt;res.end('Hello World\n');&amp;lt;/code&amp;gt; writes &amp;quot;Hello World&amp;quot; to the response.&lt;br /&gt;
&lt;br /&gt;
Note the use of non-blocking I/O, even in this one little example.  ''Whenever a connection is made, the callback function will be called and passed parameters associated with that connection.''&lt;br /&gt;
&lt;br /&gt;
== A Static File Server Using Node.js ==&lt;br /&gt;
&lt;br /&gt;
Node.js does not automatically serve up static files in the way that an Apache/PHP does.  We need to either use an extension that handles this for us, like Express, or we need to write our own code to make a simple static file server.  The latter option is really not all that difficult, and it gives good insight into how a static file server works.&lt;br /&gt;
&lt;br /&gt;
=== Installing Packages ===&lt;br /&gt;
&lt;br /&gt;
In order for the example code below to work, you need to install the ''mime'' package.  To do this, '''cd to the working directory where you will save your Node.js JavaScript file''' and run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ npm install mime&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''npm'' is the package manager for Node.js.  Unlike all of the package managers we've used up to this point, ''npm'' installs dependencies locally, ''not'' globally.  This means that you can have two different projects using different versions of the same package.  ''npm'' will create a ''node_modules'' directory in the CWD and will install the packages into it.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' When using npm to install local dependencies, '''''do not use sudo'''''.  It will screw up your file permissions.&lt;br /&gt;
&lt;br /&gt;
=== Static Fileserver Code ===&lt;br /&gt;
&lt;br /&gt;
The following code will make an HTTP server on port 3456 that serves up all static files in &amp;lt;STATIC DIRECTORY NAME&amp;gt; relative to app.js.&lt;br /&gt;
&lt;br /&gt;
'''Make an attempt to understand this code.'''  It's important that you are comfortable with the non-blocking nature, as well as how we handle file I/O. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
// Require the functionality we need to use:&lt;br /&gt;
var http = require('http'),&lt;br /&gt;
	url = require('url'),&lt;br /&gt;
	path = require('path'),&lt;br /&gt;
	mime = require('mime'),&lt;br /&gt;
	path = require('path'),&lt;br /&gt;
	fs = require('fs');&lt;br /&gt;
&lt;br /&gt;
// Make a simple fileserver for all of our static content.&lt;br /&gt;
// Everything underneath &amp;lt;STATIC DIRECTORY NAME&amp;gt; will be served.&lt;br /&gt;
var app = http.createServer(function(req, resp){&lt;br /&gt;
	var filename = path.join(__dirname, &amp;quot;&amp;lt;STATIC DIRECTORY NAME&amp;gt;&amp;quot;, url.parse(req.url).pathname);&lt;br /&gt;
	(fs.exists || path.exists)(filename, function(exists){&lt;br /&gt;
		if (exists) {&lt;br /&gt;
			fs.readFile(filename, function(err, data){&lt;br /&gt;
				if (err) {&lt;br /&gt;
					// File exists but is not readable (permissions issue?)&lt;br /&gt;
					resp.writeHead(500, {&lt;br /&gt;
						&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;&lt;br /&gt;
					});&lt;br /&gt;
					resp.write(&amp;quot;Internal server error: could not read file&amp;quot;);&lt;br /&gt;
					resp.end();&lt;br /&gt;
					return;&lt;br /&gt;
				}&lt;br /&gt;
				&lt;br /&gt;
				// File exists and is readable&lt;br /&gt;
				var mimetype = mime.lookup(filename);&lt;br /&gt;
				resp.writeHead(200, {&lt;br /&gt;
					&amp;quot;Content-Type&amp;quot;: mimetype&lt;br /&gt;
				});&lt;br /&gt;
				resp.write(data);&lt;br /&gt;
				resp.end();&lt;br /&gt;
				return;&lt;br /&gt;
			});&lt;br /&gt;
		}else{&lt;br /&gt;
			// File does not exist&lt;br /&gt;
			resp.writeHead(404, {&lt;br /&gt;
				&amp;quot;Content-Type&amp;quot;: &amp;quot;text/plain&amp;quot;&lt;br /&gt;
			});&lt;br /&gt;
			resp.write(&amp;quot;Requested file not found: &amp;quot;+filename);&lt;br /&gt;
			resp.end();&lt;br /&gt;
			return;&lt;br /&gt;
		}&lt;br /&gt;
	});&lt;br /&gt;
});&lt;br /&gt;
app.listen(3456);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Port 3456 ===&lt;br /&gt;
&lt;br /&gt;
We are running our server on port 3456 as opposed to the default web server port, which of course is 80.  We therefore need to open our Node.js application like this:&lt;br /&gt;
&lt;br /&gt;
http://ec2-xx-xx-xx-xx.compute-1.amazonaws.com:3456/path.extension&lt;br /&gt;
&lt;br /&gt;
However, this won't work on the first time.  ''Why?'' (Try to figure this out on your own before reading the next paragraph.)&lt;br /&gt;
&lt;br /&gt;
We need to open port 3456 on our Amazon EC2 instance.  Remember when you opened port 80 way back in Module 2?  We need to do the same sort of procedure again now.&lt;br /&gt;
&lt;br /&gt;
# Log into your EC2 management console&lt;br /&gt;
# Go to &amp;quot;Security Groups&amp;quot;&lt;br /&gt;
# Select your security group from Module 2&lt;br /&gt;
# Under &amp;quot;Inbound&amp;quot;, create a custom TCP rule for port 3456, and apply your changes.&lt;br /&gt;
&lt;br /&gt;
== Node.js Security ==&lt;br /&gt;
&lt;br /&gt;
Just because we're writing in JavaScript doesn't mean that we can forget about the security practices you've been learning in the last three months of CSE 330.  XSS is still a problem, as is the use of ''eval'', CSRF attacks, and so on.&lt;br /&gt;
&lt;br /&gt;
The two links below have good information about security vulnerabilities specific to Node.js that you should think about when crafting your application.&lt;br /&gt;
&lt;br /&gt;
# Book from PragProg ($24, 2015): https://pragprog.com/book/kdnodesec/secure-your-node-js-web-application&lt;br /&gt;
# Slideshow from a Switzerland Conference on Application Security (2012): http://www.slideshare.net/ASF-WS/asfws-2012-nodejs-security-old-vulnerabilities-in-new-dresses-par-sven-vetsch&lt;br /&gt;
&lt;br /&gt;
== Node.js Conventions ==&lt;br /&gt;
&lt;br /&gt;
There ought to be a standard way to save metadata about your app, right?  Well, ''npm'' introduces a straightforward way to do this in the form of a ''package.json'' file.&lt;br /&gt;
&lt;br /&gt;
To make your ''npm'' file with a step-by-step prompt, run in your project root directory:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ npm init&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
One nifty feature of ''package.json'' is the way it automatically handles dependencies.  For example, you can put the following lines in your ''package.json'':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
  &amp;quot;dependencies&amp;quot;: {&lt;br /&gt;
    &amp;quot;mime&amp;quot;: &amp;quot;~1.2.11&amp;quot;,&lt;br /&gt;
    &amp;quot;socket.io&amp;quot;: &amp;quot;~0.9.16&amp;quot;&lt;br /&gt;
  },&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, back on the command line, when you run&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ npm install&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
it automatically installs the dependencies for you!  No more headaches of trying to figure out which modules you need to install; all that information is saved for you in your code base.&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' Once you set up your ''package.json'' file, you can automatically add a dependency to it by using the ''--save'' argument on ''npm install'': &amp;lt;code&amp;gt;npm install --save socket.io&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 7]]&lt;/div&gt;</summary>
		<author><name>James</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_3&amp;diff=2293</id>
		<title>Module 3</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_3&amp;diff=2293"/>
		<updated>2017-02-20T21:21:33Z</updated>

		<summary type="html">&lt;p&gt;James: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
In Module 3, you will learn about MySQL, a web application database.&lt;br /&gt;
&lt;br /&gt;
This article contains your assignments for Module 3.&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Introduction to MySQL]]&lt;br /&gt;
* [[MySQL Schema and State]]&lt;br /&gt;
* [[PHP and MySQL]]&lt;br /&gt;
* [[Web Application Security, Part 2]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
You will create a simple grades database containing four tables.&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT:''' The individual assignment is to be done by writing queries by hand.  (You can use phpMyAdmin to run the queries, but '''do not let phpMyAdmin write your queries for you!''')  Writing your own queries gives you a greater understanding of the underlying mechanisms and databases in general.  Additionally, having SQL knowledge and experience is a very marketable trait.&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL and phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
Before you start, '''you need to install MySQL''' on your EC2 instance.  You may also install phpMyAdmin, a web frontend to MySQL, if you choose to do so.&lt;br /&gt;
&lt;br /&gt;
=== Set Up a Database ===&lt;br /&gt;
&lt;br /&gt;
You may find the following article to be very helpful: [[Introduction to MySQL]]&lt;br /&gt;
&lt;br /&gt;
# Create a database named '''wustl''' &lt;br /&gt;
# Create a user named '''wustl_inst''' and give them the password '''wustl_pass'''&lt;br /&gt;
&lt;br /&gt;
=== Create Tables ===&lt;br /&gt;
&lt;br /&gt;
You may find the following article to be very helpful: [[MySQL Schema and State]]&lt;br /&gt;
&lt;br /&gt;
When creating tables, keep the following items in mind:&lt;br /&gt;
&lt;br /&gt;
* You should create all tables such that they use the InnoDB storage engine, since we wish to make use of its support of foreign keys. In other database engines, foreign key constraints are not enforced.  (If you mess up, you can use ALTER TABLE to change the storage engine.)&lt;br /&gt;
* Where it is appropriate, you should take advantage of the ability to define fields NOT NULL so that you do not inadvertently insert incomplete data for a row.&lt;br /&gt;
&lt;br /&gt;
Create the following tables:&lt;br /&gt;
&lt;br /&gt;
# Create a table named '''students''' with the following fields:&lt;br /&gt;
#* '''id''' of an appropriately-sized unsigned integer type (we will never need to process more than a million students)&lt;br /&gt;
#* '''first_name''' of type '''VARCHAR(50)'''&lt;br /&gt;
#* '''last_name''' of type '''VARCHAR(50)'''&lt;br /&gt;
#* '''email_address''' of type '''VARCHAR(50)'''&lt;br /&gt;
#: The primary key should be on the '''id''' field.&lt;br /&gt;
# Create a table named '''departments''' with the following fields:&lt;br /&gt;
#* '''school_code''' of type '''ENUM''' (e.g. &amp;quot;L&amp;quot; for ArtSci and &amp;quot;E&amp;quot; for Engineering).  The options are as follows:&lt;br /&gt;
#*: 'L', 'B', 'A', 'F', 'E', 'T', 'I', 'W', 'S', 'U', 'M'&lt;br /&gt;
#* '''dept_id''' of an appropriately-sized unsigned integer type (in the foreseeable future there will never be more than 200 departments in a school)&lt;br /&gt;
#* '''abbreviation''' of type '''VARCHAR(9)''' (e.g. CSE, ChemE, etc)&lt;br /&gt;
#* '''dept_name''' of type '''VARCHAR(200)''' (e.g. Computer Science and Engineering)&lt;br /&gt;
#: The primary key should be on two fields: '''school_code''' and '''dept_id'''&lt;br /&gt;
#: '''Note:''' Why not just use the department ID for the primary key? The ID numbers are sometimes reused across schools. For instance, department 33 in The College of Arts and Sciences is Psychology while department 33 in The School of Engineering and Applied Sciences is Energy, Environmental and Chemical Engineering. Thus we must also include the school code to differentiate them  such that the record for  E33 is distinct from that of L33.&lt;br /&gt;
# Create a table named '''courses''' with the following fields:&lt;br /&gt;
#* '''school_code''' of type '''ENUM'''&lt;br /&gt;
#*: This should have the same letters in the same order as the '''school_code''' '''ENUM''' field in the '''departments''' table.&lt;br /&gt;
#* '''dept_id''' of the same size of integer as in the '''departments''' table&lt;br /&gt;
#* '''course_code''' of type '''CHAR(5)''' (this will hold course codes; e.g., '330S', '131', '2960')&lt;br /&gt;
#* '''name''' of type '''VARCHAR(150)'''&lt;br /&gt;
#: The appropriate fields in this table should make a foreign key reference to the corresponding fields in '''department'''.&lt;br /&gt;
#: In addition, it is up to you to determine the field(s) for the primary key.&lt;br /&gt;
#: '''Note:''' If you are unsure which fields to make the foreign keys and feel the need to beg your friends or the TAs to give you the answer, bang your head on your desk whilst repeating &amp;quot;I WILL EXERCISE REASON AND COMMON SENSE AND I WILL CURTAIL MY DESIRE TO BLINDLY FOLLOW DIRECTIONS&amp;quot;&lt;br /&gt;
#: ''Disclaimer: don't actually bang your head on your desk, the resulting head trauma may in fact make it harder for you to determine which fields should have associated foreign keys.''&lt;br /&gt;
# Create a table named '''grades''' with the following fields:&lt;br /&gt;
#* '''pk_grade_ID''' of an appropriately-sized unsigned integer type (should be larger than the one you chose for the '''students''' table)&lt;br /&gt;
#*: You should declare this field to be '''auto_increment''' and make it the primary key.&lt;br /&gt;
#*: This is called a ''surrogate key'' as opposed to a ''natural key'' because it doesn't arise &amp;quot;naturally&amp;quot; from the data; that is to say that it is not derived from application data. The use of surrogate keys vs. natural keys is a polemic issue amongst database designers.  For a decently unbiased take on the issue, see this page: http://www.agiledata.org/essays/keys.html#Comparison&lt;br /&gt;
#*: '''Food for thought:''' Aside from simply exposing you to the concept, can you think of any reasons why a surrogate key might be preferable for this table?  Alternatively, what attributes, if any, could you use as a natural key, and what might be the drawbacks of doing so?&lt;br /&gt;
#* '''student_id''' of the same integer (unsigned) type that you chose in the '''students''' table&lt;br /&gt;
#* '''grade''' of type '''decimal(5,2)'''&lt;br /&gt;
#* '''school_code''' of type '''ENUM'''&lt;br /&gt;
#*: Can you guess what entries to use for the enum?&lt;br /&gt;
#* '''dept_id''' of the same integer type that you've used for this field in other tables&lt;br /&gt;
#* '''course_code''' of the same type you chose for the course code in the '''courses''' table&lt;br /&gt;
#: The '''grades''' table should have foreign keys to both the '''students''' table and the '''courses''' table.&lt;br /&gt;
&lt;br /&gt;
=== Populate Tables ===&lt;br /&gt;
&lt;br /&gt;
Now, populate the tables by downloading the text files given below and loading them into the appropriate tables.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Do not insert all the values manually; instead, use the MySQL's ability to load in data from text files.&lt;br /&gt;
&lt;br /&gt;
You may find the following article to be very helpful: [[MySQL Schema and State]]&lt;br /&gt;
&lt;br /&gt;
The files containing the data are:&lt;br /&gt;
* students: http://classes.engineering.wustl.edu/cse330/content/students_data.txt&lt;br /&gt;
* courses: http://classes.engineering.wustl.edu/cse330/content/courses.txt&lt;br /&gt;
* departments: http://classes.engineering.wustl.edu/cse330/content/departments_data.txt&lt;br /&gt;
* grades: http://classes.engineering.wustl.edu/cse330/content/grades_data.txt&lt;br /&gt;
&lt;br /&gt;
=== Insert More Data ===&lt;br /&gt;
&lt;br /&gt;
Insert the following data into the tables that you have created and populated:&lt;br /&gt;
&lt;br /&gt;
# Insert an entry for CSE 330S&lt;br /&gt;
#: ''If you don't know CSE's department code, how can you find out using the tables in the database?''&lt;br /&gt;
# Insert the grades given for the students named below.  You may choose to make the entries for whichever classes you like, with the one condition that all of the students must have a grade for CSE 330S (who wouldn't want to take that class: I hear the professor and TAs are amazing!)&lt;br /&gt;
#* '''Ben Harper'''&lt;br /&gt;
#** E-mail: '''bharper@ffym.com'''&lt;br /&gt;
#** Student ID: '''88'''&lt;br /&gt;
#** Grades:&lt;br /&gt;
#*** 35.5 (CSE 330S grade)&lt;br /&gt;
#*** 0&lt;br /&gt;
#*** 95&lt;br /&gt;
#* '''Matt Freeman'''&lt;br /&gt;
#** E-mail: '''mfreeman@kickinbassist.net'''&lt;br /&gt;
#** Student ID: '''202'''&lt;br /&gt;
#** Grades:&lt;br /&gt;
#*** 100 (CSE 330S grade)&lt;br /&gt;
#*** 90.5&lt;br /&gt;
#*** 94.8&lt;br /&gt;
#* '''Marc Roberge'''&lt;br /&gt;
#** E-mail: '''mroberge@ofarevolution.us'''&lt;br /&gt;
#** Student ID: '''115'''&lt;br /&gt;
#** Grades:&lt;br /&gt;
#*** 75 (CSE 330S grade)&lt;br /&gt;
#*** 37&lt;br /&gt;
#*** 45.5&lt;br /&gt;
#: You may choose any 3 classes you'd like for them to be enrolled in, with at least one class, &amp;quot;CSE 330S&amp;quot;, in which they are all enrolled.&lt;br /&gt;
&lt;br /&gt;
=== Querying Your Database ===&lt;br /&gt;
&lt;br /&gt;
Now that you have a fully-functional, populated database, let's do some queries on it!&lt;br /&gt;
&lt;br /&gt;
Please take a screenshot of running the following '''select''' queries and commit them with the rest of your repository (be sure to include your query command and the response):&lt;br /&gt;
&lt;br /&gt;
# Select the entire grades table.&lt;br /&gt;
# Select all fields describing the courses offered in the school of arts and sciences (school code L).&lt;br /&gt;
# The names, student IDs, and CSE330 grades of the students who are in CSE330S.&lt;br /&gt;
#: '''Note:''' This query should involve joins.  You don't need to use any aggregation functions.&lt;br /&gt;
# The names, e-mails, and average grades of any student with an average below 50 so that the dean can send them an email notification that they are now on academic probation.&lt;br /&gt;
#: ''You should be able to do this in only one query, without making any temporary tables.  You will need to use aggregation functions and the '''having''' keyword.''&lt;br /&gt;
# An individual report card for Jack Johnson, consisting of his student ID, e-mail address, and average grade.&lt;br /&gt;
#: ''Again, you should be able to do this in just one query, using the correct combination of aggregation functions and joins.''&lt;br /&gt;
#: '''Note:''' Your query must look for students with the name Jack Johnson instead of hard-coding the student ID.&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
You will work in pairs on this project.  You may work with the same partner from Module 2, or change to someone else.&lt;br /&gt;
&lt;br /&gt;
'''Important Reminder:''' frequently commit your work to your Git repository as a backup!&lt;br /&gt;
&lt;br /&gt;
=== Simple News Web Site ===&lt;br /&gt;
&lt;br /&gt;
'''Examples:'''&lt;br /&gt;
* http://digg.com/&lt;br /&gt;
* http://slashdot.org/&lt;br /&gt;
&lt;br /&gt;
You should use '''PHP''' unless you get permission to use another web technology from the instructor.  You may also use phpMyAdmin to help set up databases.&lt;br /&gt;
&lt;br /&gt;
You may find this wiki article helpful: [[PHP and MySQL]]&lt;br /&gt;
&lt;br /&gt;
==== Requirements ====&lt;br /&gt;
&lt;br /&gt;
* Users can register for accounts and then log in to the website.&lt;br /&gt;
* Accounts should have both a username and a ''secure'' password.  '''NEVER store plaintext passwords in a database!'''&lt;br /&gt;
*: For more information on password security, refer to [[Web Application Security, Part 2#Password Security|the Web Application Security guide]].&lt;br /&gt;
* Registered users can submit story commentary.&lt;br /&gt;
*: A link can be associated with each story, and they should be stored in a separate database field from the story&lt;br /&gt;
* Registered users can comment on any story.&lt;br /&gt;
* Unregistered users can only view stories and comments.&lt;br /&gt;
* Registered users can edit and delete their stories and comments.&lt;br /&gt;
* All data must be kept in a MySQL database (user information, stories, comments, and links).&lt;br /&gt;
* Creative Portion&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
No application is finished until much thought is put into web security and best practice.  Throughout this course, we heavily emphasize the dogma of [http://coderesponsibly.org/ responsible] coding.&lt;br /&gt;
&lt;br /&gt;
Read this week's Web Application Security guide: [[Web Application Security, Part 2]].  In particular, your project needs to:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to be secure from SQL injection attacks'''. If you are using prepared queries, you should already be safe on this front.&lt;br /&gt;
* '''Your passwords need to be securely salted''' to prevent rainbow table attacks.&lt;br /&gt;
* '''You should pass tokens in forms''' to prevent CSRF attacks.&lt;br /&gt;
* '''You should check all preconditions on the server side''' to prevent Abuse of Functionality attacks.&lt;br /&gt;
&lt;br /&gt;
You shouldn't forget the practices you learned last week:&lt;br /&gt;
&lt;br /&gt;
* '''Your page should validate''' with no errors through the W3C validator.&lt;br /&gt;
* '''Filter Input and Escape Output''', but not the other way around.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. ''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID1-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-201343-314450) &lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly or if you fail to share it with cse330, the TAs are not responsible for grading your assignment. If we cannot find it, you will receive a 0.'''&lt;br /&gt;
&lt;br /&gt;
________&lt;br /&gt;
&lt;br /&gt;
# '''MySQL Queries (25 Points):'''&lt;br /&gt;
#* A MySQL server is running on your instance (2 points)&lt;br /&gt;
#* Tables' fields, including data types, are correct (4 points)&lt;br /&gt;
#* Foreign keys are correct, and the screenshots of the structure are committed to BitBucket (4 points)&lt;br /&gt;
#*: ''Note: To demonstrate the structure of your tables, you should include either a file containing the output of the &amp;lt;code&amp;gt;SHOW CREATE TABLE&amp;lt;/code&amp;gt; command or a screenshot of the result of running that command '''for each table.'''''&lt;br /&gt;
#* The output of each of the five queries is correct, and screenshots of the result of running each query are committed to BitBucket. (3 points each)&lt;br /&gt;
# '''News Site (60 Points):'''&lt;br /&gt;
#* '''''User Management (20 Points):'''''&lt;br /&gt;
#** A session is created when a user logs in (3 points)&lt;br /&gt;
#** New users can register (3 points)&lt;br /&gt;
#** Passwords are hashed and salted (3 points)&lt;br /&gt;
#** Users can log out (3 points)&lt;br /&gt;
#** A user can edit and delete his/her own stories and comments but cannot edit or delete the stories or comments of another user (8 points)&lt;br /&gt;
#* '''''Story and Comment Management (20 Points):'''''&lt;br /&gt;
#** Relational database is configured with correct data types and foreign keys (4 points)&lt;br /&gt;
#** Stories can be posted (3 points)&lt;br /&gt;
#** A link can be associated with each story, and they should be stored in a separate database field from the story (3 points)&lt;br /&gt;
#** Comments can be posted in association with a story (4 points)&lt;br /&gt;
#** Stories can be edited and deleted (3 points)&lt;br /&gt;
#** Comments can be edited and deleted (3 points)&lt;br /&gt;
#**: ''Note: Although there are only 6 points allocated for editing/deleting in this section, there are 8 more points at stake in the User Management section that cannot be earned unless editing/deleting is implemented.  Implementing editing but not deleting, or vice-versa, will result in earning half the points.''&lt;br /&gt;
#* '''''Best Practices (15 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (3 points)&lt;br /&gt;
#** Safe from SQL Injection attacks (2 points)&lt;br /&gt;
#** Site follows the FIEO philosophy (3 points)&lt;br /&gt;
#** All pages pass the W3C validator (2 points)&lt;br /&gt;
#** CSRF tokens are passed when creating, editing, and deleting comments and stories (5 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Site is intuitive to use and navigate (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (15 Points)''' (see below)&lt;br /&gt;
#* '''''Make sure you have a README.md file in your group repo with the following:'''''&lt;br /&gt;
#** Names and Student IDs of all the group members&lt;br /&gt;
#** A link to your homepage of the site&lt;br /&gt;
#** A brief description of what you did for your creative portion&lt;br /&gt;
#** Any additional login details needed for the TA&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 3]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>James</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_3&amp;diff=2262</id>
		<title>Module 3</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_3&amp;diff=2262"/>
		<updated>2017-02-07T16:08:30Z</updated>

		<summary type="html">&lt;p&gt;James: /* Querying Your Database */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
In Module 3, you will learn about MySQL, a web application database.&lt;br /&gt;
&lt;br /&gt;
This article contains your assignments for Module 3.&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Introduction to MySQL]]&lt;br /&gt;
* [[MySQL Schema and State]]&lt;br /&gt;
* [[PHP and MySQL]]&lt;br /&gt;
* [[Web Application Security, Part 2]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
You will create a simple grades database containing four tables.&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT:''' The individual assignment is to be done by writing queries by hand.  (You can use phpMyAdmin to run the queries, but '''do not let phpMyAdmin write your queries for you!''')  Writing your own queries gives you a greater understanding of the underlying mechanisms and databases in general.  Additionally, having SQL knowledge and experience is a very marketable trait.&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL and phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
Before you start, '''you need to install MySQL''' on your EC2 instance.  You may also install phpMyAdmin, a web frontend to MySQL, if you choose to do so.&lt;br /&gt;
&lt;br /&gt;
=== Set Up a Database ===&lt;br /&gt;
&lt;br /&gt;
You may find the following article to be very helpful: [[Introduction to MySQL]]&lt;br /&gt;
&lt;br /&gt;
# Create a database named '''wustl''' &lt;br /&gt;
# Create a user named '''wustl_inst''' and give them the password '''wustl_pass'''&lt;br /&gt;
&lt;br /&gt;
=== Create Tables ===&lt;br /&gt;
&lt;br /&gt;
You may find the following article to be very helpful: [[MySQL Schema and State]]&lt;br /&gt;
&lt;br /&gt;
When creating tables, keep the following items in mind:&lt;br /&gt;
&lt;br /&gt;
* You should create all tables such that they use the InnoDB storage engine, since we wish to make use of its support of foreign keys. In other database engines, foreign key constraints are not enforced.  (If you mess up, you can use ALTER TABLE to change the storage engine.)&lt;br /&gt;
* Where it is appropriate, you should take advantage of the ability to define fields NOT NULL so that you do not inadvertently insert incomplete data for a row.&lt;br /&gt;
&lt;br /&gt;
Create the following tables:&lt;br /&gt;
&lt;br /&gt;
# Create a table named '''students''' with the following fields:&lt;br /&gt;
#* '''id''' of an appropriately-sized unsigned integer type (we will never need to process more than a million students)&lt;br /&gt;
#* '''first_name''' of type '''VARCHAR(50)'''&lt;br /&gt;
#* '''last_name''' of type '''VARCHAR(50)'''&lt;br /&gt;
#* '''email_address''' of type '''VARCHAR(50)'''&lt;br /&gt;
#: The primary key should be on the '''id''' field.&lt;br /&gt;
# Create a table named '''departments''' with the following fields:&lt;br /&gt;
#* '''school_code''' of type '''ENUM''' (e.g. &amp;quot;L&amp;quot; for ArtSci and &amp;quot;E&amp;quot; for Engineering).  The options are as follows:&lt;br /&gt;
#*: 'L', 'B', 'A', 'F', 'E', 'T', 'I', 'W', 'S', 'U', 'M'&lt;br /&gt;
#* '''dept_id''' of an appropriately-sized unsigned integer type (in the foreseeable future there will never be more than 200 departments in a school)&lt;br /&gt;
#* '''abbreviation''' of type '''VARCHAR(9)''' (e.g. CSE, ChemE, etc)&lt;br /&gt;
#* '''dept_name''' of type '''VARCHAR(200)''' (e.g. Computer Science and Engineering)&lt;br /&gt;
#: The primary key should be on two fields: '''school_code''' and '''dept_id'''&lt;br /&gt;
#: '''Note:''' Why not just use the department ID for the primary key? The ID numbers are sometimes reused across schools. For instance, department 33 in The College of Arts and Sciences is Psychology while department 33 in The School of Engineering and Applied Sciences is Energy, Environmental and Chemical Engineering. Thus we must also include the school code to differentiate them  such that the record for  E33 is distinct from that of L33.&lt;br /&gt;
# Create a table named '''courses''' with the following fields:&lt;br /&gt;
#* '''school_code''' of type '''ENUM'''&lt;br /&gt;
#*: This should have the same letters in the same order as the '''school_code''' '''ENUM''' field in the '''departments''' table.&lt;br /&gt;
#* '''dept_id''' of the same size of integer as in the '''departments''' table&lt;br /&gt;
#* '''course_code''' of type '''CHAR(5)''' (this will hold course codes; e.g., '330S', '131', '2960')&lt;br /&gt;
#* '''name''' of type '''VARCHAR(150)'''&lt;br /&gt;
#: The appropriate fields in this table should make a foreign key reference to the corresponding fields in '''department'''.&lt;br /&gt;
#: In addition, it is up to you to determine the field(s) for the primary key.&lt;br /&gt;
#: '''Note:''' If you are unsure which fields to make the foreign keys and feel the need to beg your friends or the TAs to give you the answer, bang your head on your desk whilst repeating &amp;quot;I WILL EXERCISE REASON AND COMMON SENSE AND I WILL CURTAIL MY DESIRE TO BLINDLY FOLLOW DIRECTIONS&amp;quot;&lt;br /&gt;
#: ''Disclaimer: don't actually bang your head on your desk, the resulting head trauma may in fact make it harder for you to determine which fields should have associated foreign keys.''&lt;br /&gt;
# Create a table named '''grades''' with the following fields:&lt;br /&gt;
#* '''pk_grade_ID''' of an appropriately-sized unsigned integer type (should be larger than the one you chose for the '''students''' table)&lt;br /&gt;
#*: You should declare this field to be '''auto_increment''' and make it the primary key.&lt;br /&gt;
#*: This is called a ''surrogate key'' as opposed to a ''natural key'' because it doesn't arise &amp;quot;naturally&amp;quot; from the data; that is to say that it is not derived from application data. The use of surrogate keys vs. natural keys is a polemic issue amongst database designers.  For a decently unbiased take on the issue, see this page: http://www.agiledata.org/essays/keys.html#Comparison&lt;br /&gt;
#*: '''Food for thought:''' Aside from simply exposing you to the concept, can you think of any reasons why a surrogate key might be preferable for this table?  Alternatively, what attributes, if any, could you use as a natural key, and what might be the drawbacks of doing so?&lt;br /&gt;
#* '''student_id''' of the same integer (unsigned) type that you chose in the '''students''' table&lt;br /&gt;
#* '''grade''' of type '''decimal(5,2)'''&lt;br /&gt;
#* '''school_code''' of type '''ENUM'''&lt;br /&gt;
#*: Can you guess what entries to use for the enum?&lt;br /&gt;
#* '''dept_id''' of the same integer type that you've used for this field in other tables&lt;br /&gt;
#* '''course_code''' of the same type you chose for the course code in the '''courses''' table&lt;br /&gt;
#: The '''grades''' table should have foreign keys to both the '''students''' table and the '''courses''' table.&lt;br /&gt;
&lt;br /&gt;
=== Populate Tables ===&lt;br /&gt;
&lt;br /&gt;
Now, populate the tables by downloading the text files given below and loading them into the appropriate tables.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Do not insert all the values manually; instead, use the MySQL's ability to load in data from text files.&lt;br /&gt;
&lt;br /&gt;
You may find the following article to be very helpful: [[MySQL Schema and State]]&lt;br /&gt;
&lt;br /&gt;
The files containing the data are:&lt;br /&gt;
* students: http://classes.engineering.wustl.edu/cse330/content/students_data.txt&lt;br /&gt;
* courses: http://classes.engineering.wustl.edu/cse330/content/courses.txt&lt;br /&gt;
* departments: http://classes.engineering.wustl.edu/cse330/content/departments_data.txt&lt;br /&gt;
* grades: http://classes.engineering.wustl.edu/cse330/content/grades_data.txt&lt;br /&gt;
&lt;br /&gt;
=== Insert More Data ===&lt;br /&gt;
&lt;br /&gt;
Insert the following data into the tables that you have created and populated:&lt;br /&gt;
&lt;br /&gt;
# Insert an entry for CSE 330S&lt;br /&gt;
#: ''If you don't know CSE's department code, how can you find out using the tables in the database?''&lt;br /&gt;
# Insert the grades given for the students named below.  You may choose to make the entries for whichever classes you like, with the one condition that all of the students must have a grade for CSE 330S (who wouldn't want to take that class: I hear the professor and TAs are amazing!)&lt;br /&gt;
#* '''Ben Harper'''&lt;br /&gt;
#** E-mail: '''bharper@ffym.com'''&lt;br /&gt;
#** Student ID: '''88'''&lt;br /&gt;
#** Grades:&lt;br /&gt;
#*** 35.5 (CSE 330S grade)&lt;br /&gt;
#*** 0&lt;br /&gt;
#*** 95&lt;br /&gt;
#* '''Matt Freeman'''&lt;br /&gt;
#** E-mail: '''mfreeman@kickinbassist.net'''&lt;br /&gt;
#** Student ID: '''202'''&lt;br /&gt;
#** Grades:&lt;br /&gt;
#*** 100 (CSE 330S grade)&lt;br /&gt;
#*** 90.5&lt;br /&gt;
#*** 94.8&lt;br /&gt;
#* '''Marc Roberge'''&lt;br /&gt;
#** E-mail: '''mroberge@ofarevolution.us'''&lt;br /&gt;
#** Student ID: '''115'''&lt;br /&gt;
#** Grades:&lt;br /&gt;
#*** 75 (CSE 330S grade)&lt;br /&gt;
#*** 37&lt;br /&gt;
#*** 45.5&lt;br /&gt;
#: You may choose any 3 classes you'd like for them to be enrolled in, with at least one class, &amp;quot;CSE 330S&amp;quot;, in which they are all enrolled.&lt;br /&gt;
&lt;br /&gt;
=== Querying Your Database ===&lt;br /&gt;
&lt;br /&gt;
Now that you have a fully-functional, populated database, let's do some queries on it!&lt;br /&gt;
&lt;br /&gt;
Please take a screenshot of running the following '''select''' queries and commit them with the rest of your repository (be sure to include your query command and the response):&lt;br /&gt;
&lt;br /&gt;
# Select the entire grades table.&lt;br /&gt;
# Select all fields describing the courses offered in the school of arts and sciences (school code L).&lt;br /&gt;
# The names, student IDs, and CSE330 grades of the students who are in CSE330S.&lt;br /&gt;
#: '''Note:''' This query should involve joins.  You don't need to use any aggregation functions.&lt;br /&gt;
# The names, e-mails, and average grades of any student with an average below 50 so that the dean can send them an email notification that they are now on academic probation.&lt;br /&gt;
#: ''You should be able to do this in only one query, without making any temporary tables.  You will need to use aggregation functions and the '''having''' keyword.''&lt;br /&gt;
# An individual report card for Jack Johnson, consisting of his student ID, e-mail address, and average grade.&lt;br /&gt;
#: ''Again, you should be able to do this in just one query, using the correct combination of aggregation functions and joins.''&lt;br /&gt;
#: '''Note:''' Your query must look for students with the name Jack Johnson instead of hard-coding the student ID.&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
You will work in pairs on this project.  You may work with the same partner from Module 2, or change to someone else.&lt;br /&gt;
&lt;br /&gt;
'''Important Reminder:''' frequently commit your work to your Git repository as a backup!&lt;br /&gt;
&lt;br /&gt;
=== Simple News Web Site ===&lt;br /&gt;
&lt;br /&gt;
'''Examples:'''&lt;br /&gt;
* http://digg.com/&lt;br /&gt;
* http://slashdot.org/&lt;br /&gt;
&lt;br /&gt;
You should use '''PHP''' unless you get permission to use another web technology from the instructor.  You may also use phpMyAdmin to help set up databases.&lt;br /&gt;
&lt;br /&gt;
You may find this wiki article helpful: [[PHP and MySQL]]&lt;br /&gt;
&lt;br /&gt;
==== Requirements ====&lt;br /&gt;
&lt;br /&gt;
* Users can register for accounts and then log in to the website.&lt;br /&gt;
* Accounts should have both a username and a ''secure'' password.  '''NEVER store plaintext passwords in a database!'''&lt;br /&gt;
*: For more information on password security, refer to [[Web Application Security, Part 2#Password Security|the Web Application Security guide]].&lt;br /&gt;
* Registered users can submit story commentary.&lt;br /&gt;
*: A link can be associated with each story, and they should be stored in a separate database field from the story&lt;br /&gt;
* Registered users can comment on any story.&lt;br /&gt;
* Unregistered users can only view stories and comments.&lt;br /&gt;
* Registered users can edit and delete their stories and comments.&lt;br /&gt;
* All data must be kept in a MySQL database (user information, stories, comments, and links).&lt;br /&gt;
* Creative Portion&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
No application is finished until much thought is put into web security and best practice.  Throughout this course, we heavily emphasize the dogma of [http://coderesponsibly.org/ responsible] coding.&lt;br /&gt;
&lt;br /&gt;
Read this week's Web Application Security guide: [[Web Application Security, Part 2]].  In particular, your project needs to:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to be secure from SQL injection attacks'''. If you are using prepared queries, you should already be safe on this front.&lt;br /&gt;
* '''Your passwords need to be securely salted''' to prevent rainbow table attacks.&lt;br /&gt;
* '''You should pass tokens in forms''' to prevent CSRF attacks.&lt;br /&gt;
* '''You should check all preconditions on the server side''' to prevent Abuse of Functionality attacks.&lt;br /&gt;
&lt;br /&gt;
You shouldn't forget the practices you learned last week:&lt;br /&gt;
&lt;br /&gt;
* '''Your page should validate''' with no errors through the W3C validator.&lt;br /&gt;
* '''Filter Input and Escape Output''', but not the other way around.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. ''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID1-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-201343-314450) &lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, or share it with cse330, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
________&lt;br /&gt;
&lt;br /&gt;
# '''MySQL Queries (25 Points):'''&lt;br /&gt;
#* A MySQL server is running on your instance (2 points)&lt;br /&gt;
#* Tables fields, including data types, are correct (4 points)&lt;br /&gt;
#* Foreign keys are correct (4 points)&lt;br /&gt;
#* The output of each of the five queries is correct (3 points each)&lt;br /&gt;
# '''News Site (60 Points):'''&lt;br /&gt;
#* '''''User Management (20 Points):'''''&lt;br /&gt;
#** A session is created when a user logs in (3 points)&lt;br /&gt;
#** New users can register (3 points)&lt;br /&gt;
#** Passwords are hashed using salted one-way encryption (3 points)&lt;br /&gt;
#** Users can log out (3 points)&lt;br /&gt;
#** A user can edit and delete his/her own stories and comments but cannot edit or delete the stories or comments of another user (8 points)&lt;br /&gt;
#* '''''Story and Comment Management (20 Points):'''''&lt;br /&gt;
#** Relational database is configured with correct data types and foreign keys (4 points)&lt;br /&gt;
#** Stories can be posted (3 points)&lt;br /&gt;
#** A link can be associated with each story, and they should be stored in a separate database field from the story (3 points)&lt;br /&gt;
#** Comments can be posted in association with a story (4 points)&lt;br /&gt;
#** Stories can be edited and deleted (3 points)&lt;br /&gt;
#** Comments can be edited and deleted (3 points)&lt;br /&gt;
#**: ''Note: Although there are only 6 points allocated for editing/deleting in this section, there are 8 more points at stake in the User Management section that cannot be earned unless editing/deleting is implemented.  Implementing editing but not deleting, or vice-versa, will result in earning half the points.''&lt;br /&gt;
#* '''''Best Practices (15 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (3 points)&lt;br /&gt;
#** Safe from SQL Injection attacks (2 points)&lt;br /&gt;
#** Site follows the FIEO philosophy (3 points)&lt;br /&gt;
#** All pages pass the W3C validator (2 points)&lt;br /&gt;
#** CSRF tokens are passed when creating, editing, and deleting comments and stories (5 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Site is intuitive to use and navigate (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (15 Points)''' (see below)&lt;br /&gt;
#* '''''Make sure you have a README.md file in your group repo with the following:'''''&lt;br /&gt;
#** Names and Student IDs of all the group members&lt;br /&gt;
#** A link to your homepage of the site&lt;br /&gt;
#** A brief description of what you did for your creative portion&lt;br /&gt;
#** Any additional login details needed for the TA&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 3]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>James</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2247</id>
		<title>Module 2</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2247"/>
		<updated>2017-01-27T14:22:14Z</updated>

		<summary type="html">&lt;p&gt;James: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 2 introduces you to Linux, a command-line environment, the Apache web server, and PHP.  You will create and configure your own cloud instance, install Apache and related software, and then form groups to make a simple file sharing site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;'''DO NOT WAIT UNTIL THE LAST MINUTE TO START ON THIS (or any) MODULE!'''  The most common reason students perform poorly in this class is procrastination.  You have been warned.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Linux]]&lt;br /&gt;
* [[Bash]]&lt;br /&gt;
* [[Amazon Web Services]]&lt;br /&gt;
* [[SSH]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[Workflow]]&lt;br /&gt;
* [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;There are a lot of wiki pages that you need to read in order to complete the individual portion of Module 2.  The wiki pages contain an assortment of required steps, optional steps, and information.  To make things easier, we have highlighted the ''required steps'' with a red bar, like you see on the left of this message.  Do not skip anything marked with a red bar, or else you will not have a perfectly configured instance.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Learn About Linux ===&lt;br /&gt;
&lt;br /&gt;
Linux is an open-source operating system based on UNIX. Linux is highly versatile and is used in a wide range of applications.&lt;br /&gt;
&lt;br /&gt;
If you are not a Linux guru, read the Linux guide to get started: [[Linux]]&lt;br /&gt;
&lt;br /&gt;
=== Install Cygwin: Windows Users Only ===&lt;br /&gt;
&lt;br /&gt;
You will need Cygwin in order to log into and configure your EC2 instance.  Cygwin is already installed on the CEC machines.  Instructions for installing Cygwin on your personal machine are located in [[Workflow#Cygwin|the Workflow guide]].&lt;br /&gt;
&lt;br /&gt;
Mac OS X users should located the &amp;quot;Terminal&amp;quot; application, which is installed by default; you will need this in the coming steps.&lt;br /&gt;
&lt;br /&gt;
=== Create an AWS EC2 Instance ===&lt;br /&gt;
&lt;br /&gt;
Once you understand [[Linux]], you need to set up your Amazon EC2 Instance.  Use the AWS article to guide you through the process: [[Amazon Web Services]]&lt;br /&gt;
&lt;br /&gt;
=== Configure SSH ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions in [[SSH#SSH Configuration|the SSH guide]] to do the following:&lt;br /&gt;
&lt;br /&gt;
# Create your own SSH key pair&lt;br /&gt;
# Log in as the default user to your EC2 instance&lt;br /&gt;
# Create a new user&lt;br /&gt;
# Give the new user your SSH public key&lt;br /&gt;
&lt;br /&gt;
From now on, when you need to log into your EC2 instance as an administrator, just pop up a terminal and run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ ssh your-username@ec2-xx-xx-xx-xx.compute-1.amazonaws.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install Essential Packages ===&lt;br /&gt;
&lt;br /&gt;
Recall that software installation in Linux instances is usually handled through '''apt''' (Debian) or '''yum''' (RHEL).  For more information, refer to [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
To make sure everything is working properly, '''install your first package(s) according to the ''Essential Packages'' subsection in the Linux guide.'''&lt;br /&gt;
&lt;br /&gt;
=== Set the Timezone ===&lt;br /&gt;
&lt;br /&gt;
'''Set your server to use US Central time (America/Chicago).'''  Instructions are in the Linux guide: [[Linux#Synchronizing Date and Time]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up the Apache Web Server ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install the Apache web server on your EC2 instance'''.  Refer to [[Apache|the Apache guide]].&lt;br /&gt;
&lt;br /&gt;
In order for your web server to be accessible, you need to '''open up Port 80 on your EC2 instance'''.  Instructions are in the AWS guide: [[Amazon Web Services#Enabling Web Access to your EC2 Instance]]&lt;br /&gt;
&lt;br /&gt;
'''Enable the UserDir module in Apache.'''  Instructions are in the Apache guide: [[Apache#The UserDir Module]]&lt;br /&gt;
&lt;br /&gt;
=== Install PHP ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install PHP on your EC2 server'''.  Instructions are at the top of the PHP guide: [[PHP]]&lt;br /&gt;
&lt;br /&gt;
You need to '''configure PHP to show errors'''.  Instructions are immediately below installation in the PHP guide.&lt;br /&gt;
&lt;br /&gt;
=== Learn the PHP Language ===&lt;br /&gt;
&lt;br /&gt;
Before you can continue, you will need to make yourself acquainted with PHP language components.  Read the PHP guide for an overview: [[PHP#PHP Language Components]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up your Workspace ===&lt;br /&gt;
&lt;br /&gt;
You are now ready to set up the workspace that you will be using for the rest of the semester.  Follow the instructions in [[Workflow]] to:&lt;br /&gt;
&lt;br /&gt;
# Make an account on Bitbucket&lt;br /&gt;
# Make a repository for your individual work for CSE 330&lt;br /&gt;
# Install SourceTree&lt;br /&gt;
# '''Windows only:''' Set up Pageant so that SourceTree can conect to Bitbucket&lt;br /&gt;
# Clone your CSE 330 repo from Bitbucket&lt;br /&gt;
# Install Komodo Edit&lt;br /&gt;
# Create a Komodo Edit Project inside of your Git repository&lt;br /&gt;
# Add the ''*.komodoproject'' file to ''.gitignore''&lt;br /&gt;
# Install FileZilla&lt;br /&gt;
# Connect FileZilla to your remote instance&lt;br /&gt;
&lt;br /&gt;
=== Calculator ===&lt;br /&gt;
&lt;br /&gt;
'''Make a calculator using PHP and an HTML form.'''  The form should have two inputs.  The form should submit a GET request either back to the same page or to a different results page.  The calculator should support addition, subtraction, multiplication, and division by means of a radio button group on the page.  (Consider edge cases!)&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
You will work in pairs (that means you and one other person) on this project.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;In this module, and all future modules, the group portion builds off of material you learn in the individual portion.  You should therefore complete the individual portions prior to working on the group portions.  (Trust us: it will make your life easier!)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Important Reminder:''' frequently commit your work to your repository as a backup!&lt;br /&gt;
&lt;br /&gt;
=== Simple File Sharing Site ===&lt;br /&gt;
&lt;br /&gt;
You will be making a simple file sharing site that supports uploading, viewing, and deleting files associated with various users.  Details:&lt;br /&gt;
&lt;br /&gt;
* You should have a file named '''users.txt''' stored in a secure place on your filesystem.  It should have at least three usernames, with one username per line.&lt;br /&gt;
*: Passwords add an extra layer of complexity (encryption) that we will cover in Module 3.  You will not earn credit for implementing passwords as your creative portion for this module.&lt;br /&gt;
* Users of the file sharing site should be able to enter their username and then log in.&lt;br /&gt;
*: You may implement logins using session variables, or you may implement them using a GET parameter that is passed between pages.  You will need to always use sessions starting in Module 3.&lt;br /&gt;
* Users should see a list of all files associated with their username after the log in.&lt;br /&gt;
* Users should be able to view, upload, and delete files associated with their username.&lt;br /&gt;
* The URI should NOT reveal the internal file structure of your web site.&lt;br /&gt;
** Example of what not to do:  http://www.example.com/download.php?file=/home/paul/file.txt&lt;br /&gt;
** Another bad example:  http://www.example.com/~user/file.txt&lt;br /&gt;
** Good example: http://www.example.com/view.php?user=music&amp;amp;name=file.txt&lt;br /&gt;
*: In general, don't reveal any internal information about the site.&lt;br /&gt;
*: '''Food for thought:''' Given that Apache processes (with the exception of the main process) do not run as root, but rather as the user apache, how can you allow both your user account and the php scripts to read and write the &lt;br /&gt;
*:necessary files?&lt;br /&gt;
*:: ''Hint:'' You shouldn't be storing the user-uploaded files in public_html (that is only the place for your own web-page files), &lt;br /&gt;
*::''Hint number 2:''  you will need to use chown to change permissions to let user apache (or www-data for Ubuntu) have permissions on the user-files (that '''are not''' in the public_html folder). If you don't know what this does or how to do this, look at the [[Apache]] page&lt;br /&gt;
* You should customize your file sharing site by implementing an additional feature or two as part of the '''creative portion'''.&lt;br /&gt;
&lt;br /&gt;
You will probably find the PHP guide on this wiki to be helpful: [[PHP#Other PHP Tips]]&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
Your project needs to demonstrate that thought was put into web security and best practice.  For more information, see this week's Web Application Security guide: [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
In particular:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to follow the conventions of FIEO (Filter Input and Escape Output)'''.  Things you should filter include file names, usernames, and so on.&lt;br /&gt;
* '''Your project must pass the W3C Validator with no errors'''.  For more information, see the HTML and CSS guide: [[HTML and CSS#Validation]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total.&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. &lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID1-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-201343-312532) &lt;br /&gt;
#* OR, if you are working alone, put both your individual and group portions in your individual repo&lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, or share it with cse330, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
_____________&lt;br /&gt;
&lt;br /&gt;
# '''Cloud Instance and Web Server (30 Points):'''&lt;br /&gt;
#* You can SSH into your instance using your own custom username and SSH key. Put a screenshot in your repository of your terminal SSH-ing into your instance (15 points)&lt;br /&gt;
#* Your custom username is able to perform SUDO commands. Put a screenshot in your repository of you successfully executing a command with sudo (5 points)&lt;br /&gt;
#* The time zone is correct on your instance. Put a screenshot in your repository of the results of the `date` command (5 points)&lt;br /&gt;
#* The UserDir Apache module is working. Place a file in /home/&amp;lt;username&amp;gt;/public_html and link to the file in your README.md (5 points)&lt;br /&gt;
# '''PHP Calculator (15 Points):'''&lt;br /&gt;
#* The calculator is able to perform all four functions (2 points each, 8 points in total)&lt;br /&gt;
#* Each function is given as a radio button choice (4 points)&lt;br /&gt;
#* The calculator page passes the W3C HTML validator (3 points)&lt;br /&gt;
# '''File Sharing Site (40 Points):'''&lt;br /&gt;
#* '''''File Management (25 Points):'''''&lt;br /&gt;
#** Users should not be able to see any files until they enter a username and log in (4 points)&lt;br /&gt;
#**: ''Remember that users.txt should be stored in a secure location on your filesystem.  That is, '''you should not be able to type any URL into your browser and see the raw users.txt file!'''''&lt;br /&gt;
#** Users can see a list of all files they have uploaded (4 points)&lt;br /&gt;
#** Users can open files they have previously uploaded (5 points)&lt;br /&gt;
#**: ''Note: Users should be able to open not only plain text files but also other file formats: images, spreadsheets, etc.''&lt;br /&gt;
#** Users can upload files (4 points)&lt;br /&gt;
#**: ''Note: Like users.txt, uploaded files should be stored in a secure location on your filesystem.  That is, '''do not keep your uploads directory underneath a directory served by Apache!'''''&lt;br /&gt;
#** Users can delete files.  If a file is &amp;quot;deleted&amp;quot;, it should actually be removed from the filesystem (4 points)&lt;br /&gt;
#** The directory structure is hidden (2 points)&lt;br /&gt;
#** Users can log out (2 points)&lt;br /&gt;
#**: ''Note: If using session variables, you must ''actually'' log out the user by destroying their session; i.e., don't just redirect them to the login screen.''&lt;br /&gt;
#* '''''Best Practices (10 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (4 points)&lt;br /&gt;
#** The site follows the FIEO philosophy (3 points)&lt;br /&gt;
#** All pages pass the W3C validator (3 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Site is intuitive to use and navigate (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (15 Points)''' (see below)&lt;br /&gt;
#* '''''Make sure you have a README.md file in your group repo with the following:'''''&lt;br /&gt;
#** An .md file is a plain text file called a markdown file  [https://guides.github.com/features/mastering-markdown/ ] .  &lt;br /&gt;
#***The contents of your README.md file are shown on your repo, making it easier for us to grade&lt;br /&gt;
#*** You may style the page with bolding, hyperlings, images, block quotes and lists&lt;br /&gt;
#*** [http://dillinger.io/ This online markdown editor] makes it easy to learn this format  &lt;br /&gt;
#** The link to BOTH your calculator and your file sharing site. '''''We need this to grade your work.'''''&lt;br /&gt;
#** A brief description of what you did for your creative portion&lt;br /&gt;
#** Any additional login details needed for the TA&lt;br /&gt;
&lt;br /&gt;
=== Creative Portion ===&lt;br /&gt;
&lt;br /&gt;
This module, and all future modules, will require that you invest some time into creating additional features for your group project.  Plan to invest at least 60 minutes of your time into the creative portion.&lt;br /&gt;
&lt;br /&gt;
* The creative portion is an opportunity for you to learn material of your own interest.&lt;br /&gt;
* You will not earn credit for a creative-portion feature that simply rehashes something you've already done in a previous module.&lt;br /&gt;
&lt;br /&gt;
If you need ideas for a creative portion, or if you want to know whether or not your creative portion idea is &amp;quot;hard enough&amp;quot;, ask a TA.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>James</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2246</id>
		<title>Module 2</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2246"/>
		<updated>2017-01-27T14:20:01Z</updated>

		<summary type="html">&lt;p&gt;James: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 2 introduces you to Linux, a command-line environment, the Apache web server, and PHP.  You will create and configure your own cloud instance, install Apache and related software, and then form groups to make a simple file sharing site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;'''DO NOT WAIT UNTIL THE LAST MINUTE TO START ON THIS (or any) MODULE!'''  The most common reason students perform poorly in this class is procrastination.  You have been warned.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Linux]]&lt;br /&gt;
* [[Bash]]&lt;br /&gt;
* [[Amazon Web Services]]&lt;br /&gt;
* [[SSH]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[Workflow]]&lt;br /&gt;
* [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;There are a lot of wiki pages that you need to read in order to complete the individual portion of Module 2.  The wiki pages contain an assortment of required steps, optional steps, and information.  To make things easier, we have highlighted the ''required steps'' with a red bar, like you see on the left of this message.  Do not skip anything marked with a red bar, or else you will not have a perfectly configured instance.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Learn About Linux ===&lt;br /&gt;
&lt;br /&gt;
Linux is an open-source operating system based on UNIX. Linux is highly versatile and is used in a wide range of applications.&lt;br /&gt;
&lt;br /&gt;
If you are not a Linux guru, read the Linux guide to get started: [[Linux]]&lt;br /&gt;
&lt;br /&gt;
=== Install Cygwin: Windows Users Only ===&lt;br /&gt;
&lt;br /&gt;
You will need Cygwin in order to log into and configure your EC2 instance.  Cygwin is already installed on the CEC machines.  Instructions for installing Cygwin on your personal machine are located in [[Workflow#Cygwin|the Workflow guide]].&lt;br /&gt;
&lt;br /&gt;
Mac OS X users should located the &amp;quot;Terminal&amp;quot; application, which is installed by default; you will need this in the coming steps.&lt;br /&gt;
&lt;br /&gt;
=== Create an AWS EC2 Instance ===&lt;br /&gt;
&lt;br /&gt;
Once you understand [[Linux]], you need to set up your Amazon EC2 Instance.  Use the AWS article to guide you through the process: [[Amazon Web Services]]&lt;br /&gt;
&lt;br /&gt;
=== Configure SSH ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions in [[SSH#SSH Configuration|the SSH guide]] to do the following:&lt;br /&gt;
&lt;br /&gt;
# Create your own SSH key pair&lt;br /&gt;
# Log in as the default user to your EC2 instance&lt;br /&gt;
# Create a new user&lt;br /&gt;
# Give the new user your SSH public key&lt;br /&gt;
&lt;br /&gt;
From now on, when you need to log into your EC2 instance as an administrator, just pop up a terminal and run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ ssh your-username@ec2-xx-xx-xx-xx.compute-1.amazonaws.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install Essential Packages ===&lt;br /&gt;
&lt;br /&gt;
Recall that software installation in Linux instances is usually handled through '''apt''' (Debian) or '''yum''' (RHEL).  For more information, refer to [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
To make sure everything is working properly, '''install your first package(s) according to the ''Essential Packages'' subsection in the Linux guide.'''&lt;br /&gt;
&lt;br /&gt;
=== Set the Timezone ===&lt;br /&gt;
&lt;br /&gt;
'''Set your server to use US Central time (America/Chicago).'''  Instructions are in the Linux guide: [[Linux#Synchronizing Date and Time]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up the Apache Web Server ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install the Apache web server on your EC2 instance'''.  Refer to [[Apache|the Apache guide]].&lt;br /&gt;
&lt;br /&gt;
In order for your web server to be accessible, you need to '''open up Port 80 on your EC2 instance'''.  Instructions are in the AWS guide: [[Amazon Web Services#Enabling Web Access to your EC2 Instance]]&lt;br /&gt;
&lt;br /&gt;
'''Enable the UserDir module in Apache.'''  Instructions are in the Apache guide: [[Apache#The UserDir Module]]&lt;br /&gt;
&lt;br /&gt;
=== Install PHP ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install PHP on your EC2 server'''.  Instructions are at the top of the PHP guide: [[PHP]]&lt;br /&gt;
&lt;br /&gt;
You need to '''configure PHP to show errors'''.  Instructions are immediately below installation in the PHP guide.&lt;br /&gt;
&lt;br /&gt;
=== Learn the PHP Language ===&lt;br /&gt;
&lt;br /&gt;
Before you can continue, you will need to make yourself acquainted with PHP language components.  Read the PHP guide for an overview: [[PHP#PHP Language Components]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up your Workspace ===&lt;br /&gt;
&lt;br /&gt;
You are now ready to set up the workspace that you will be using for the rest of the semester.  Follow the instructions in [[Workflow]] to:&lt;br /&gt;
&lt;br /&gt;
# Make an account on Bitbucket&lt;br /&gt;
# Make a repository for your individual work for CSE 330&lt;br /&gt;
# Install SourceTree&lt;br /&gt;
# '''Windows only:''' Set up Pageant so that SourceTree can conect to Bitbucket&lt;br /&gt;
# Clone your CSE 330 repo from Bitbucket&lt;br /&gt;
# Install Komodo Edit&lt;br /&gt;
# Create a Komodo Edit Project inside of your Git repository&lt;br /&gt;
# Add the ''*.komodoproject'' file to ''.gitignore''&lt;br /&gt;
# Install FileZilla&lt;br /&gt;
# Connect FileZilla to your remote instance&lt;br /&gt;
&lt;br /&gt;
=== Calculator ===&lt;br /&gt;
&lt;br /&gt;
'''Make a calculator using PHP and an HTML form.'''  The form should have two inputs.  The form should submit a GET request either back to the same page or to a different results page.  The calculator should support addition, subtraction, multiplication, and division by means of a radio button group on the page.  (Consider edge cases!)&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
You will work in pairs (that means you and one other person) on this project.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;In this module, and all future modules, the group portion builds off of material you learn in the individual portion.  You should therefore complete the individual portions prior to working on the group portions.  (Trust us: it will make your life easier!)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Important Reminder:''' frequently commit your work to your repository as a backup!&lt;br /&gt;
&lt;br /&gt;
=== Simple File Sharing Site ===&lt;br /&gt;
&lt;br /&gt;
You will be making a simple file sharing site that supports uploading, viewing, and deleting files associated with various users.  Details:&lt;br /&gt;
&lt;br /&gt;
* You should have a file named '''users.txt''' stored in a secure place on your filesystem.  It should have at least three usernames, with one username per line.&lt;br /&gt;
*: Passwords add an extra layer of complexity (encryption) that we will cover in Module 3.  You will not earn credit for implementing passwords as your creative portion for this module.&lt;br /&gt;
* Users of the file sharing site should be able to enter their username and then log in.&lt;br /&gt;
*: You may implement logins using session variables, or you may implement them using a GET parameter that is passed between pages.  You will need to always use sessions starting in Module 3.&lt;br /&gt;
* Users should see a list of all files associated with their username after the log in.&lt;br /&gt;
* Users should be able to view, upload, and delete files associated with their username.&lt;br /&gt;
* The URI should NOT reveal the internal file structure of your web site.&lt;br /&gt;
** Example of what not to do:  http://www.example.com/download.php?file=/home/paul/file.txt&lt;br /&gt;
** Another bad example:  http://www.example.com/~user/file.txt&lt;br /&gt;
** Good example: http://www.example.com/view.php?user=music&amp;amp;name=file.txt&lt;br /&gt;
*: In general, don't reveal any internal information about the site.&lt;br /&gt;
*: '''Food for thought:''' Given that Apache processes (with the exception of the main process) do not run as root, but rather as the user apache, how can you allow both your user account and the php scripts to read and write the &lt;br /&gt;
*:necessary files?&lt;br /&gt;
*:: ''Hint:'' You shouldn't be storing the user-uploaded files in public_html (that is only the place for your own web-page files), &lt;br /&gt;
*::''Hint number 2:''  you will need to use chown to change permissions to let user apache (or www-data for Ubuntu) have permissions on the user-files (that '''are not''' in the public_html folder). If you don't know what this does or how to do this, look at the [[Apache]] page&lt;br /&gt;
* You should customize your file sharing site by implementing an additional feature or two as part of the '''creative portion'''.&lt;br /&gt;
&lt;br /&gt;
You will probably find the PHP guide on this wiki to be helpful: [[PHP#Other PHP Tips]]&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
Your project needs to demonstrate that thought was put into web security and best practice.  For more information, see this week's Web Application Security guide: [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
In particular:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to follow the conventions of FIEO (Filter Input and Escape Output)'''.  Things you should filter include file names, usernames, and so on.&lt;br /&gt;
* '''Your project must pass the W3C Validator with no errors'''.  For more information, see the HTML and CSS guide: [[HTML and CSS#Validation]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total.&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. &lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID1-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-201343-312532) &lt;br /&gt;
#* OR, if you are working alone, put both your individual and group portions in your individual repo&lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, or share it with cse330, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
_____________&lt;br /&gt;
&lt;br /&gt;
# '''Cloud Instance and Web Server (30 Points):'''&lt;br /&gt;
#* You can SSH into your instance using your own custom username and SSH key. Put a screenshot in your repository of your terminal SSH-ing into your instance (15 points)&lt;br /&gt;
#* Your custom username is able to perform SUDO commands. Put a screenshot in your repository of you successfully executing a command with sudo (5 points)&lt;br /&gt;
#* The time zone is correct on your instance. Put a screenshot in your repository of the results of the `date` command (5 points)&lt;br /&gt;
#* The UserDir Apache module is working. Place a file in /home/&amp;lt;username&amp;gt;/public_html and link to the file in your README.md (5 points)&lt;br /&gt;
# '''PHP Calculator (15 Points):'''&lt;br /&gt;
#* The calculator is able to perform all four functions (2 points each, 8 points in total)&lt;br /&gt;
#* Each function is given as a radio button choice (4 points)&lt;br /&gt;
#* The calculator page passes the W3C HTML validator (3 points)&lt;br /&gt;
# '''File Sharing Site (40 Points):'''&lt;br /&gt;
#* '''''File Management (25 Points):'''''&lt;br /&gt;
#** Users should not be able to see any files until they enter a username and log in (4 points)&lt;br /&gt;
#**: ''Remember that users.txt should be stored in a secure location on your filesystem.  That is, '''you should not be able to type any URL into your browser and see the raw users.txt file!'''''&lt;br /&gt;
#** Users can see a list of all files they have uploaded (4 points)&lt;br /&gt;
#** Users can open files they have previously uploaded (5 points)&lt;br /&gt;
#**: ''Note: Users should be able to open not only plain text files but also other file formats: images, spreadsheets, etc.''&lt;br /&gt;
#** Users can upload files (4 points)&lt;br /&gt;
#**: ''Note: Like users.txt, uploaded files should be stored in a secure location on your filesystem.  That is, '''do not keep your uploads directory underneath a directory served by Apache!'''''&lt;br /&gt;
#** Users can delete files.  If a file is &amp;quot;deleted&amp;quot;, it should actually be removed from the filesystem (4 points)&lt;br /&gt;
#** The directory structure is hidden (2 points)&lt;br /&gt;
#** Users can log out (2 points)&lt;br /&gt;
#**: ''Note: If using session variables, you must ''actually'' log out the user by destroying their session; i.e., don't just redirect them to the login screen.''&lt;br /&gt;
#* '''''Best Practices (10 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (4 points)&lt;br /&gt;
#** The site follows the FIEO philosophy (3 points)&lt;br /&gt;
#** All pages pass the W3C validator (3 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Site is intuitive to use and navigate (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (15 Points)''' (see below)&lt;br /&gt;
#* '''''Make sure you have a README.md file in your group repo with the following:'''''&lt;br /&gt;
#** An .md file is a plain text file called a markdown file  [https://guides.github.com/features/mastering-markdown/ ] .  &lt;br /&gt;
#***The contents of your README.md file are shown on your repo, making it easier for us to grade&lt;br /&gt;
#*** You may style the page with bolding, hyperlings, images, block quotes and lists&lt;br /&gt;
#*** [http://dillinger.io/ This online markdown editor] makes it easy to learn this format  &lt;br /&gt;
#** The url of BOTH your calculator and your file sharing site. '''''We need this to grade your work.'''''&lt;br /&gt;
#** Names and Student IDs of all the group members&lt;br /&gt;
#** A link to the front page of your site&lt;br /&gt;
#** A brief description of what you did for your creative portion&lt;br /&gt;
#** Any additional login details needed for the TA&lt;br /&gt;
&lt;br /&gt;
=== Creative Portion ===&lt;br /&gt;
&lt;br /&gt;
This module, and all future modules, will require that you invest some time into creating additional features for your group project.  Plan to invest at least 60 minutes of your time into the creative portion.&lt;br /&gt;
&lt;br /&gt;
* The creative portion is an opportunity for you to learn material of your own interest.&lt;br /&gt;
* You will not earn credit for a creative-portion feature that simply rehashes something you've already done in a previous module.&lt;br /&gt;
&lt;br /&gt;
If you need ideas for a creative portion, or if you want to know whether or not your creative portion idea is &amp;quot;hard enough&amp;quot;, ask a TA.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>James</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2245</id>
		<title>Module 2</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2245"/>
		<updated>2017-01-23T20:02:30Z</updated>

		<summary type="html">&lt;p&gt;James: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 2 introduces you to Linux, a command-line environment, the Apache web server, and PHP.  You will create and configure your own cloud instance, install Apache and related software, and then form groups to make a simple file sharing site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;'''DO NOT WAIT UNTIL THE LAST MINUTE TO START ON THIS (or any) MODULE!'''  The most common reason students perform poorly in this class is procrastination.  You have been warned.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Linux]]&lt;br /&gt;
* [[Bash]]&lt;br /&gt;
* [[Amazon Web Services]]&lt;br /&gt;
* [[SSH]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[Workflow]]&lt;br /&gt;
* [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;There are a lot of wiki pages that you need to read in order to complete the individual portion of Module 2.  The wiki pages contain an assortment of required steps, optional steps, and information.  To make things easier, we have highlighted the ''required steps'' with a red bar, like you see on the left of this message.  Do not skip anything marked with a red bar, or else you will not have a perfectly configured instance.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Learn About Linux ===&lt;br /&gt;
&lt;br /&gt;
Linux is an open-source operating system based on UNIX. Linux is highly versatile and is used in a wide range of applications.&lt;br /&gt;
&lt;br /&gt;
If you are not a Linux guru, read the Linux guide to get started: [[Linux]]&lt;br /&gt;
&lt;br /&gt;
=== Install Cygwin: Windows Users Only ===&lt;br /&gt;
&lt;br /&gt;
You will need Cygwin in order to log into and configure your EC2 instance.  Cygwin is already installed on the CEC machines.  Instructions for installing Cygwin on your personal machine are located in [[Workflow#Cygwin|the Workflow guide]].&lt;br /&gt;
&lt;br /&gt;
Mac OS X users should located the &amp;quot;Terminal&amp;quot; application, which is installed by default; you will need this in the coming steps.&lt;br /&gt;
&lt;br /&gt;
=== Create an AWS EC2 Instance ===&lt;br /&gt;
&lt;br /&gt;
Once you understand [[Linux]], you need to set up your Amazon EC2 Instance.  Use the AWS article to guide you through the process: [[Amazon Web Services]]&lt;br /&gt;
&lt;br /&gt;
=== Configure SSH ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions in [[SSH#SSH Configuration|the SSH guide]] to do the following:&lt;br /&gt;
&lt;br /&gt;
# Create your own SSH key pair&lt;br /&gt;
# Log in as the default user to your EC2 instance&lt;br /&gt;
# Create a new user&lt;br /&gt;
# Give the new user your SSH public key&lt;br /&gt;
&lt;br /&gt;
From now on, when you need to log into your EC2 instance as an administrator, just pop up a terminal and run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ ssh your-username@ec2-xx-xx-xx-xx.compute-1.amazonaws.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install Essential Packages ===&lt;br /&gt;
&lt;br /&gt;
Recall that software installation in Linux instances is usually handled through '''apt''' (Debian) or '''yum''' (RHEL).  For more information, refer to [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
To make sure everything is working properly, '''install your first package(s) according to the ''Essential Packages'' subsection in the Linux guide.'''&lt;br /&gt;
&lt;br /&gt;
=== Set the Timezone ===&lt;br /&gt;
&lt;br /&gt;
'''Set your server to use US Central time (America/Chicago).'''  Instructions are in the Linux guide: [[Linux#Synchronizing Date and Time]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up the Apache Web Server ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install the Apache web server on your EC2 instance'''.  Refer to [[Apache|the Apache guide]].&lt;br /&gt;
&lt;br /&gt;
In order for your web server to be accessible, you need to '''open up Port 80 on your EC2 instance'''.  Instructions are in the AWS guide: [[Amazon Web Services#Enabling Web Access to your EC2 Instance]]&lt;br /&gt;
&lt;br /&gt;
'''Enable the UserDir module in Apache.'''  Instructions are in the Apache guide: [[Apache#The UserDir Module]]&lt;br /&gt;
&lt;br /&gt;
=== Install PHP ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install PHP on your EC2 server'''.  Instructions are at the top of the PHP guide: [[PHP]]&lt;br /&gt;
&lt;br /&gt;
You need to '''configure PHP to show errors'''.  Instructions are immediately below installation in the PHP guide.&lt;br /&gt;
&lt;br /&gt;
=== Learn the PHP Language ===&lt;br /&gt;
&lt;br /&gt;
Before you can continue, you will need to make yourself acquainted with PHP language components.  Read the PHP guide for an overview: [[PHP#PHP Language Components]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up your Workspace ===&lt;br /&gt;
&lt;br /&gt;
You are now ready to set up the workspace that you will be using for the rest of the semester.  Follow the instructions in [[Workflow]] to:&lt;br /&gt;
&lt;br /&gt;
# Make an account on Bitbucket&lt;br /&gt;
# Make a repository for your individual work for CSE 330&lt;br /&gt;
# Install SourceTree&lt;br /&gt;
# '''Windows only:''' Set up Pageant so that SourceTree can conect to Bitbucket&lt;br /&gt;
# Clone your CSE 330 repo from Bitbucket&lt;br /&gt;
# Install Komodo Edit&lt;br /&gt;
# Create a Komodo Edit Project inside of your Git repository&lt;br /&gt;
# Add the ''*.komodoproject'' file to ''.gitignore''&lt;br /&gt;
# Install FileZilla&lt;br /&gt;
# Connect FileZilla to your remote instance&lt;br /&gt;
&lt;br /&gt;
=== Calculator ===&lt;br /&gt;
&lt;br /&gt;
'''Make a calculator using PHP and an HTML form.'''  The form should have two inputs.  The form should submit a GET request either back to the same page or to a different results page.  The calculator should support addition, subtraction, multiplication, and division by means of a radio button group on the page.  (Consider edge cases!)&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
You will work in pairs (that means you and one other person) on this project.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;In this module, and all future modules, the group portion builds off of material you learn in the individual portion.  You should therefore complete the individual portions prior to working on the group portions.  (Trust us: it will make your life easier!)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Important Reminder:''' frequently commit your work to your repository as a backup!&lt;br /&gt;
&lt;br /&gt;
=== Simple File Sharing Site ===&lt;br /&gt;
&lt;br /&gt;
You will be making a simple file sharing site that supports uploading, viewing, and deleting files associated with various users.  Details:&lt;br /&gt;
&lt;br /&gt;
* You should have a file named '''users.txt''' stored in a secure place on your filesystem.  It should have at least three usernames, with one username per line.&lt;br /&gt;
*: Passwords add an extra layer of complexity (encryption) that we will cover in Module 3.  You will not earn credit for implementing passwords as your creative portion for this module.&lt;br /&gt;
* Users of the file sharing site should be able to enter their username and then log in.&lt;br /&gt;
*: You may implement logins using session variables, or you may implement them using a GET parameter that is passed between pages.  You will need to always use sessions starting in Module 3.&lt;br /&gt;
* Users should see a list of all files associated with their username after the log in.&lt;br /&gt;
* Users should be able to view, upload, and delete files associated with their username.&lt;br /&gt;
* The URI should NOT reveal the internal file structure of your web site.&lt;br /&gt;
** Example of what not to do:  http://www.example.com/download.php?file=/home/paul/file.txt&lt;br /&gt;
** Another bad example:  http://www.example.com/~user/file.txt&lt;br /&gt;
** Good example: http://www.example.com/view.php?user=music&amp;amp;name=file.txt&lt;br /&gt;
*: In general, don't reveal any internal information about the site.&lt;br /&gt;
*: '''Food for thought:''' Given that Apache processes (with the exception of the main process) do not run as root, but rather as the user apache, how can you allow both your user account and the php scripts to read and write the &lt;br /&gt;
*:necessary files?&lt;br /&gt;
*:: ''Hint:'' You shouldn't be storing the user-uploaded files in public_html (that is only the place for your own web-page files), &lt;br /&gt;
*::''Hint number 2:''  you will need to use chown to change permissions to let user apache (or www-data for Ubuntu) have permissions on the user-files (that '''are not''' in the public_html folder). If you don't know what this does or how to do this, look at the [[Apache]] page&lt;br /&gt;
* You should customize your file sharing site by implementing an additional feature or two as part of the '''creative portion'''.&lt;br /&gt;
&lt;br /&gt;
You will probably find the PHP guide on this wiki to be helpful: [[PHP#Other PHP Tips]]&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
Your project needs to demonstrate that thought was put into web security and best practice.  For more information, see this week's Web Application Security guide: [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
In particular:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to follow the conventions of FIEO (Filter Input and Escape Output)'''.  Things you should filter include file names, usernames, and so on.&lt;br /&gt;
* '''Your project must pass the W3C Validator with no errors'''.  For more information, see the HTML and CSS guide: [[HTML and CSS#Validation]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total.&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. &lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID1-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-201343-312532) &lt;br /&gt;
#* OR, if you are working alone, put both your individual and group portions in your individual repo&lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, or share it with cse330, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
_____________&lt;br /&gt;
&lt;br /&gt;
# '''Cloud Instance and Web Server (30 Points):'''&lt;br /&gt;
#* You can SSH into your instance using your own custom username and SSH key. Put a screenshot in your repository of your terminal SSH-ing into your instance (15 points)&lt;br /&gt;
#* Your custom username is able to perform SUDO commands. Put a screenshot in your repository of you successfully executing a command with sudo (5 points)&lt;br /&gt;
#* The time zone is correct on your instance. Put a screenshot in your repository of the results of the `date` command (5 points)&lt;br /&gt;
#* The UserDir Apache module is working. Place a file in /home/&amp;lt;username&amp;gt;/public_html and link to the file in your README.md (5 points)&lt;br /&gt;
# '''PHP Calculator (15 Points):'''&lt;br /&gt;
#* The calculator is able to perform all four functions (2 points each, 8 points in total)&lt;br /&gt;
#* Each function is given as a radio button choice (4 points)&lt;br /&gt;
#* The calculator page passes the W3C HTML validator (3 points)&lt;br /&gt;
# '''File Sharing Site (40 Points):'''&lt;br /&gt;
#* '''''File Management (25 Points):'''''&lt;br /&gt;
#** Users should not be able to see any files until they enter a username and log in (4 points)&lt;br /&gt;
#**: ''Remember that users.txt should be stored in a secure location on your filesystem.  That is, '''you should not be able to type any URL into your browser and see the raw users.txt file!'''''&lt;br /&gt;
#** Users can see a list of all files they have uploaded (4 points)&lt;br /&gt;
#** Users can open files they have previously uploaded (5 points)&lt;br /&gt;
#**: ''Note: Users should be able to open not only plain text files but also other file formats: images, spreadsheets, etc.''&lt;br /&gt;
#** Users can upload files (4 points)&lt;br /&gt;
#**: ''Note: Like users.txt, uploaded files should be stored in a secure location on your filesystem.  That is, '''do not keep your uploads directory underneath a directory served by Apache!'''''&lt;br /&gt;
#** Users can delete files.  If a file is &amp;quot;deleted&amp;quot;, it should actually be removed from the filesystem (4 points)&lt;br /&gt;
#** The directory structure is hidden (2 points)&lt;br /&gt;
#** Users can log out (2 points)&lt;br /&gt;
#**: ''Note: If using session variables, you must ''actually'' log out the user by destroying their session; i.e., don't just redirect them to the login screen.''&lt;br /&gt;
#* '''''Best Practices (10 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (4 points)&lt;br /&gt;
#** The site follows the FIEO philosophy (3 points)&lt;br /&gt;
#** All pages pass the W3C validator (3 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Site is intuitive to use and navigate (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (15 Points)''' (see below)&lt;br /&gt;
#* '''''Make sure you have a README.md file in your group repo with the following:'''''&lt;br /&gt;
#** An .md file is a plain text file called a markdown file  [https://guides.github.com/features/mastering-markdown/ ] .  &lt;br /&gt;
#***The contents of your README.md file are shown on your repo, making it easier for us to grade&lt;br /&gt;
#*** You may style the page with bolding, hyperlings, images, block quotes and lists&lt;br /&gt;
#*** [http://dillinger.io/ This online markdown editor] makes it easy to learn this format  &lt;br /&gt;
#** Names and Student IDs of all the group members&lt;br /&gt;
#** A link to the front page of your site&lt;br /&gt;
#** A brief description of what you did for your creative portion&lt;br /&gt;
#** Any additional login details needed for the TA&lt;br /&gt;
&lt;br /&gt;
=== Creative Portion ===&lt;br /&gt;
&lt;br /&gt;
This module, and all future modules, will require that you invest some time into creating additional features for your group project.  Plan to invest at least 60 minutes of your time into the creative portion.&lt;br /&gt;
&lt;br /&gt;
* The creative portion is an opportunity for you to learn material of your own interest.&lt;br /&gt;
* You will not earn credit for a creative-portion feature that simply rehashes something you've already done in a previous module.&lt;br /&gt;
&lt;br /&gt;
If you need ideas for a creative portion, or if you want to know whether or not your creative portion idea is &amp;quot;hard enough&amp;quot;, ask a TA.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>James</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7.2&amp;diff=2244</id>
		<title>Module 7.2</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_7.2&amp;diff=2244"/>
		<updated>2017-01-21T02:40:56Z</updated>

		<summary type="html">&lt;p&gt;James: Created page with '== Individual Assignment == In this assignment, you will build an Angular dog-walking website. To get Angular running on your machine, follow the [https://angular.io/docs/ts/late…'&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Individual Assignment ==&lt;br /&gt;
In this assignment, you will build an Angular dog-walking website. To get Angular running on your machine, follow the [https://angular.io/docs/ts/latest/quickstart.html quickstart] tutorial. Once you are able to see the &amp;quot;Hello Angular!&amp;quot; on your screen, you are ready to begin.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Understanding Angular and TypeScript'''&lt;br /&gt;
&lt;br /&gt;
Before starting this section, create a copy the quickstart folder you just created. Use one folder to complete the tutorial and another folder to create your dog walking site.&lt;br /&gt;
&lt;br /&gt;
Complete steps 1-6 of the [https://angular.io/docs/ts/latest/tutorial/ angular tutorial]. Go slowly through the tutorial and try to understand the code. Pay close attention to the routing section as this can be quite tricky. TAs will check out your working tutorial code. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Overview of the dog walking site'''&lt;br /&gt;
&lt;br /&gt;
The dog walking site will have two main views: dogs and walkers. Each page should show a picture as well as basic information about each dog/walker. Clicking on an image should show more information about the selected dog/walker. &lt;br /&gt;
&lt;br /&gt;
Under more information, there should be buttons that link to personalized pages for the specified dog/walker. This will be done by using a parameterized route.&lt;br /&gt;
&lt;br /&gt;
Here is a general layout of the website:&lt;br /&gt;
&lt;br /&gt;
[[File:siteflow-2.png|center|thumb|upright=2]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Building the site'''&lt;br /&gt;
&lt;br /&gt;
1. You should start with the [https://angular.io/docs/ts/latest/guide/setup.html quickstart] base that you created. Your folder structure should look like [http://classes.engineering.wustl.edu/cse330/images/1/18/FolderStructure.png this].&lt;br /&gt;
&lt;br /&gt;
2. Create two files: mock-dogs.ts and mock-walkers.ts. These files are very similar to [https://angular.io/docs/ts/latest/tutorial/toh-pt4.html mock-heroes.ts] from the tutorial. &lt;br /&gt;
&lt;br /&gt;
In mock-dogs.ts, put the following code:&lt;br /&gt;
&lt;br /&gt;
     import { Dog } from './dog';&lt;br /&gt;
     import { Walker } from './walker';&lt;br /&gt;
     &lt;br /&gt;
     let rexi = new Walker(1, 'Rexi', 20, [], 'http://cdnak1.psbin.com/img/mw=300/cr=n/d=tqw7n/vmdxhv95r1qhos2t.jpg');&lt;br /&gt;
     let caroline =  new Walker(2, 'Caroline', 21, [], 'http://cdnak1.psbin.com/img/mw=300/cr=n/d=d75wq/jhm8rmg2i2ckxj7g.jpg');&lt;br /&gt;
     let joe =  new Walker(3, 'Joe', 25, [],'https://images-na.ssl-images-amazon.com/images/M/MV5BOTI3ODk1MTMyNV5BMl5BanBnXkFtZTcwNDEyNTE2Mg@@._V1_UY317_CR6,0,214,317_AL_.jpg');&lt;br /&gt;
     let jake =  new Walker(4, 'Jake', 19, [], 'http://a4.files.biography.com/image/upload/c_fit,cs_srgb,dpr_1.0,h_1200,q_80,w_1200/MTE4MDAzNDEwNzk1MjAyMDYy.jpg');&lt;br /&gt;
      &lt;br /&gt;
     export const DOGS: Dog[] = [&lt;br /&gt;
       { id: 1, name: 'Sheila', age: 7, walkers: [rexi, caroline], personality:'Fun-loving, very active', picture:'https://www.what-dog.net/Images/faces2/scroll0015.jpg'},&lt;br /&gt;
       { id: 2, name: 'Doge', age: 10, walkers: [joe, rexi, jake], personality:'Slow moving, tired', picture:'https://pbs.twimg.com/profile_images/378800000822867536/3f5a00acf72df93528b6bb7cd0a4fd0c.jpeg'},&lt;br /&gt;
       { id: 3, name: 'Lola', age: 2, walkers: [jake], personality:'Hyper active puppy', picture:'https://d2csxpduxe849s.cloudfront.net/media/27FB7F0C-9885-42A6-9E0C19C35242B5AC/62E3C530-E8C8-445A-B6EA56249F2436C8/51B393D6-AC74-46BC-B669648017EF48AF/b9824b6d-ea23-5b20-8412-45061f7ebc8b/thul-IMG_1809.jpg'},&lt;br /&gt;
       { id: 4, name: 'Gizmo', age: 4, walkers: [joe], personality:'Likes to bark at squirrels', picture:'https://pbs.twimg.com/profile_images/473535319090819074/6j-F-_N-_400x400.jpeg'},&lt;br /&gt;
     ];&lt;br /&gt;
&lt;br /&gt;
In mock-walkers.ts put the following code:&lt;br /&gt;
&lt;br /&gt;
import { Walker } from './walker';&lt;br /&gt;
import { Dog } from './dog';&lt;br /&gt;
&lt;br /&gt;
      let sheila = new Dog(1, 'Sheila', 7, [], 'Fun-loving, very active', 'https://www.what-dog.net/Images/faces2/scroll0015.jpg');&lt;br /&gt;
       let doge = new Dog( 2, 'Doge', 10, [], 'Slow moving, tired', 'http://www.dogchannel.com/images/articles/breed_profile_images/canaan-dog.jpg');&lt;br /&gt;
       let lola = new Dog(3,'Lola',2, [], 'Hyper active puppy','https://d2csxpduxe849s.cloudfront.net/media/27FB7F0C-9885-42A6-9E0C19C35242B5AC/62E3C530-E8C8-445A-B6EA56249F2436C8/51B393D6-AC74-46BC-B669648017EF48AF/b9824b6d-ea23-5b20-8412-45061f7ebc8b/thul-IMG_1809.jpg');&lt;br /&gt;
       let gizmo = new Dog(4, 'Gizmo', 4, [], 'Likes to bark at squirrels', 'https://pbs.twimg.com/profile_images/473535319090819074/6j-F-_N-_400x400.jpeg');&lt;br /&gt;
      &lt;br /&gt;
      export const WALKERS: Walker[] = [&lt;br /&gt;
        { id: 1, name: 'Rexi', age: 20, dogsWalked:[gizmo], picture:'http://cdnak1.psbin.com/img/mw=300/cr=n/d=tqw7n/vmdxhv95r1qhos2t.jpg'},&lt;br /&gt;
        { id: 2, name: 'Caroline', age: 21, dogsWalked:[sheila, lola], picture:'http://cdnak1.psbin.com/img/mw=300/cr=n/d=d75wq/jhm8rmg2i2ckxj7g.jpg'},&lt;br /&gt;
        { id: 3, name: 'Joe', age: 25, dogsWalked:[gizmo, lola, doge], picture:'https://images-na.ssl-images-amazon.com/images/M/MV5BOTI3ODk1MTMyNV5BMl5BanBnXkFtZTcwNDEyNTE2Mg@@._V1_UY317_CR6,0,214,317_AL_.jpg'},&lt;br /&gt;
        { id: 4, name: 'Jake', age: 19, dogsWalked:[gizmo, sheila], picture:'http://a4.files.biography.com/image/upload/c_fit,cs_srgb,dpr_1.0,h_1200,q_80,w_1200/MTE4MDAzNDEwNzk1MjAyMDYy.jpg'},&lt;br /&gt;
      ];&lt;br /&gt;
&lt;br /&gt;
You will need to create a dog class and a walker class based upon the mock data above. Call these dog.ts and walker.ts (the format should be similar to [https://angular.io/docs/ts/latest/tutorial/toh-pt3.html hero.ts] from the tutorial). In these files, create constructors for the appropriate object. This should look something like:&lt;br /&gt;
&lt;br /&gt;
      export class Example{&lt;br /&gt;
           id: number;&lt;br /&gt;
           name: string;&lt;br /&gt;
      &lt;br /&gt;
           constructor ( id: number, name: string){&lt;br /&gt;
               this.id = id;&lt;br /&gt;
               this.name = name;&lt;br /&gt;
           }&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
You will also need to create two service files (one for dog and one for walker) to be able to access the mock data. Call these dog.service.ts and walker.service.ts. Reference the tutorial (especially [https://angular.io/docs/ts/latest/tutorial/toh-pt4.html hero.service.ts]) if you need help.&lt;br /&gt;
&lt;br /&gt;
3. Create dog.component.ts. This component should iterate through all the dogs of mock-dogs and display their picture and general information. Refer to [https://angular.io/docs/ts/latest/tutorial/toh-pt2.html hero.component.ts] from the tutorial for help. When you have completed this section, your website should look like:&lt;br /&gt;
&lt;br /&gt;
[[File:DogHomePage-2.png|center|thumb|upright=2]]&lt;br /&gt;
&lt;br /&gt;
4. Create dog-detail.component.ts. This component should show more information about the dog if its picture is clicked. Refer to [https://angular.io/docs/ts/latest/tutorial/toh-pt3.html hero-detail.component.ts] from the tutorial for help. This is what your site should look like:&lt;br /&gt;
&lt;br /&gt;
[[File:DogDetailPage.png|center|thumb|upright=2]]&lt;br /&gt;
&lt;br /&gt;
5. Create a nav bar at the top of the page and link the other tab to a walker.component.ts. This page should operate the same as dog.component.ts but iterate through mock-walkers. Use the [https://angular.io/docs/ts/latest/tutorial/toh-pt5.html routing] section of the tutorial for help. The nav bar should look something like:&lt;br /&gt;
&lt;br /&gt;
[[File:NavBar.png|center|thumb|upright=2]]&lt;br /&gt;
&lt;br /&gt;
6. Create walker-page.component.ts. This will be a separate &amp;quot;facebook page&amp;quot; that will be routed by a parameterized route. The parameterized routes in [https://angular.io/docs/ts/latest/tutorial/toh-pt5.html routing] from the tutorial will be extremely helpful. This page should look like:&lt;br /&gt;
&lt;br /&gt;
[[File:DeepLinkWalkerPage.png|center|thumb|upright=2]]&lt;br /&gt;
&lt;br /&gt;
*Make sure to take note of the url - the number at the end corresponds to the id of the selected walker.&lt;br /&gt;
&lt;br /&gt;
The best way to make this route work is to pass a walker object to the parameterized route page. Some helpful code that should go into DogDetailComponent: &lt;br /&gt;
&lt;br /&gt;
       getWalkers(): void {&lt;br /&gt;
         this.walkerService.getWalkers().then(walkers =&amp;gt; this.walkers = walkers);&lt;br /&gt;
       }&lt;br /&gt;
      &lt;br /&gt;
       ngOnInit():void{&lt;br /&gt;
         this.getWalkers();&lt;br /&gt;
       }&lt;br /&gt;
      &lt;br /&gt;
       onSelect(walker: Walker):void {&lt;br /&gt;
         this.selectedWalker = walker;&lt;br /&gt;
         this.gotoDetail();&lt;br /&gt;
       }&lt;br /&gt;
      &lt;br /&gt;
       gotoDetail(): void{&lt;br /&gt;
         this.router.navigate(['/walker', this.selectedWalker.id]);&lt;br /&gt;
       }&lt;br /&gt;
&lt;br /&gt;
This code will help you get the proper walker based on the button selected and help you pass the object to the parameterized route page.&lt;br /&gt;
&lt;br /&gt;
To parse the walker object on the parameterized route page, you can use the following code. This should go in WalkerPageComponent in walker-page.component.ts:&lt;br /&gt;
&lt;br /&gt;
      ngOnInit(): void {&lt;br /&gt;
          this.route.params.forEach((params: Params) =&amp;gt; {&lt;br /&gt;
              let id = +params['id'];&lt;br /&gt;
              this.walkerService.getWalker(id)&lt;br /&gt;
              .then(walker =&amp;gt; this.walker = walker);&lt;br /&gt;
          });&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
7. Once you have all the routes working, feel free to add different pictures, different attributes for the classes, nice CSS and bootstrap, etc. Your final folder structure should look like [http://classes.engineering.wustl.edu/cse330/images/6/67/FinalFolderStructure.png this].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Debugging'''&lt;br /&gt;
&lt;br /&gt;
Debugging in Angular can be quite tricky. Here are some helpful hints:&lt;br /&gt;
&lt;br /&gt;
1. Check your terminal for 404 error messages. A 404 message usually means that you misspelled a file name in your imports or that file doesn't exist.&lt;br /&gt;
&lt;br /&gt;
[[File:terminalerrors.png|center|thumb|upright=2]]&lt;br /&gt;
&lt;br /&gt;
In this image above, we see a 404 error message in app.components.ts. Let's take a look at what is in app.module.ts:&lt;br /&gt;
&lt;br /&gt;
[[File:modulets.png|center|thumb|upright=2]]&lt;br /&gt;
&lt;br /&gt;
Looking over the file, we can see that the file app.component.ts is misspelled with an extra 's'. This is where we get the 404 error from. The compiler can't find app.components.ts because it does not exist. &lt;br /&gt;
&lt;br /&gt;
2. If you aren't getting a 404 error message in the console, use inspect element on Google Chrome. Usually an error will be thrown and you can identify it through the inspector. Let's take a look at the example below:&lt;br /&gt;
&lt;br /&gt;
[[File:inspectorerrors.png|center|thumb|upright=2]]&lt;br /&gt;
&lt;br /&gt;
We immediately see that my walker page is not being rendered correctly (none of the walkers appear). So, right click the web page in Google Chrome and click &amp;quot;Inspect&amp;quot;. The inspect toolbar should appear. Looking at the console, we can see that WalkerComponent doesn't have a DogService provider. We can easily fix this by doing the following:&lt;br /&gt;
&lt;br /&gt;
[[File:errorfix.png|center|thumb|upright=2]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 60 points total.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. Assignments must be demoed within 4 days of the due date (Friday at 11:30 AM for Module 7). You are allowed to demo your assignment at TA office hours. However, after Friday at 11:30 AM, you will receive a 0 for the assignment, regardless of your time-stamp.''' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-FirstName-LastName-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-John-Doe-201343)&lt;br /&gt;
&lt;br /&gt;
___________&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#	'''Completed Angular Tutorial steps 0-6 (5 points)'''&lt;br /&gt;
#	 '''Completed dog-walking website (55 points)'''&lt;br /&gt;
#*	Quickstart (5 points)&lt;br /&gt;
#**	Folder structure is correct (3 points)&lt;br /&gt;
#**	Set up Angular correctly (2 points)&lt;br /&gt;
#*	Main Components (12 points)&lt;br /&gt;
#**	Set up of mock-dogs.ts, dogs.ts, and dog.service.ts is correct (5 points)&lt;br /&gt;
#**	Iterates through all dog objects and displays correct information (5 points)&lt;br /&gt;
#**  The same is done for walker component (2 points)&lt;br /&gt;
#*	Detail Components (10 points):&lt;br /&gt;
#**	User is able to select a dog image and see more information about the selected dog (5 points)&lt;br /&gt;
#**	When the image is selected, the web page does not refresh or go to a different url (3 points)&lt;br /&gt;
#**	The same is done for walker detail component (2 points) &lt;br /&gt;
#*	Navigation Bar (8 points)&lt;br /&gt;
#**	A navigation bar is at the top of dog component page and walker component page (3 points)&lt;br /&gt;
#**  User can switch between the two components easily and appropriate data is rendered upon switch (5 points)&lt;br /&gt;
#*    Parameterized Route Page (15 points):&lt;br /&gt;
#**  User is taken to a separate page with a parameterized route when a walker button is clicked on dog component page (5 points)&lt;br /&gt;
#**  Info about the appropriate walker appears automatically (5 points)&lt;br /&gt;
#**  There is a back button to take user back to previous page (3 points)&lt;br /&gt;
#**  The same is done for dog buttons on walker component page (2 points)&lt;br /&gt;
#*	BootStrapping (5 points)&lt;br /&gt;
#**	Site looks good, intuitive, and professional (5 points)&lt;/div&gt;</summary>
		<author><name>James</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_1&amp;diff=2237</id>
		<title>Module 1</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_1&amp;diff=2237"/>
		<updated>2017-01-19T02:18:41Z</updated>

		<summary type="html">&lt;p&gt;James: /* Reading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 1 introduces the fundamentals of HTML and CSS.  You will first make a static document using HTML and CSS, and then you will make a portal to a DuckDuckGo search.  This module is worth 50 points.&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignment.&lt;br /&gt;
&lt;br /&gt;
* [[Git]]&lt;br /&gt;
* [[HTML and CSS]]&lt;br /&gt;
* [[HTML Forms]]&lt;br /&gt;
&lt;br /&gt;
== Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Write a Birthday Card ===&lt;br /&gt;
&lt;br /&gt;
'''Write a birthday card to a friend or family member using HTML and CSS.'''  Use HTML to define the content of the card (like the headings and the paragraphs), and use CSS to define the appearance.  Some ideas:&lt;br /&gt;
&lt;br /&gt;
* Make the background-color of the page baby blue and use purple ink to write a card to a little boy&lt;br /&gt;
* Make the text big and include pictures of hearts&lt;br /&gt;
* Use a font with text shadows (more advanced)&lt;br /&gt;
&lt;br /&gt;
Use this opportunity to experiment with the plethora of CSS properties.  Remember that you're in a computer science class (not an art class), so we don't care if your card looks ugly.  The main thing is that you learn HTML and CSS and use them appropriately.&lt;br /&gt;
&lt;br /&gt;
==== How to Edit Your File ====&lt;br /&gt;
&lt;br /&gt;
Starting in Module 2, we will be using Komodo Edit as our primary development tool.  However, for the purposes of this exercise, we want you to edit your HTML file using a more basic text editor.&lt;br /&gt;
&lt;br /&gt;
* On Windows, consider Notepad++.  This is already installed for you in the CEC labs.  If you prefer to use your personal computer, you can download it from [http://notepad-plus-plus.org/ here].&lt;br /&gt;
* On Mac OS X, consider TextWrangler.  You can download it from [http://www.barebones.com/products/textwrangler/ here] or from the Apple App Store.&lt;br /&gt;
* Most Linux distributions come with gedit pre-installed, which you can use for this lab.&lt;br /&gt;
&lt;br /&gt;
Please save your file as ''birthday.html'' from the plain text editor of your choice.&lt;br /&gt;
&lt;br /&gt;
'''Important Note:''' Writing your web page in a word processor like Microsoft Word or even WordPad or TextEdit will ''not'' work.  What you need is a plain text editor.&lt;br /&gt;
&lt;br /&gt;
==== How to View Your HTML Document ====&lt;br /&gt;
&lt;br /&gt;
Once you have ''birthday.html'', you can open it using your favorite web browser (like Firefox).  For the purposes of this exercise, it suffices to right-click the file and tell it to &amp;quot;open with&amp;quot; Firefox.  When the file opens, it should be under the file:/// protocol.&lt;br /&gt;
&lt;br /&gt;
In Module 2, we will install a web server that serves up pages on the http:// protocol.&lt;br /&gt;
&lt;br /&gt;
==== Validation ====&lt;br /&gt;
&lt;br /&gt;
'''Your birthday card must pass the W3C Validator with no errors.'''  From [http://validator.w3.org/ the validator], you can choose to upload your file.&lt;br /&gt;
&lt;br /&gt;
For more information on validation, see the HTML and CSS guide: [[HTML and CSS#Validation]]&lt;br /&gt;
&lt;br /&gt;
=== Make a Portal to a DuckDuckGo Search ===&lt;br /&gt;
&lt;br /&gt;
'''Write an HTML document containing a form that searches DuckDuckGo's web site.'''  You should be able to type in a search term and have your form load the DuckDuckGo search page.&lt;br /&gt;
&lt;br /&gt;
# Visit [https://www.duckduckgo.com/ www.duckduckgo.com].  Search for something easy to spot in the URL, like &amp;quot;QUERY&amp;quot;.&lt;br /&gt;
# Look at the URL of the search page.  What is the script URL?  What is the query variable?&lt;br /&gt;
# Make an HTML document containing a text field and a submit button.  Typing a search query into the text field and pressing the submit button should load the DuckDuckGo search page.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 50 points total.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# '''Birthday Card (30 Points):'''&lt;br /&gt;
#* Correct usage of HTML and CSS in your birthday card (10 points).&lt;br /&gt;
#*: ''Make sure that you use HTML for &amp;quot;content&amp;quot; and CSS for &amp;quot;appearance.&amp;quot;  Don't write inline styles: use a separate stylesheet and link your HTML file to it.''&lt;br /&gt;
#* Experimenting with at least 5 different CSS properties in your birthday card (10 points).&lt;br /&gt;
#* Birthday card passes the W3C validation for the declared DOCTYPE (e.g., HTML 5) (10 points).&lt;br /&gt;
# '''Search Portal (10 Points):'''&lt;br /&gt;
#* DuckDuckGo search portal is functional (10 points).&lt;br /&gt;
# '''Account Creation and Version Control (10 Points):'''&lt;br /&gt;
#* Account Created on Amazon Web Services (5 Points)&lt;br /&gt;
#* Bitbucket account created (2 Points)&lt;br /&gt;
#* Files pushed to properly named private repo (ex. Spring2017-Module1-StudentID) on Bitbucket using Git (2 Points)&lt;br /&gt;
#* Bitbucket repo shared with cse330 user (1 Point)&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 1]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>James</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Git&amp;diff=2236</id>
		<title>Git</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Git&amp;diff=2236"/>
		<updated>2017-01-18T20:06:33Z</updated>

		<summary type="html">&lt;p&gt;James: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Git''' is a ''distributed version control system''.  It enables you to:&lt;br /&gt;
&lt;br /&gt;
# Keep track of revisions to your files&lt;br /&gt;
# Push and pull your revisions to other computers or servers&lt;br /&gt;
# Collaborate with other people on the same project&lt;br /&gt;
&lt;br /&gt;
Subversion is the version control system you used in CSE 132.  However, Subversion does not have the same agility of Git in terms of local revisions, staging, and collaboration.  This guide aims to get you up to speed with the power of Git for multi-developer projects.&lt;br /&gt;
&lt;br /&gt;
== Git TL;DR ==&lt;br /&gt;
&lt;br /&gt;
Before the first commit: &lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Navigate to project&lt;br /&gt;
$ cd /path/to/your/directory/&lt;br /&gt;
# Initialize folder as git repository&lt;br /&gt;
$ git init&lt;br /&gt;
# Set target URL&lt;br /&gt;
$ git remote add origin &amp;lt;repository URL&amp;gt;&lt;br /&gt;
# If this is your first time using git on your machine, you need to set your username and email&lt;br /&gt;
$ git config --global user.name &amp;quot;Your Name&amp;quot;&lt;br /&gt;
$ git config --global user.email &amp;quot;you@example.com&amp;quot;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For each subsequent commit:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Add untracked files ( use `git add .` to add all files)&lt;br /&gt;
$ git add &amp;lt;filename&amp;gt;&lt;br /&gt;
# Commit changes&lt;br /&gt;
$ git commit -m &amp;quot;Your commit message&amp;quot;&lt;br /&gt;
# Push changes to bitbucket. Unless you are working on a different branch, &amp;lt;branchname&amp;gt; should be `master`.&lt;br /&gt;
$ git push -u origin &amp;lt;branchname&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Initializing Git ==&lt;br /&gt;
&lt;br /&gt;
To initialize a Git repository inside of a folder, you can use Git's '''init''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git init&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This will create a .git directory, where Git will store information about the repository. This command can be run either in an empty folder, or in a folder where files already exist.&lt;br /&gt;
&lt;br /&gt;
== Local and Remote Branches ==&lt;br /&gt;
&lt;br /&gt;
When you create a branch named &amp;quot;mybranch&amp;quot; on your local repository and ''push'' changes up to the remote repository, they actually get pushed to a remote branch called '''origin/mybranch'''.  (Note that '''origin''' is the default name for a remote Git repository.)  Even after your collaborators ''pull'' changes from remote to their local repositories, no new branches are created on their own personal local repositories.&lt;br /&gt;
&lt;br /&gt;
Let's say that you and your partner are both working directly in the '''master''' branch (not a great idea for large or professional projects).  When you ''push'' your changes up, they get saved in '''origin/master'''.  When your partner goes and pulls changes from remote, if '''master''' is still her working copy, your changes will be immediately merged into her local '''master''' branch.&lt;br /&gt;
&lt;br /&gt;
In practice, each collaborator will have their own branch, and when they make new versions of the features they are developing, they will merge those changes into '''master'''.  (When '''master''' changes, each collaborator will merge the changes from '''master''' back into their personal branch.)  What follows is an example that should help illustrate this process.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Adding a Remote ==&lt;br /&gt;
A project that is being tracked with Git needs to be connected to a remote before files are pushed to version control. To add a remote to an initialized Git project, use the '''git remote add''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;git remote add origin \&amp;lt;repository URL\&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The origin remote is the default server that Git will push to. &lt;br /&gt;
&lt;br /&gt;
== Staging ==&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-Staging.jpg|400px|thumb|right|Staging a file in SourceTree]]&lt;br /&gt;
&lt;br /&gt;
Up to this point, you have been using SourceTree to automatically commit all changes.  However, Git enables you to not commit every single file if you don't want to.  This is where '''staging''' comes into play.&lt;br /&gt;
&lt;br /&gt;
To add a file to the stage, use the '''add''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git add &amp;lt;filename&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then, when you run ''git commit'', only those files that have been staged will be updated.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' &amp;lt;code&amp;gt;git commit -a&amp;lt;/code&amp;gt; commits all files, whether or not they had been staged.  &amp;lt;code&amp;gt;git commit&amp;lt;/code&amp;gt; (without the ''-a'') only commits those files in the staging area. It is a good idea to run '''git status''' before staging files to avoid staging files that should not be committed.&lt;br /&gt;
&lt;br /&gt;
=== Ignoring Files in Git  ===&lt;br /&gt;
Some files should not be committed to version control. Sensitive information such as SSH keys and files containing passwords should be ignored. Dependency folders such as node_modules should also be ignored; dependencies contain an enormous number of files that could change and will cause commit conflicts. . Rather, use the appropriate dependency manager to install those packages after cloning a repository (e.g. '''npm install'''). Folders containing virtual environments for frameworks such as Flask should also be ignored, and should instead be generated at will. &lt;br /&gt;
&lt;br /&gt;
To add files to be ignored, edit your .gitignore file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ vim .gitignore&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In this file, add the file or folder to be ignored. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
node_modules&lt;br /&gt;
venv&lt;br /&gt;
db_connect.php&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Staging in SourceTree ===&lt;br /&gt;
&lt;br /&gt;
Staging in SourceTree is very intuitive.  However, before you can use this feature, you need to turn it on.  (We had you turn of the staging feature in Module 2.)&lt;br /&gt;
&lt;br /&gt;
# Go to the SourceTree preferences.&lt;br /&gt;
# Enter the Git pane.&lt;br /&gt;
# Check the box that says &amp;quot;Use the staging area&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
You should now be able to use the staging area!  In the &amp;quot;File Status View&amp;quot;, you can drag and drop files back and forth between Staged and Unstaged.  See the screenshot for an example.&lt;br /&gt;
&lt;br /&gt;
== Commits ==&lt;br /&gt;
&lt;br /&gt;
When you want to create a &amp;quot;snapshot&amp;quot; of your project, what you do in Git is called a ''commit''.  The commit finds all files under version control, looks for ones that have been changed, and records the changes in a local archive.  You learned how to perform a commit in SourceTree [[Workflow|in Module 2]].&lt;br /&gt;
&lt;br /&gt;
If you need to determine what files have been changed since the last commit, you can use Git's '''status''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git status&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In SourceTree, the results of ''git status'' are displayed nicely in the &amp;quot;File Status View&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Branches and Merging ==&lt;br /&gt;
&lt;br /&gt;
Git enables you to work on different features of the same software suite in isolation from each other.  The way to do this is using '''branches'''.&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-Checkout.jpg|400px|thumb|right|Checking out an existing branch in SourceTree]]&lt;br /&gt;
&lt;br /&gt;
To create a new branch, use the '''checkout -b''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git checkout -b my-new-branch&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now, when you next commit, you will be committing to the '''my-new-branch''' branch rather than the default '''master''' branch.&lt;br /&gt;
&lt;br /&gt;
To switch the working copy over to a different branch, use the '''checkout''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git checkout my-existing-branch&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
See the screenshot for how to checkout a branch in SourceTree.&lt;br /&gt;
&lt;br /&gt;
To merge changes from a different branch to the current working copy, use the '''merge''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git merge my-existing-branch&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After you merge, if you wish to terminate a branch, use the '''branch -d''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git branch -d my-existing-branch&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Git also has another command called '''rebase''', which is similar to '''merge''' except that it combines the commits of each branch into a single branch, but still keeping the head of each branch.  For more information on ''rebase'', read [http://blog.sourcetreeapp.com/2012/08/21/merge-or-rebase/ this article on the SourceTree blog].&lt;br /&gt;
&lt;br /&gt;
This will all make more sense when we go through an example.  We will also be using SourceTree in the example.&lt;br /&gt;
&lt;br /&gt;
== Example: Staging and Branches ==&lt;br /&gt;
&lt;br /&gt;
Suppose I have three files under version control: apple.txt, banana.txt, and carrot.txt.  The contents is like so (Thanks to [http://www.sumitkhemka.com/ Sumit Khemka] for the humor):&lt;br /&gt;
&lt;br /&gt;
* '''apple.txt:''' How do you make an apple turnover?  Push it downhill!&lt;br /&gt;
* '''banana.txt:''' What is a ghost's favorite fruit?  A boonanaa!&lt;br /&gt;
* '''carrot.txt:''' How do you make a soup rich?  Add 14 carats to it!&lt;br /&gt;
&lt;br /&gt;
All files have been committed to the HEAD, which is by default the '''master''' branch:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git add -A; git commit&lt;br /&gt;
...&lt;br /&gt;
$ git status&lt;br /&gt;
# On branch master&lt;br /&gt;
nothing to commit, working directory clean&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Staging ===&lt;br /&gt;
&lt;br /&gt;
Now, let's change the Apple joke, and keep the Banana and the Carrot the same:&lt;br /&gt;
&lt;br /&gt;
* '''apple.txt:''' What kind of apple has a short temper?  A crab apple!&lt;br /&gt;
&lt;br /&gt;
We can see in Git and SourceTree that there is one file changed: apple.txt.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git status&lt;br /&gt;
# On branch master&lt;br /&gt;
# Changes not staged for commit:&lt;br /&gt;
#   (use &amp;quot;git add &amp;lt;file&amp;gt;...&amp;quot; to update what will be committed)&lt;br /&gt;
#   (use &amp;quot;git checkout -- &amp;lt;file&amp;gt;...&amp;quot; to discard changes in working directory)&lt;br /&gt;
#&lt;br /&gt;
#	modified:   apple.txt&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-Branching.jpg|400px|thumb|right|Creating a new branch using SourceTree]]&lt;br /&gt;
&lt;br /&gt;
Let's go ahead and stage our file:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git add apple.txt&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In SourceTree, drag a file from the &amp;quot;working tree&amp;quot; pane to the &amp;quot;files staged in index&amp;quot; pane to stage the file.&lt;br /&gt;
&lt;br /&gt;
=== Branching ===&lt;br /&gt;
&lt;br /&gt;
But now, instead of committing this change directly to our '''master''' branch, let's make a new branch, and let's call it '''apple-branch'''.&lt;br /&gt;
&lt;br /&gt;
In SourceTree, press the &amp;quot;Branch&amp;quot; button to bring up a little dialog box.  See the screenshot for an example.&lt;br /&gt;
&lt;br /&gt;
If we were using the command line, the command would be:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;$ git checkout -b apple-branch&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is what we now see when we run '''git status''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git status&lt;br /&gt;
# On branch apple-branch&lt;br /&gt;
# Changes to be committed:&lt;br /&gt;
#   (use &amp;quot;git reset HEAD &amp;lt;file&amp;gt;...&amp;quot; to unstage)&lt;br /&gt;
#&lt;br /&gt;
#	modified:   apple.txt&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let's now go ahead and commit the changes:&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-ExampleAppleBranch.jpg|400px|thumb|right|Our current tree structure in SourceTree]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git commit -m &amp;quot;First Apple Commit&amp;quot;&lt;br /&gt;
[apple-branch c2c1738] First Apple Commit&lt;br /&gt;
 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In SourceTree, run the commit as you have been doing in Modules 2-4.&lt;br /&gt;
&lt;br /&gt;
Let's now make a second branch.  This branch is going to be rooted at the current version of the '''master''' branch, which of course is still the three original jokes.  To switch back to the '''master''' branch, we use the '''checkout''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git checkout master&lt;br /&gt;
Switched to branch 'master'&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In SourceTree, press the &amp;quot;Checkout&amp;quot; button, and choose the revision or branch that you want to checkout; see the screenshot for an example.&lt;br /&gt;
&lt;br /&gt;
We will now make a revision to the Banana joke:&lt;br /&gt;
&lt;br /&gt;
* '''banana.txt:''' What would you call two bananas? A pair of slippers!&lt;br /&gt;
&lt;br /&gt;
Let's change the file, stage it, and see the current status.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git add -A&lt;br /&gt;
$ git status&lt;br /&gt;
# On branch master&lt;br /&gt;
# Changes to be committed:&lt;br /&gt;
#   (use &amp;quot;git reset HEAD &amp;lt;file&amp;gt;...&amp;quot; to unstage)&lt;br /&gt;
#&lt;br /&gt;
#	modified:   banana.txt&lt;br /&gt;
#&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We will now create another new branch, and commit our changes to it.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git checkout -b banana-branch&lt;br /&gt;
$ git commit -m &amp;quot;First Banana Commit&amp;quot;&lt;br /&gt;
[banana-branch f876aac] First Banana Commit&lt;br /&gt;
 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We can see all branches using '''git branch -v''':&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git branch -v&lt;br /&gt;
  apple-branch  c2c1738 First Apple Commit&lt;br /&gt;
* banana-branch f876aac First Banana Commit&lt;br /&gt;
  master        b770092 Initial Commit&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
However, this is where a GUI like SourceTree really comes in handy.  Here is what you now see in the Log View:&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-ViewBranches.jpg]]&lt;br /&gt;
&lt;br /&gt;
Nifty!&lt;br /&gt;
&lt;br /&gt;
=== Merging ===&lt;br /&gt;
&lt;br /&gt;
Okay, so now we want to take the two newest Apple and Banana jokes and merge them both back into '''master'''.  Let's first merge in '''banana-branch'''.  We can do this using the '''merge''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git checkout master&lt;br /&gt;
Switched to branch 'master'&lt;br /&gt;
$ git merge banana-branch&lt;br /&gt;
Updating b770092..f876aac&lt;br /&gt;
Fast-forward&lt;br /&gt;
 banana.txt | 2 +-&lt;br /&gt;
 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''''WHEN YOU MERGE, YOU TAKE THE CHANGES FROM THE SPECIFIED BRANCH AND MERGE THEM INTO THE CURRENT WORKING BRANCH.'''''  It is easy to get this mixed up.  Think of it this way: the currently &amp;quot;open&amp;quot; branch is the only one that will get changed when you perform the merge.&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-Merge.jpg|400px|thumb|right|Merging '''apple-branch''' into '''master''']]&lt;br /&gt;
&lt;br /&gt;
We now have the original Apple joke and the new Banana joke in the '''master''' branch.&lt;br /&gt;
&lt;br /&gt;
Now let's merge in '''apple-branch'''.  We can use the command line to do it, but let's see how it works in SourceTree.  First press the &amp;quot;Merge&amp;quot; button in the toolbar.  You will see a window like the one shown in the screenshot to the right.  If everything looks good, press &amp;quot;OK&amp;quot; to perform the merge.&lt;br /&gt;
&lt;br /&gt;
We now have both of the new jokes in our '''master''' branch:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ cat apple.txt &lt;br /&gt;
What kind of apple has a short temper?  A crab apple!&lt;br /&gt;
$ cat banana.txt &lt;br /&gt;
What would you call two bananas? A pair of slippers!&lt;br /&gt;
$ cat carrot.txt &lt;br /&gt;
How do you make a soup rich? Add 14 carats to it!&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Okay, so we are now happy with our Apple joke.  Let's ''close'' that branch so that it doesn't show up in the list any more:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git branch -d apple-branch&lt;br /&gt;
Deleted branch apple-branch (was c2c1738).&lt;br /&gt;
$ git branch -v&lt;br /&gt;
  banana-branch f876aac First Banana Commit&lt;br /&gt;
* master        5159c4e Merge branch 'apple-branch'&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Let's switch back to our banana branch, make a new joke, and commit that change to the banana branch:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git checkout banana-branch&lt;br /&gt;
Switched to branch 'banana-branch'&lt;br /&gt;
$ echo 'What is the easiest way to make a banana split? Cut it in half!' &amp;gt; banana.txt&lt;br /&gt;
$ git commit -am 'Further revising our Banana joke'&lt;br /&gt;
[banana-branch cf6a894] Further revising our Banana joke&lt;br /&gt;
 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Remember that '''git commit -a''' is shorthand for '''git add -A''' followed by a plain '''git commit''' in most cases.&lt;br /&gt;
&lt;br /&gt;
But guess what: we changed our mind again!  Let's try an ''even better'' banana joke.  This time, I made the change using GUI tools:&lt;br /&gt;
&lt;br /&gt;
# Open '''banana.txt''' in your favorite text editor and make the joke say, &amp;quot;Why are bananas never lonely? Because they hang around in bunches!&amp;quot;&lt;br /&gt;
# In SourceTree, press &amp;quot;Commit&amp;quot; in the toolbar&lt;br /&gt;
# Drag the file to the &amp;quot;Stage&amp;quot; pane, type a commit message like &amp;quot;The best banana joke ever!&amp;quot;, and press &amp;quot;Commit&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Finally, let's merge our greatest Banana joke into '''master''' and close up '''banana-branch'''.  Here is how to do it in SourceTree:&lt;br /&gt;
&lt;br /&gt;
# Checkout '''master'''&lt;br /&gt;
# Press &amp;quot;Merge&amp;quot; in the toolbar&lt;br /&gt;
# Select '''banana-branch''' and press &amp;quot;Merge&amp;quot;&lt;br /&gt;
# To delete the branch, press &amp;quot;Branch&amp;quot; and then &amp;quot;Delete Branch&amp;quot; in the toolbar&lt;br /&gt;
# Select '''banana-branch''' only, press &amp;quot;Delete Branches&amp;quot;, and when asked to confirm, press &amp;quot;OK&amp;quot;&lt;br /&gt;
&lt;br /&gt;
We now have the three newest jokes in our '''master''' branch, and all other branches have been cleaned up.&lt;br /&gt;
&lt;br /&gt;
After performing all of the steps in this example, here is how the tree looks in SourceTree:&lt;br /&gt;
&lt;br /&gt;
[[File:SourceTree-Tree.jpg]]&lt;br /&gt;
&lt;br /&gt;
== Conflicts ==&lt;br /&gt;
&lt;br /&gt;
It might be the case that you inadvertently edit the same file on two different branches.  If you do, when you merge one branch into another, a '''merge conflict''' will occur.&lt;br /&gt;
&lt;br /&gt;
=== Example ===&lt;br /&gt;
&lt;br /&gt;
Suppose both Apple and Banana change the Carrot joke:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
# Change the file in the Apple branch&lt;br /&gt;
$ git checkout apple-branch&lt;br /&gt;
	Switched to branch 'apple-branch'&lt;br /&gt;
$ cat carrot.txt&lt;br /&gt;
	How do you make a soup rich? Add 14 carats to it!&lt;br /&gt;
$ echo 'What\'s a Vegetable\'s favourite martial art? Carrotee!' &amp;gt; carrot.txt&lt;br /&gt;
$ git commit -am &amp;quot;Apple changing carrot joke&amp;quot;&lt;br /&gt;
	[apple-branch f76f247] Apple changing carrot joke&lt;br /&gt;
	 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
&lt;br /&gt;
# Change the file in the Banana branch&lt;br /&gt;
$ git checkout banana-branch&lt;br /&gt;
	Switched to branch 'banana-branch'&lt;br /&gt;
$ cat carrot.txt&lt;br /&gt;
	How do you make a soup rich? Add 14 carats to it!&lt;br /&gt;
$ echo 'Why did the carrot get an award? Because he was outstanding in his field!' &amp;gt; carrot.txt&lt;br /&gt;
$ git commit -am &amp;quot;Banana changing carrot joke&amp;quot;&lt;br /&gt;
	[banana-branch f565381] Banana changing carrot joke&lt;br /&gt;
	 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
&lt;br /&gt;
# Attempt to merge into master&lt;br /&gt;
$ git checkout master&lt;br /&gt;
	Switched to branch 'master'&lt;br /&gt;
$ git merge apple-branch&lt;br /&gt;
	Updating 7ed050b..f76f247&lt;br /&gt;
	Fast-forward&lt;br /&gt;
	 carrot.txt | 2 +-&lt;br /&gt;
	 1 file changed, 1 insertion(+), 1 deletion(-)&lt;br /&gt;
$ git merge banana-branch&lt;br /&gt;
	Auto-merging carrot.txt&lt;br /&gt;
	CONFLICT (content): Merge conflict in carrot.txt&lt;br /&gt;
	Automatic merge failed; fix conflicts and then commit the result.&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Yikes!  What do we do next?&lt;br /&gt;
&lt;br /&gt;
=== Resolving Merge Conflicts ===&lt;br /&gt;
&lt;br /&gt;
There are two main ways to resolve merge conflicts: by manually editing the file and choosing the lines of code you want to keep, or by choosing one version of the file and replacing the other entirely.&lt;br /&gt;
&lt;br /&gt;
==== Manually Editing the Conflicted File ====&lt;br /&gt;
&lt;br /&gt;
When you open the file after running &amp;lt;code&amp;gt;git merge banana-branch&amp;lt;/code&amp;gt; above, you will see something like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt;&amp;lt; HEAD&lt;br /&gt;
What's a Vegetable's favourite martial art? Carrotee!&lt;br /&gt;
=======&lt;br /&gt;
Why did the carrot get an award? Because he was outstanding in his field!&lt;br /&gt;
&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt;&amp;gt; banana-branch&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Git added this notation to help you find which parts of the file were from the current branch (HEAD) and which ones were from the foreign branch (banana-branch).  Simply edit the file to reflect the version you prefer, and then commit.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ emacs carrot.txt # edit the file to reflect the joke you want&lt;br /&gt;
$ cat carrot.txt  # optionally check to make sure you've got the right version&lt;br /&gt;
	Why did the carrot get an award? Because he was outstanding in his field!&lt;br /&gt;
$ git commit -am &amp;quot;Resolving conflict&amp;quot;&lt;br /&gt;
	[master 98ba901] Resolving conflict&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Keeping One Version and Replacing the Other ====&lt;br /&gt;
&lt;br /&gt;
Git provides commands that will merge a file from a branch.&lt;br /&gt;
&lt;br /&gt;
* If you want to keep the version in the current branch and ignore the version coming from the foreign branch, run &amp;lt;code&amp;gt;git checkout --ours carrot.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
* If you want to keep the version coming from the foreign branch and ignore the version in the current branch, run &amp;lt;code&amp;gt;git checkout --theirs carrot.txt&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is an example where we keep Banana's version of the joke:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git checkout --theirs carrot.txt &lt;br /&gt;
$ cat carrot.txt  # optionally check to make sure you've got the right version&lt;br /&gt;
	Why did the carrot get an award? Because he was outstanding in his field!&lt;br /&gt;
$ git commit -am &amp;quot;Resolving conflict&amp;quot;&lt;br /&gt;
	[master 1669536] Resolving conflict&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Here is an example where we keep the existing version of the joke, which is Apple's version since we had already merged Apple into master:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ git checkout --ours carrot.txt &lt;br /&gt;
$ cat carrot.txt  # optionally check to make sure you've got the right version&lt;br /&gt;
	What's a Vegetable's favourite martial art? Carrotee!&lt;br /&gt;
$ git commit -am &amp;quot;Resolving conflict&amp;quot;&lt;br /&gt;
	[master 1fdcd7b] Resolving conflict&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' If you are using SourceTree, you can right-click the conflicted file in the file browser and select &amp;quot;keep mine&amp;quot; or &amp;quot;keep theirs&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
== Collaboration ==&lt;br /&gt;
&lt;br /&gt;
Using Git's powerful branch and merge tools are ideal for team collaboration.&lt;br /&gt;
&lt;br /&gt;
=== Collaboration Example ===&lt;br /&gt;
&lt;br /&gt;
Here's the idea: everyone working on a feature has their own branch.  Changes from each developer's branch are periodically merged in to the '''master''' branch, and developers periodically merge other people's changes from the '''master''' branch into their own branch.  When the feature is complete and bug-free, the branch is closed.&lt;br /&gt;
&lt;br /&gt;
Suppose there are three developers on a project: Susan, Caroline, and Rachel.  They each have their own branch and are developing separate features.  Susan is ready to merge her changes into '''master'''.  Here is what might happen:&lt;br /&gt;
&lt;br /&gt;
# Susan ''checks out'' the '''master''' branch locally.&lt;br /&gt;
# Susan ''pulls'' any changes that might be on '''origin/master''' into her local copy of '''master'''.&lt;br /&gt;
# Susan ''merges'' relevant changes from her branch into '''master'''.&lt;br /&gt;
# Susan ''checks out'' her own branch again.&lt;br /&gt;
# Susan ''pushes'' her repo updates to the remote repository.&lt;br /&gt;
# Caroline and Rachel ''check out'' the '''master''' branch locally.&lt;br /&gt;
# Caroline and Rachel ''pull'' the changes from '''origin/master''' to '''master'''.&lt;br /&gt;
# Caroline and Rachel ''check out'' their own branches locally.&lt;br /&gt;
# Caroline and Rachel ''merge'' '''master''' into their respective branches.&lt;br /&gt;
# Finally, Caroline and Rachel ''push'' everything up to the remote repository.&lt;br /&gt;
&lt;br /&gt;
This can be a cumbersome process, but it is important that you perform it at least once per working session to ensure that everyone's branches are up-to-date.&lt;br /&gt;
&lt;br /&gt;
=== Alternatives ===&lt;br /&gt;
&lt;br /&gt;
Fortunately for us, there exist developers who have created additional command-line utilities that automate the above process.  One such project is '''[https://github.com/aanand/git-up git-up]'''.  You and your partner may elect to use '''git-up''' instead of manual branching and merging.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 5]]&lt;/div&gt;</summary>
		<author><name>James</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Linux&amp;diff=2235</id>
		<title>Linux</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Linux&amp;diff=2235"/>
		<updated>2017-01-18T15:54:43Z</updated>

		<summary type="html">&lt;p&gt;James: /* Linux Distributions */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[wikipedia:Linux|Linux]] is an [[wikipedia:Free and open-source software|open-source]] operating system based on [[wikipedia:UNIX|UNIX]].  Linux is highly versatile and is used in a wide range of applications.  [[wikipedia:Desktop Linux|Desktop Linux]] is Linux with a GUI (like Microsoft Windows or Mac OS X); Desktop Linux is popular in niche markets, and it is used widely in developing countries.&lt;br /&gt;
&lt;br /&gt;
Linux is the most widely used operating system for web servers.  In CSE330, we will be interacting with Linux from the command line.  This article covers the tools you need to make the best use of Linux.&lt;br /&gt;
&lt;br /&gt;
== Linux Distributions ==&lt;br /&gt;
&lt;br /&gt;
The open-source community is responsible for the development of many different [[wikipedia:Linux distributions|distributions]] of Linux.  Distributions, or ''distros'', are different &amp;quot;flavors&amp;quot; of the Linux operating system with different objectives.&lt;br /&gt;
&lt;br /&gt;
There are hundreds of distributions of Linux.  Three of the main banches are [[wikipedia:Debian|Debian]], [[wikipedia:SuSE|SuSE]] (based on [[wikipedia:Slackware|Slackware]]), and [[wikipedia:Red Hat Enterprise Linux|Red Hat Enterprise Linux (RHEL)]].&lt;br /&gt;
&lt;br /&gt;
The sections below discuss two of these branches and give recommendations of Linux distributions suitable for a web server.  The CSE330 wiki provides instructions for both Debian-based and RHEL-based Linux distributions, so the choice of which to use is up to you. That being said, the majority of TAs have experience with Debian-based distributions. You may find better support while troubleshooting if you choose Ubuntu.&lt;br /&gt;
&lt;br /&gt;
=== Debian ===&lt;br /&gt;
&lt;br /&gt;
'''Debian''' was first introduced in 1993.  Debian has a passionate following, and its repositories contain more software packages than any other mainstream Linux distribution.  There are hundreds of derivatives of Debian.  Debian's most popular desktop derivative is '''[[wikipedia:Ubuntu|Ubuntu]]'''.&lt;br /&gt;
&lt;br /&gt;
Base Debian has a slow upgrade schedule, and because of this, it is an extremely stable operating system, making it well-suited for servers.  '''[[wikipedia:Ubuntu Server|Ubuntu Server]]''' is also an excellent choice for a Debian-based web server.&lt;br /&gt;
&lt;br /&gt;
=== Red Hat Enterprise Linux (RHEL) ===&lt;br /&gt;
&lt;br /&gt;
Red Hat Enterprise Linux, or '''RHEL''', was first introduced in 1994.  RHEL is known for being a good choice for enterprises that wish to use Linux as their primary OS.  RHEL has an abundance of administration tools.&lt;br /&gt;
&lt;br /&gt;
The Linux Lab in Lopata Hall uses '''[[wikipedia:Fedora Linux|Fedora Linux]]''', a desktop distribution based on RHEL.  '''[[wikipedia:CentOS|CentOS]]''' is a popular RHEL derivative that is widely used in web servers.  The '''[[wikipedia:Amazon Machine Image|Amazon EC2 Linux AMI]]''' is derived from CentOS, making it a distribution in the RHEL family.&lt;br /&gt;
&lt;br /&gt;
=== Special Note: Linux Kernel and Modules ===&lt;br /&gt;
{{XKCD&lt;br /&gt;
|id=619&lt;br /&gt;
|name=supported_features&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
What separates Linux from other Unix variants is its kernel. The kernel is the most important component of the operating system and is responsible for scheduling processes, providing access to the hardware devices, allocating memory to the programs, and so on.&lt;br /&gt;
&lt;br /&gt;
The Linux kernel uses both monolithic and modular approaches. A monolithic kernel is a single program that contains all the code so any addition to kernel (such as code to access a driver) requires recompiling the code. A monolithic kernel is usually a little faster and could have a smaller size since only the absolutely necessary code is there. The modular kernel, on the other hand, enables dynamic loading and unloading  of kernel code, called ''modules''. Typical modules include device drivers. Thanks to this modular approach, Linux seldom requires a reboot after installing a new device.&lt;br /&gt;
&lt;br /&gt;
== Bash ==&lt;br /&gt;
&lt;br /&gt;
In this course, you will be interacting with Linux primarily on the command line.  The most widespread ''command line language'' is '''Bash'''.  This is described in more detail in [[Bash|the Bash guide]].&lt;br /&gt;
&lt;br /&gt;
== Files and Permissions ==&lt;br /&gt;
&lt;br /&gt;
At the core of a Unix-based operating system is a directory structure with files and permissions.&lt;br /&gt;
&lt;br /&gt;
=== Filesystem Hierarchy ===&lt;br /&gt;
&lt;br /&gt;
The root directory of Linux contains a dozen or so subdirectories, each with a specific purpose:&lt;br /&gt;
&lt;br /&gt;
* '''/bin''' contains [[Bash#Running Programs|binaries]] used by all users&lt;br /&gt;
* '''/sbin''' contains system binaries typically used only by the system administrator&lt;br /&gt;
* '''/lib''' contains libraries for the binaries found in '''/bin''' and '''/sbin'''&lt;br /&gt;
* '''/etc''' contains configuration files&lt;br /&gt;
** '''/etc/yum.conf''' Configuration file for yum&lt;br /&gt;
** '''/etc/yum/yum.repos.d''' Directory containing .repo files for online repositories&lt;br /&gt;
** '''/etc/crontab''' System-wide crontab file&lt;br /&gt;
** '''/etc/fstab''' Information about default partitions to be mounted&lt;br /&gt;
** '''/etc/group''' List of groups in the system&lt;br /&gt;
** '''/etc/hosts''' List of IP addresses with their names&lt;br /&gt;
** '''/etc/inittab''' What to do at each run-level&lt;br /&gt;
** '''/etc/inetd.conf''' Configuration file for some internet services (replaced by xinetd.* in most systems)&lt;br /&gt;
** '''/etc/modules.conf''' Module information for the boot&lt;br /&gt;
** '''/etc/motd''' Message to be seen at the login prompt&lt;br /&gt;
** '''/etc/passwd''' User information&lt;br /&gt;
** '''/etc/profile''' System level initial file for sh and its derivatives&lt;br /&gt;
** '''/etc/shadow''' User passwords&lt;br /&gt;
* '''/dev''' contains device files&lt;br /&gt;
* '''/proc''' contains information on currently running processes&lt;br /&gt;
* '''/var''' contains files whose contents is expected to change&lt;br /&gt;
** '''/var/log''' contains system log files&lt;br /&gt;
*** '''/var/log/messages''' System/Kernel messages&lt;br /&gt;
*** '''/var/log/syslog''' System log (mostly for Daemons)&lt;br /&gt;
*** '''/var/log/wtmp'''' User access log (binary)&lt;br /&gt;
*** '''/var/log/dmesg''' Boot-up messages&lt;br /&gt;
*** '''/var/log/auth.log''' Authorization logs&lt;br /&gt;
** '''/var/lib''' contains packages and database files&lt;br /&gt;
** '''/var/spool''' contains print queues&lt;br /&gt;
* '''/tmp''' contains temporary files that are deleted at system reboot&lt;br /&gt;
* '''/usr''' contains user programs&lt;br /&gt;
** '''/usr/bin''' contains binaries for user programs&lt;br /&gt;
** '''/usr/sbin''' contains binaries for system administrators&lt;br /&gt;
** '''/usr/lib''' contains libraries for '''/usr/bin''' and '''/usr/sbin'''&lt;br /&gt;
** '''/usr/local''' contains programs that you install from source&lt;br /&gt;
* '''/home''' contains users' home directories&lt;br /&gt;
* '''/root''' is root's home directory&lt;br /&gt;
* '''/boot''' contains boot loader files (do not touch unless you know what you are doing!)&lt;br /&gt;
* '''/opt''' contains optional add-on applications&lt;br /&gt;
* '''/mnt''' is where system administrators can mount filesystems&lt;br /&gt;
* '''/media''' contains links to removable media devices (for example, CDs)&lt;br /&gt;
* '''/srv''' contains site-specific data which are served by the system&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
For more information, see the Wikipedia article on the [[wikipedia:Filesystem Hierarchy Standard|Filesystem Hierarchy Standard]].&lt;br /&gt;
&lt;br /&gt;
=== File Permissions ===&lt;br /&gt;
&lt;br /&gt;
Every file in Linux has permissions that define which users can Read, Write, and Execute it.  Every file has an owner and a group.  The permissions for a file are set on three levels: User (owner), Group, and Other.&lt;br /&gt;
&lt;br /&gt;
==== Symbolic Notation ====&lt;br /&gt;
&lt;br /&gt;
When you view the permissions of a file in Linux, they will most often be displayed in ''symbolic notation''.  Symbolic notation consists of 10 characters: the first defines the file type, and then there are three characters each for User, Group, and Other permissions.&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;-r--r--r--&amp;lt;/code&amp;gt; is a normal file that is readable by all users but writable or executable by no one.&lt;br /&gt;
* &amp;lt;code&amp;gt;-rwxr-xr-x&amp;lt;/code&amp;gt; is a normal file that is readable and executable by everyone but only writable by User (the file's owner).  This is the most common permission set.&lt;br /&gt;
&lt;br /&gt;
==== Viewing File Permissions ====&lt;br /&gt;
&lt;br /&gt;
To view the permissions of all files in a certain directory, run the binary &amp;lt;code&amp;gt;ls -l&amp;lt;/code&amp;gt; in Bash:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ ls -l   # displays a list of all files in a directory with their permissions in symbolic notation&lt;br /&gt;
total 16&lt;br /&gt;
lrwxr-xr-x  1 sffc  wheel   6 Aug  9 09:13 link -&amp;gt; myfile.txt&lt;br /&gt;
-rwxr--r--  1 sffc  wheel  12 Aug  9 09:13 myfile.txt&lt;br /&gt;
$ ls -l myfile.txt   # displays the permissions of only myfile.txt&lt;br /&gt;
-rwxr--r--  1 sffc  wheel  12 Aug  9 09:13 myfile.txt&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Setting File Permissions ====&lt;br /&gt;
&lt;br /&gt;
Linux comes with several useful binaries for setting file permissions.&lt;br /&gt;
&lt;br /&gt;
* '''chmod''' is used for setting permissions&lt;br /&gt;
* '''chown''' is used for setting a file's owner&lt;br /&gt;
* '''chgrp''' is used for setting a file's group&lt;br /&gt;
&lt;br /&gt;
Some examples are shown below.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ chmod a+x myfile.txt   # turns on the Execute option for all users&lt;br /&gt;
$ chmod o-w myfile.txt   # turns off the Write option for Other users&lt;br /&gt;
$ chmod u+wx-r myfile.txt   # turns on the Write and Execute options for User (the file's owner) and also turns off the Read option for User&lt;br /&gt;
$ chown todd myfile.txt   # sets the owner of myfile.txt to the user todd.  Note: First comes the user, then comes the filename: not the other way around!&lt;br /&gt;
$ chgrp staff myfile.txt   # sets the group of myfile.txt to usergroup staff&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more information, see https://www.linux.com/learn/tutorials/760276-how-to-manage-file-and-folder-permissions-in-linux&lt;br /&gt;
&lt;br /&gt;
=== The . and .. Directories ===&lt;br /&gt;
&lt;br /&gt;
The '''.''' directory is a reference to the current directory.   The '''..''' directory brings you one level up in the filesystem.&lt;br /&gt;
&lt;br /&gt;
=== Symbolic Links ===&lt;br /&gt;
&lt;br /&gt;
A [[wikipedia:Symbolic link|symbolic link]], or ''symlink'', is basically a link from one spot in the filesystem to another.  You can think of them like ''aliases'' in Mac OS X.  To create a a symlink, use the ''ln -s'' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ ln -s /path/to/file.txt /path/to/link   # creates a symlink to file.txt at /path/to/link&lt;br /&gt;
&lt;br /&gt;
# Example:&lt;br /&gt;
$ ln -s /home/todd/instructions.doc /var/www/public_html/classes/instructions.doc   # creates a symlink in the web server to instructions.doc&lt;br /&gt;
$ vi /var/www/public_html/classes/instructions.doc   # changes to the symbolic link will be reflected in the original file&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== User Management ==&lt;br /&gt;
&lt;br /&gt;
=== Adding a New User ===&lt;br /&gt;
&lt;br /&gt;
To create a new user, use the '''useradd''' command.  Then, set a password for that user using the '''passwd''' command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo useradd -r -m -c &amp;quot;My Full Name&amp;quot; myUserName&lt;br /&gt;
$ sudo passwd myUserName&lt;br /&gt;
Enter new UNIX password: &lt;br /&gt;
Retype new UNIX password: &lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Note:''' If Linux doesn't like your command, first check your syntax and then try it with single quotes around your full name and password instead of double quotes. If this works it is likely that you used some special characters in your password such as '!', which serves a special purpose in the shell. This is because Linux takes parameters enclosed in double quotes as one string, but still looks for special characters inside of the string and acts in accordance with their normal meaning. On the other hand, single quotes tell the shell to ignore any special characters within.&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT:''' If you are using Ubuntu Server, new users are created with /bin/sh as their default shell.  You want to use /bin/bash.  To change the shell for your user, run this command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo chsh -s /bin/bash myUserName   # changes shell for myUserName to /bin/bash&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Adding a User to the Sudoers List ===&lt;br /&gt;
&lt;br /&gt;
For security reasons, you should never SSH into your server as the root user.  Instead, you should use a normal user to whom you give '''sudo''' privileges.  (For more detail on sudo, see [[Linux#SUDO|the Linux guide]].)&lt;br /&gt;
&lt;br /&gt;
To give a user sudo privileges, use the command '''visudo''', which opens up the SUDO configuration file in the system's default text editor.  (Never edit the file ''/etc/sudoers'' directly!)  SUDO users are specified using lines similar to&lt;br /&gt;
&lt;br /&gt;
 alice   ALL=(ALL) ALL&lt;br /&gt;
&lt;br /&gt;
Add that line immediately below  the line defining '''root''':&lt;br /&gt;
&lt;br /&gt;
 root   ALL=(ALL) ALL&lt;br /&gt;
&lt;br /&gt;
When you are finished, save and close the file.  For more information on editing files on the command line, refer to [[#File Editors|the section about File Editors in this guide]].&lt;br /&gt;
&lt;br /&gt;
In this case, '''alice''' will be able to run any command with SUDO privileges on the computer.   For more detail on SUDO configuration, see http://www.linuxhelp.net/guides/sudo/&lt;br /&gt;
&lt;br /&gt;
'''Note:''' The visudo utility is especially useful because it not only locks the sudoers file against simultaneous edits, but it also checks the file for syntax errors when you quit. Therefore, it is always recommended that you use visudo to change the sudoers list rather than attempting to modify it directly.&lt;br /&gt;
&lt;br /&gt;
== Networking ==&lt;br /&gt;
&lt;br /&gt;
In Linux, you can see your network information by typing '''ifconfig'''. This command shows the status information of each network interface, including the IP address you will need to remotely connect to your instance. The interface ''lo'' is the special loopback interface with IP address 127.0.0.1.  This refers to your local machine and any connection from your machine to your machine goes through this pseudo-interface.  Typical network interfaces include ''eth0'', ''eth1'',..., ''wlan0'', etc. Ethernet cards are represented with ''ethX''.  In the past, most wireless cards showed up as ''wlanX'', but it is also common now for them to be represented with ''ethX'' names. ''ifconfig'' also gives information such as hardware address (MAC), netmask, and broadcast addresses.&lt;br /&gt;
&lt;br /&gt;
You can start or stop networking by calling ''/etc/init.d/networking'' script. As with most ''/etc/init.d'' scripts, this script takes several options, such as ''start'', ''stop'', ''restart''.  Note even if you stop networking, you would still have your lo interface. You can look at the code of the script to find out what it actually does. You can also stop or start individual interfaces by using the '''ifup''' and '''ifdown''' commands.&lt;br /&gt;
&lt;br /&gt;
The network configuration files are stored in ''/etc/network''. ''/etc/network/interfaces'' contains the defaults for each interface. For xample, you could specify static IP, netmask, network, broadcast and default gateway for an interface here, but you should not need to edit this files in general.  These default options can be changed with the '''ifconfig''' command. The ''/etc/network/if-down.d'' and ''/etc/network/if-up.d'' directories contain the scripts that are going to be executed when an interface is turned on or off.  Of course, most modern Linux distributions have GUI tools for doing network configuration more easily, and you shouldn't need to change anything for the purposes of this course.&lt;br /&gt;
&lt;br /&gt;
== Synchronizing Date and Time ==&lt;br /&gt;
&lt;br /&gt;
In order to avoid setting your system's time manually at every daylight savings change, you can use a Network Time Server via the Network Time Protocol (NTP).&lt;br /&gt;
&lt;br /&gt;
The NTP Daemon comes pre-installed on EC2 AMI instances.  To install it on Debian, install the '''ntp''' package from apt.&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
=== Setting Timezone ===&lt;br /&gt;
&lt;br /&gt;
Your server is probably not set to the correct timezone by default.&lt;br /&gt;
&lt;br /&gt;
The timezone files are in the directory ''/usr/share/zoneinfo''. They are further organized within subdirectories grouped by region.  For instance, Rome's time zone file is stored within ''/usr/share/zoneinfo/Europe''.&lt;br /&gt;
&lt;br /&gt;
In order to set the time zone, simply copy the desired time zone file to our ''/etc'' directory as a new file named &amp;quot;localtime&amp;quot;.  For example, to set the the machine's system time to Rome's time zone, we would enter the command&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
sudo cp /usr/share/zoneinfo/Europe/Rome /etc/localtime&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''ntp'' uses ''/etc/ntp.conf'' configuration file to find the ostnames of remote time servers.  The defaults here are probably fine.&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Installing Software ==&lt;br /&gt;
&lt;br /&gt;
The package management tool in Red Hat Enterprise Linux (and therefore also your Amazon EC2 instance) is '''rpm'''.  (In Debian, it is '''dpkg'''.)  If you have an ''rpm'' package, you can install it by&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ rpm -i somepackage.rpm&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This requires that ''somepackage.rpm'' be in your current directory, which means you will have to download the file yourself (or create it). It requires you to manually install any dependencies the package has.&lt;br /&gt;
&lt;br /&gt;
=== Repository-Based Package Managers ===&lt;br /&gt;
&lt;br /&gt;
A better alternative is to use a repository-based package manager.  In RHEL, this is '''yum'''; in Debian, it is '''apt'''.&lt;br /&gt;
&lt;br /&gt;
Before you install new software, you need to ensure that your local list of available packages is up-to-date.  Run one of the following commands to perform this operation:&lt;br /&gt;
&lt;br /&gt;
* In RHEL: '''yum check-update'''&lt;br /&gt;
* In Debian: '''apt-get update'''&lt;br /&gt;
&lt;br /&gt;
After you have ensured that your package list is synced with the remote repository, you can start installing packages.  To install a package, use one of the following commands:&lt;br /&gt;
&lt;br /&gt;
* In RHEL: '''yum install package-name'''&lt;br /&gt;
* In Debian: '''apt-get install package-name'''&lt;br /&gt;
&lt;br /&gt;
If you get a permission denied error, try sudoing the command, like '''sudo apt-get install xxxx'''&lt;br /&gt;
&lt;br /&gt;
For example, this is how you would install ''lynx'', a command-line web browser, in your RHEL Linux distribution:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ lynx --version   # is lynx installed?&lt;br /&gt;
-bash: lynx: command not found&lt;br /&gt;
$ sudo yum check-update   # sync package lists with the remote repositories&lt;br /&gt;
$ sudo yum install lynx    # install the lynx package&lt;br /&gt;
Downloading Packages:&lt;br /&gt;
lynx-2.8.6-27.6.amzn1.i686.rpm        | 1.8 MB     00:00     &lt;br /&gt;
Running rpm_check_debug&lt;br /&gt;
Running Transaction Test&lt;br /&gt;
Transaction Test Succeeded&lt;br /&gt;
Running Transaction&lt;br /&gt;
  Installing : lynx-2.8.6-27.6.amzn1.i686             1/1 &lt;br /&gt;
&lt;br /&gt;
Installed:&lt;br /&gt;
  lynx.i686 0:2.8.6-27.6.amzn1                                                                                                                                                                                                                &lt;br /&gt;
&lt;br /&gt;
Complete!&lt;br /&gt;
$ lynx --version   # test again to see if we have lynx installed&lt;br /&gt;
Lynx Version 2.8.6rel.5 (09 May 2007)&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can also search for available packages by name or by the name of a file that they install.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ yum search lynx   # search for packages whose name contains lynx&lt;br /&gt;
======= N/S Matched: lynx =======&lt;br /&gt;
lynx.i686 : A text-based Web browser&lt;br /&gt;
$ yum provides lynx   # search for packages that install a file or command named lynx&lt;br /&gt;
lynx-2.8.6-27.6.amzn1.i686 : A text-based Web browser&lt;br /&gt;
Repo        : installed&lt;br /&gt;
Matched from:&lt;br /&gt;
Other       : Provides-match: lynx&lt;br /&gt;
$ &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The list of repositories that '''yum''' searches is located at &amp;lt;code&amp;gt;/etc/yum.conf&amp;lt;/code&amp;gt;.  The list of repositories that '''apt''' searches is located at &amp;lt;code&amp;gt;/etc/apt/sources.list&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
=== Essential Packages ===&lt;br /&gt;
&lt;br /&gt;
To save you some headaches later on, it is recommended that you install a few essential package bundles when you first create a new Linux instance.  These packages include things like Make and a C compiler.&lt;br /&gt;
&lt;br /&gt;
'''Debian:'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo apt-get install build-essential&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''RHEL:'''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ sudo yum groupinstall &amp;quot;Development Tools&amp;quot;&lt;br /&gt;
$ sudo yum install kernel-devel kernel-headers&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Searching for Packages ===&lt;br /&gt;
&lt;br /&gt;
You can search for packages by name, command, and so on.  For example, to search for all packages relating to &amp;quot;lynx&amp;quot;, you could do:&lt;br /&gt;
&lt;br /&gt;
'''Debian:'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ apt-cache search lynx&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''RHEL:'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ yum search lynx&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Command Reference ==&lt;br /&gt;
{{XKCD&lt;br /&gt;
|id=196&lt;br /&gt;
|name=command_line_fu&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
Earlier, you saw that '''cat''' is a command that shows the contents of a file.  Below is a list of other useful commands in Linux.&lt;br /&gt;
&lt;br /&gt;
=== Navigation and File Management ===&lt;br /&gt;
&lt;br /&gt;
* '''ls''' List file(s) in current working directory&lt;br /&gt;
** '''ll''' Shortcut to '''ls -l'''.  List files with more details than '''ls'''.  Only available in certain distributions&lt;br /&gt;
* '''cd''' Change working directory.  Note: cd called without any arguments moves you to your home directory&lt;br /&gt;
* '''cp''' Copy a file&lt;br /&gt;
* '''mv''' Move or rename a file&lt;br /&gt;
* '''rm''' Remove a file&lt;br /&gt;
** '''rm -r''' Remove a directory and all files in it&lt;br /&gt;
* '''ln -s''' Create a symlink to a file&lt;br /&gt;
* '''mkdir''' Create a directory&lt;br /&gt;
* '''rmdir''' Remove a directory (directory must be empty; if it's not, use '''rm -r''')&lt;br /&gt;
* '''cat''' Display the contents of a file&lt;br /&gt;
* '''less''' Display the contents of a file, wait for the user at each page&lt;br /&gt;
* '''tail''' Display the last 20 lines of a file&lt;br /&gt;
** '''tail -f''' Display the last 20 lines of a file and then wait for changes, displaying them as they occur.  Useful for monitoring log files.&lt;br /&gt;
* '''chown''' Change the owner of a file&lt;br /&gt;
* '''chgrp''' Change the group of a file&lt;br /&gt;
* '''chmod''' Change the security permissions of a file&lt;br /&gt;
* '''grep''' Display the lines of a file matching a user specified string&lt;br /&gt;
* '''diff''' Display the difference between two files&lt;br /&gt;
&lt;br /&gt;
=== System Administration ===&lt;br /&gt;
&lt;br /&gt;
* '''df''' Display free diskspace&lt;br /&gt;
* '''du''' Display disk usage&lt;br /&gt;
* '''free''' Display memory usage information&lt;br /&gt;
* '''date''' Display current time and date&lt;br /&gt;
* '''top''' Display the CPU and Memory usages of current processes&lt;br /&gt;
* '''ps''' Display current processes&lt;br /&gt;
* '''kill''' Terminate a running process&lt;br /&gt;
* '''killall''' Terminate the running process matching user specified criterias&lt;br /&gt;
* '''ping hostname''' Ping a host&lt;br /&gt;
* '''host''' Get the IP address of a host&lt;br /&gt;
* '''passwd''' Change the user password&lt;br /&gt;
* '''su user''' Switch to the privileges of another user&lt;br /&gt;
* '''shutdown''' Power off the computer&lt;br /&gt;
* '''reboot''' Reboot the computer&lt;br /&gt;
* '''clear''' Clear the terminal&lt;br /&gt;
* '''ifconfig''' Display/Configure a network device&lt;br /&gt;
* '''file''' Show the file type&lt;br /&gt;
* '''lsmod''' Display loaded kernel modules&lt;br /&gt;
* '''insmod''' Install a kernel module&lt;br /&gt;
* '''modprobe''' Load a kernel module (also load the dependencies)&lt;br /&gt;
* '''adduser''' Add a new user&lt;br /&gt;
* '''exit''' Exit from a shell&lt;br /&gt;
* '''lpr''' Print a file&lt;br /&gt;
* '''head''' Display  lines at the beginning of a file&lt;br /&gt;
* '''tail''' Display lines at the end of a file&lt;br /&gt;
* '''pwd''' Display the name of the current working directory&lt;br /&gt;
* '''lsof''' Open files in the system&lt;br /&gt;
* '''netstat''' Statistics related to open sockets&lt;br /&gt;
* '''vmstat''' Reports information about processes, memory, IO, and CPU&lt;br /&gt;
&lt;br /&gt;
=== File Editors ===&lt;br /&gt;
{{XKCD&lt;br /&gt;
|name=real_programmers&lt;br /&gt;
|id=378&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
It is sometimes convenient to edit files using the command line.  Three widely-used command line text editors are '''vi''', '''emacs''', and '''nano'''.&lt;br /&gt;
&lt;br /&gt;
==== Vi ====&lt;br /&gt;
&lt;br /&gt;
To edit a file using Vi, use the command '''vi'''.  You will see something like this:&lt;br /&gt;
&lt;br /&gt;
 .&lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 &amp;quot;myfile.txt&amp;quot; [New File]&lt;br /&gt;
&lt;br /&gt;
To insert text into the file, press '''i''' once, then type away:&lt;br /&gt;
&lt;br /&gt;
 Hello World&lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 -- INSERT -- &lt;br /&gt;
&lt;br /&gt;
To leave insert mode, press ESC.&lt;br /&gt;
&lt;br /&gt;
To save your file, type the command ''':w''' and press Enter.&lt;br /&gt;
&lt;br /&gt;
 Hello World&lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 ~                                                     &lt;br /&gt;
 &amp;quot;myfile.txt&amp;quot; [New] 1L, 12C written&lt;br /&gt;
&lt;br /&gt;
To save and then close your file, type the command ''':wq'''.  (To close the file without saving, use the command ''':q!''')&lt;br /&gt;
&lt;br /&gt;
For more vi commands, see http://ss64.com/vi.html&lt;br /&gt;
&lt;br /&gt;
==== Emacs ====&lt;br /&gt;
&lt;br /&gt;
To edit a file using emacs, use the command '''emacs'''.  You can start typing immediately:&lt;br /&gt;
&lt;br /&gt;
 Hello World&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 -uuu:**-F1  myfile.txt     All L1     (Text)----------&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
To save a file, type '''C-x C-s''' (that means Control-X, then Control-S):&lt;br /&gt;
&lt;br /&gt;
 Hello World&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 -uuu:---F1  myfile.txt     All L1     (Text)----------&lt;br /&gt;
 Wrote /home/todd/myfile.txt&lt;br /&gt;
&lt;br /&gt;
To quit emacs, type '''C-x C-c'''.  (It will ask you whether or not to save the file if you've made changes.)&lt;br /&gt;
&lt;br /&gt;
For more emacs commands, see http://souptonuts.sourceforge.net/chirico/emacs_ref.html&lt;br /&gt;
&lt;br /&gt;
==== Nano ====&lt;br /&gt;
&lt;br /&gt;
To edit a file using nano, use the command '''nano'''.  You can start editing the file immediately:&lt;br /&gt;
&lt;br /&gt;
   GNU nano 2.0.6               File: myfile.txt                                      &lt;br /&gt;
 &lt;br /&gt;
 Hello World&lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 &lt;br /&gt;
 ^G Get Help   ^O WriteOut   ^R Read File  ^Y Prev Page  ^K Cut Text   ^C Cur Pos&lt;br /&gt;
 ^X Exit       ^J Justify    ^W Where Is   ^V Next Page  ^U UnCut Text ^T To Spell&lt;br /&gt;
&lt;br /&gt;
Nano tells you the commands you need right there so you don't have to always keep looking them up like with Vi and Emacs.&lt;br /&gt;
&lt;br /&gt;
For more detail on Nano commands, see http://www.nano-editor.org/dist/v2.2/nano.html&lt;br /&gt;
&lt;br /&gt;
== Linux Resources ==&lt;br /&gt;
&lt;br /&gt;
[http://www.yolinux.com/TUTORIALS/LinuxTutorialSysAdmin.html  Linux System Administration Tutorial]&lt;br /&gt;
&lt;br /&gt;
[http://www-uxsup.csx.cam.ac.uk/pub/doc/suse/suse9.0/userguide-9.0/ch24.html Working with the Shell (SUSE Documentation)]&lt;br /&gt;
&lt;br /&gt;
[http://en.wikipedia.org/wiki/Linux_kernel Linux Kernel]&lt;br /&gt;
&lt;br /&gt;
[http://www.yolinux.com/TUTORIALS/LinuxTutorialAdvanced_vi.html VI Tutorial]&lt;br /&gt;
&lt;br /&gt;
[http://students.cec.wustl.edu/~jg18/guide/ Making the Transition to Linux: A Guide to the Linux Command Line Interface for Students]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;/div&gt;</summary>
		<author><name>James</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_6&amp;diff=2234</id>
		<title>Module 6</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_6&amp;diff=2234"/>
		<updated>2017-01-18T01:07:18Z</updated>

		<summary type="html">&lt;p&gt;James: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 6 builds upon the JavaScript skills you learned in Module 5.&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Node.JS]]&lt;br /&gt;
* [[Socket.IO]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Install Node.JS ===&lt;br /&gt;
&lt;br /&gt;
Install Node.JS from Apt or Yum according to the instructions in the [[Node.JS]] guide.&lt;br /&gt;
&lt;br /&gt;
=== Static File Server in Node.JS ===&lt;br /&gt;
&lt;br /&gt;
The individual portion of Module 6 is short in order to give you enough time to complete the group portion.&lt;br /&gt;
&lt;br /&gt;
# Copy the example code from the Node.JS guide into a file called ''static_server.js'' or something of that nature.  Save it on your EC2 instance (but not in a place that Apache can serve!).&lt;br /&gt;
#: Ensure that you understand what the static file server script is doing…&lt;br /&gt;
# Make a directory parallel to ''static_server.js'' named ''static''.&lt;br /&gt;
# Change &amp;quot;&amp;lt;STATIC DIRECTORY NAME&amp;gt;&amp;quot; on line 11 of the static fileserver example code to reflect the name of the directory you just made.&lt;br /&gt;
# Save the following files in your ''static'' directory:&lt;br /&gt;
#* ''hello.txt'', a text file containing &amp;quot;Hello World&amp;quot;&lt;br /&gt;
#* ''brookings.jpg'', an image file you can download from here: http://classes.engineering.wustl.edu/cse330/content/brookings.jpg&lt;br /&gt;
#* ''college.html'', an HTML document based on the [[HTML and CSS#Quick and Easy Page Layout|Quick and Easy HTML Layout]] containing an image tag pointing to ''brookings.jpg''&lt;br /&gt;
#* ''phpinfo.php'', a PHP file containing the phpinfo command that generates a diagnostic page of the server:&lt;br /&gt;
#: &amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&amp;lt;?php   phpinfo();   ?&amp;gt;&amp;lt;/source&amp;gt;&lt;br /&gt;
# Boot up your Node.JS static fileserver, and from your browser, load all four of the files you created in step 4.&lt;br /&gt;
#: Which ones work and which ones don't?  Why might this be the case?&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
In the group portion of Module 6 you will create a multi-room chat server using Node.JS and Socket.IO.&lt;br /&gt;
&lt;br /&gt;
This chat service will contain a main lobby where users sign on with a nickname and can communicate with each other.  Users may also create chat rooms for other to join.  The entire app should be displayed on a single webpage, listing the room you are in, all available rooms, and the users in the current room.&lt;br /&gt;
&lt;br /&gt;
The single room chat server and client are provided here: [[Socket.IO]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 75 points total.&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. Assignments must be demoed within 4 days of the due date (Friday at 11:30 AM for Module 6). ''' &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID1-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module5-201343-301452) &lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
_________&lt;br /&gt;
&lt;br /&gt;
# '''Individual Portion (25 Points):'''&lt;br /&gt;
#* Node.JS is installed on your EC2 instance (5 points)&lt;br /&gt;
#* The ''hello.txt'', ''brookings.jpg'', and ''college.html'' files all load successfully (4 points each)&lt;br /&gt;
#* Visiting a file that does not exist inside the ''static'' directory results in a 404 (4 points)&lt;br /&gt;
#* You can explain to the TA why ''phpinfo.php'' behaves the way it does when loaded through Node.JS (4 points)&lt;br /&gt;
#* Make sure your individual portion files are pushed to Bitbucket&lt;br /&gt;
# '''Multi-room Chat Server (50 Points):'''&lt;br /&gt;
#* '''''Administration of user created chat rooms (25 Points):'''''&lt;br /&gt;
#** Users can create chat rooms with an arbitrary room name(5 points)&lt;br /&gt;
#** Users can join an arbitrary chat room (5 points)&lt;br /&gt;
#** The chat room displays all users currently in the room (5 points)&lt;br /&gt;
#** A private room can be created that is password protected (5 points)&lt;br /&gt;
#** Creators of chat rooms can temporarily kick others out of the room (3 points)&lt;br /&gt;
#** Creators of chat rooms can permanently ban users from joining that particular room (2 points)&lt;br /&gt;
#* '''''Messaging (5 Points):'''''&lt;br /&gt;
#** A user's message shows their username and is sent to everyone in the room (1 point)&lt;br /&gt;
#** Users can send private messages to another user in the same room (4 points)&lt;br /&gt;
#* '''''Best Practices (5 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (2 points)&lt;br /&gt;
#** Code passes HTML validation (2 points)&lt;br /&gt;
#** node_modules folder is ignored by version control (1 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Communicating with others and joining rooms is easy and intuitive (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
#* '''Creative Portion (10 Points)'''&lt;br /&gt;
#** Make sure to create a README.md file pointing to your server&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 6]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>James</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_5&amp;diff=2233</id>
		<title>Module 5</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_5&amp;diff=2233"/>
		<updated>2017-01-18T01:06:28Z</updated>

		<summary type="html">&lt;p&gt;James: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
In Module 5, you will learn JavaScript, the dominant client-side web language.  JavaScript is the third and final programming language you will learn in CSE 330.&lt;br /&gt;
&lt;br /&gt;
This article contains your assignments for Module 5.&lt;br /&gt;
&lt;br /&gt;
'''Warning:'''&lt;br /&gt;
&lt;br /&gt;
''This module takes students a while. It is strongly recommended that you start early and ask questions as they come up.''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[JavaScript]]&lt;br /&gt;
* [[AJAX and JSON]]&lt;br /&gt;
* [[jQuery]]&lt;br /&gt;
* [[Web Application Security, Part 3]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
'''''IMPORTANT:'' Both of the individual assignments must be completed ''without'' using a JavaScript library like jQuery.'''  However, you may (and should) use jQuery for the group portion.&lt;br /&gt;
&lt;br /&gt;
=== JavaScript Calculator ===&lt;br /&gt;
&lt;br /&gt;
In Module 2, you made a calculator using PHP.  Now you will be making one using JavaScript.&lt;br /&gt;
&lt;br /&gt;
* The web page should have two input fields and a radio button group for the operation, with the 4 basic math operations represented (add, subtract, multiply, divide).&lt;br /&gt;
* JavaScript should monitor all three fields and display the current result whenever the user changes any value in any field, without refreshing the page.&lt;br /&gt;
*: '''Tip 1:''' Consider using either the ''change'' or the ''keyup'' event on the text fields, and either the ''change'' or the ''click'' event on the radio buttons.&lt;br /&gt;
*: '''Tip 2:''' Re-read [[JavaScript|the JavaScript guide]] if you need help figuring our how to bind callback functions to events, or how to determine which radio button is currently selected.  (There are examples for both of these!)&lt;br /&gt;
* The calculator should be completely self-contained; i.e., you should not be making any requests to any other server-side or client-side scripts or web pages after the initial page load.&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' You can embed JavaScript code into an HTML document like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
// your code here&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' If your code isn't working the way you expect, use a JavaScript error console.  In Chrome, for example, press Ctrl-Shift-I (or Cmd-Option-I) to open the WebKit inspector.&lt;br /&gt;
&lt;br /&gt;
'''Important:''' It is best practice to fully separate the content, appearance, and behavior.  In previous modules, you may have lost points for using HTML tags that change the appearance of things &amp;lt;nowiki&amp;gt;(like &amp;lt;center&amp;gt; and &amp;lt;font&amp;gt;).&amp;lt;/nowiki&amp;gt;  In this module, make sure that you define your event listeners in JavaScript as in &amp;lt;code&amp;gt;document.getElementById(&amp;quot;xyz&amp;quot;).addEventListener(...)&amp;lt;/code&amp;gt; and '''''not''''' in the HTML like &amp;lt;code&amp;gt;&amp;lt;button onclick=&amp;quot;badExample();&amp;quot;&amp;gt;Bad Example&amp;lt;/button&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
=== Weather Widget ===&lt;br /&gt;
&lt;br /&gt;
In this section, you will make a web page that displays the weather forecast using AJAX requests to a weather server.&lt;br /&gt;
&lt;br /&gt;
# Make an empty HTML document; name it '''weather.html'''&lt;br /&gt;
#: Refer to the [[HTML and CSS]] guide for the skeleton of an HTML document&lt;br /&gt;
# Define a function in JavaScript; call it '''fetchWeather()'''.  You may write your JavaScript in an embedded script in your HTML document.&lt;br /&gt;
# Inside your '''fetchWeather()''' function, make an AJAX request to the weather server.&lt;br /&gt;
#: We have a server that outputs the current weather in JSON format.  The format is documented in the [[#JSON Structure]] section below.&lt;br /&gt;
#: '''URL:''' http://classes.engineering.wustl.edu/cse330/content/weather_json.php&lt;br /&gt;
#: We kindly thank Yahoo Weather for providing us with up-to-date weather information.&lt;br /&gt;
#* '''IMPORTANT:''' Under normal circumstances, AJAX requests ''cannot'' be performed cross-domain for security reasons.  We have set the &amp;lt;code&amp;gt;Access-Control-Allow-Origin&amp;lt;/code&amp;gt; header on our server to allow requests from your EC2 instances, or from localhost.  '''You will therefore need to upload your code to your EC2, or access it via localhost, in order for the AJAX requests to work.'''  This means that you cannot, for example, complete this part of the individual portion in JSFiddle.&lt;br /&gt;
# In your callback, process the JSON and use JavaScript to manipulate the HTML DOM to display the following information on your page:&lt;br /&gt;
#* Location&lt;br /&gt;
#** City, in a &amp;lt;nowiki&amp;gt;&amp;lt;strong&amp;gt;&amp;lt;/nowiki&amp;gt; tag&lt;br /&gt;
#** State, not in any tag&lt;br /&gt;
#* Humidity&lt;br /&gt;
#* Current Temperature&lt;br /&gt;
#* Image for Tomorrow's Forecast (see [[#Weather Condition Images]] below for more information)&lt;br /&gt;
#* Image for the Day After Tomorrow's Forecast&lt;br /&gt;
# Finally, bind '''fetchWeather()''' to the DOMContentLoaded event so that your weather widget is automatically initialized when the page is loaded:&lt;br /&gt;
#: &amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;document.addEventListener(&amp;quot;DOMContentLoaded&amp;quot;, fetchWeather, false);&amp;lt;/source&amp;gt;&lt;br /&gt;
# In addition, add a button that runs your ''fetchWeather'' function when clicked.  This should update your widget with the current weather conditions.&lt;br /&gt;
&lt;br /&gt;
Use the following HTML:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;html4strict&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;weather&amp;quot; id=&amp;quot;weatherWidget&amp;quot;&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;weather-loc&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;weather-humidity&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;div class=&amp;quot;weather-temp&amp;quot;&amp;gt;&amp;lt;/div&amp;gt;&lt;br /&gt;
	&amp;lt;img class=&amp;quot;weather-tomorrow&amp;quot; /&amp;gt;&lt;br /&gt;
	&amp;lt;img class=&amp;quot;weather-dayaftertomorrow&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Include the CSS file from here: http://classes.engineering.wustl.edu/cse330/content/weather.css&lt;br /&gt;
&lt;br /&gt;
When everything is working, the weather widget should look something like this:&lt;br /&gt;
&lt;br /&gt;
[[File:WeatherWidget.png]]&lt;br /&gt;
&lt;br /&gt;
'''Important:''' The widget in this section needs to work in only Firefox and Chrome.  It does '''''not''''' need to work Internet Explorer.&lt;br /&gt;
&lt;br /&gt;
==== Tips ====&lt;br /&gt;
&lt;br /&gt;
===== JSON Structure =====&lt;br /&gt;
&lt;br /&gt;
The JSON from our server looks like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
   &amp;quot;updated&amp;quot;: &amp;quot;Thu, 11 Oct 2012 5:54 pm CDT&amp;quot;,&lt;br /&gt;
   &amp;quot;location&amp;quot;: {&lt;br /&gt;
      &amp;quot;city&amp;quot;: &amp;quot;St. Louis&amp;quot;,&lt;br /&gt;
      &amp;quot;state&amp;quot;: &amp;quot;MO&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;wind&amp;quot;: {&lt;br /&gt;
      &amp;quot;chill&amp;quot;: &amp;quot;62&amp;quot;,&lt;br /&gt;
      &amp;quot;direction&amp;quot;: &amp;quot;150&amp;quot;,&lt;br /&gt;
      &amp;quot;speed&amp;quot;: &amp;quot;3 mph&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;atmosphere&amp;quot;: {&lt;br /&gt;
      &amp;quot;humidity&amp;quot;: &amp;quot;50&amp;quot;,&lt;br /&gt;
      &amp;quot;visibility&amp;quot;: &amp;quot;10&amp;quot;,&lt;br /&gt;
      &amp;quot;pressure&amp;quot;: &amp;quot;30.12 in&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;current&amp;quot;: {&lt;br /&gt;
      &amp;quot;code&amp;quot;: &amp;quot;28&amp;quot;,&lt;br /&gt;
      &amp;quot;text&amp;quot;: &amp;quot;Mostly Cloudy&amp;quot;,&lt;br /&gt;
      &amp;quot;temp&amp;quot;: &amp;quot;62°F&amp;quot;,&lt;br /&gt;
      &amp;quot;date&amp;quot;: &amp;quot;Thu, 11 Oct 2012 5:54 pm CDT&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;tomorrow&amp;quot;: {&lt;br /&gt;
      &amp;quot;code&amp;quot;: &amp;quot;29&amp;quot;,&lt;br /&gt;
      &amp;quot;text&amp;quot;: &amp;quot;Clouds Early/Clearing Late&amp;quot;,&lt;br /&gt;
      &amp;quot;low&amp;quot;: &amp;quot;45°F&amp;quot;,&lt;br /&gt;
      &amp;quot;high&amp;quot;: &amp;quot;61°F&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;dayafter&amp;quot;: {&lt;br /&gt;
      &amp;quot;code&amp;quot;: &amp;quot;30&amp;quot;,&lt;br /&gt;
      &amp;quot;text&amp;quot;: &amp;quot;Partly Cloudy&amp;quot;,&lt;br /&gt;
      &amp;quot;low&amp;quot;: &amp;quot;53°F&amp;quot;,&lt;br /&gt;
      &amp;quot;high&amp;quot;: &amp;quot;65°F&amp;quot;&lt;br /&gt;
   },&lt;br /&gt;
   &amp;quot;credit&amp;quot;: &amp;quot;http://us.rd.yahoo.com/dailynews/rss/weather/St._Louis__MO/*http://weather.yahoo.com/forecast/USMO0170_f.html&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===== Weather Condition Images =====&lt;br /&gt;
&lt;br /&gt;
Each day's forecast has a code.  There are images associated with these codes.&lt;br /&gt;
&lt;br /&gt;
One place to get the images is from here: &amp;lt;nowiki&amp;gt;http://us.yimg.com/i/us/nws/weather/gr/&amp;lt;/nowiki&amp;gt;'''##'''&amp;lt;nowiki&amp;gt;ds.png&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Replace the '''##''' with the forecast code.  For example, for code 32, the URL would be: http://us.yimg.com/i/us/nws/weather/gr/32ds.png&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
I forgot if I already mentioned this, but '''start early on this project!''' It will take longer than you think, I promise!&lt;br /&gt;
&lt;br /&gt;
You are encouraged to use the advanced version control practices you learned in Module 5 when completing this assignment.&lt;br /&gt;
&lt;br /&gt;
=== Calendar ===&lt;br /&gt;
&lt;br /&gt;
Build a simple calendar that allows users to add and remove events dynamically.&lt;br /&gt;
&lt;br /&gt;
You will use JavaScript to process user interactions at the web browser, without ever refreshing the browser after the initial web page load.  You may use a JavaScript library of your choice, including Ext JS.&lt;br /&gt;
&lt;br /&gt;
Your application should utilize AJAX to run server-side scripts that query your database to save and retrieve information, including user accounts and events.&lt;br /&gt;
&lt;br /&gt;
We have also written some functions to help you get started: [[JavaScript Calendar Library]]&lt;br /&gt;
&lt;br /&gt;
==== Examples ====&lt;br /&gt;
&lt;br /&gt;
* https://calendar.google.com/&lt;br /&gt;
* http://www.zoho.com/calendar/&lt;br /&gt;
&lt;br /&gt;
==== Server Side Language ====&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Additionally, you may use a database of your choice.  MySQL is probably the logical choice since you have been using it since Module 2, but if you're up for a challenge we encourage you to look at other database options like [[wikipedia:MongoDB|MongoDB]].&lt;br /&gt;
&lt;br /&gt;
==== Requirements ====&lt;br /&gt;
&lt;br /&gt;
* Support a month-by-month view of the calendar.&lt;br /&gt;
*: Show one month at a time, with buttons to move forward or backward.&lt;br /&gt;
*: There should be no limit to how far forward or backward the user can go.&lt;br /&gt;
* Users can register and log in to the website.&lt;br /&gt;
*: You may leverage your MySQL project code and database from module 3 to get started.&lt;br /&gt;
* Unregistered users should see no events on the calendar.&lt;br /&gt;
* Registered users can add events.&lt;br /&gt;
*: All events should have a date and time, but do not need to have a duration.&lt;br /&gt;
*: You do ''not'' need to support recurring events (where you add an event that repeats, for example, every monday).&lt;br /&gt;
* Registered users see only events that they have added.&lt;br /&gt;
*: Your AJAX should not ask the server for events from a certain username.  Instead, your AJAX should ask the server for events, and the server should respond with the events for only the currently-logged-in user (from the session).  Can you think of why?&lt;br /&gt;
* Registered users can delete their events, but not the events of others.&lt;br /&gt;
*: Again, the server should delete events based on the username present in the session.  (If it deletes only based on an Event ID, an attacker could feed any arbitrary Event ID to your server, even if he/she didn't own that event.)&lt;br /&gt;
* All user and event data should be kept in a database.&lt;br /&gt;
* At no time should the main page need to be reloaded.&lt;br /&gt;
*: User registration, user authentication, event addition, and event deletion should all be handled by JavaScript and AJAX requests to your server.&lt;br /&gt;
* Your page needs to work in the versions of Firefox and Chrome installed on the lab computers.&lt;br /&gt;
&lt;br /&gt;
'''Tip:''' Run your database schema by a TA before implementing it.&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
Your project needs to demonstrate that thought was put into web security and best practice.  For more information, see this week's Web Application Security guide: [[Web Application Security, Part 3]]&lt;br /&gt;
&lt;br /&gt;
In particular:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to prevent XSS attacks.'''  Be careful when transmitting data over JSON that will be reflected in an event title!  (Note: JSON data should be sanitized on the client side, not the server side.)&lt;br /&gt;
* '''Perform precautionary measures to prevent session hijacking attacks.'''&lt;br /&gt;
*: You should specify your session cookie to be HTTP-Only.  However, for the means of this module, you need not test for user agent consistency.&lt;br /&gt;
* '''Optional:''' Validate your JavaScript code using [http://www.jshint.com/ JSHint] '''''or''''' [http://jslint.com/ JSLint] for up to 3 points of extra credit.&lt;br /&gt;
&lt;br /&gt;
You should continue the practices that you have learned in past weeks:&lt;br /&gt;
&lt;br /&gt;
* Pass tokens in forms to prevent CSRF attacks.&lt;br /&gt;
*: '''Hint:''' You will need to send your CSRF tokens in your AJAX requests.  Remember that AJAX still submits forms and runs server-side scripts, just like the vanilla forms you've been using in Modules 2 and 3.&lt;br /&gt;
* Use prepared queries to prevent SQL Injection attacks.&lt;br /&gt;
* If storing passwords in a database, always store them salted and encrypted.&lt;br /&gt;
* Your page should validate with no errors through the W3C validator.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total.&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. ''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID1-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module5-201343-301452) &lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, or share your repo with cse330, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
_________&lt;br /&gt;
&lt;br /&gt;
# '''JavaScript Calculator (10 Points):'''&lt;br /&gt;
#* Calculator successfully adds, subtracts, multiplies, and divides numbers (3 points)&lt;br /&gt;
#* The result is automatically computed when a value in either field is changed (3 points)&lt;br /&gt;
#* Calculator is written entirely in pure, conventional JavaScript with no external libraries (4 points)*&lt;br /&gt;
#*: ''Note: be sure to fully separate content, appearance, and behavior.  This means that you should '''not''' use the event attributes on the HTML elements like onclick, onchange, and onkeyup.''&lt;br /&gt;
# '''Weather Widget (15 Points):'''&lt;br /&gt;
#* Widget performs an AJAX request to fetch the current weather (4 points)&lt;br /&gt;
#* The HTML template is filled with the correct information, including an image (4 points)&lt;br /&gt;
#* Button to reload the weather widget (2 points)&lt;br /&gt;
#* Widget is written entirely in pure, conventional JavaScript with no external libraries (5 points)*&lt;br /&gt;
# '''AJAX Calendar (60 Points):'''&lt;br /&gt;
#* '''''Calendar View (10 Points):'''''&lt;br /&gt;
#** The calendar is displayed as a table grid with days as the columns and weeks as the rows, one month at a time (5 points)&lt;br /&gt;
#** The user can view different months as far in the past or future as desired (5 points)&lt;br /&gt;
#* '''''User and Event Management (25 Points):'''''&lt;br /&gt;
#** Events can be added, modified, and deleted (5 points)&lt;br /&gt;
#** Events have a title, date, and time (2 points)&lt;br /&gt;
#** Users can log into the site, and they cannot view or manipulate events associated with other users (8 points)&lt;br /&gt;
#**: ''Don't fall into the Abuse of Functionality trap!  Check user credentials on the server side as well as on the client side.''&lt;br /&gt;
#** All actions are performed over AJAX, without ever needing to reload the page (10 points)&lt;br /&gt;
#* '''''Best Practices (20 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (2 points)&lt;br /&gt;
#** If storing passwords, they are stored salted and encrypted; if using OpenID, you are storing the user's OpenID identifier in the database (2 points)&lt;br /&gt;
#** All AJAX requests that either contain sensitive information or modify something on the server are performed via POST, not GET (3 points)&lt;br /&gt;
#** Safe from XSS attacks; that is, all content is escaped on output (3 points)&lt;br /&gt;
#** Safe from SQL Injection attacks (2 points)&lt;br /&gt;
#** CSRF tokens are passed when editing or removing events (3 points)&lt;br /&gt;
#** Session cookie is HTTP-Only (3 points)&lt;br /&gt;
#** Page passes the W3C validator (2 points)&lt;br /&gt;
#** ''Extra Credit:'' Your code passes ''JSHint'' or ''JSLint'' (+3 bonus points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Site is intuitive to use and navigate (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (15 Points)'''&lt;br /&gt;
#* '''Additional Calendars Features (worth 15 points):''' Develop some additional features for the calendar, a few examples are provided below.&lt;br /&gt;
#**  Users can tag an event with a particular category and enable/disable those tags in the calendar view. (5 points)&lt;br /&gt;
#**  Users can share their calendar with additional users. (5 points)&lt;br /&gt;
#**  Users can create group events that display on multiple users calendars (5 points)&lt;br /&gt;
#*  '''Make sure to save a description of your creative portion, and a link to your server in your README.md file.'''&lt;br /&gt;
''* These points can be earned only if at least 3 other points have been earned in that category.  This is to prevent these points from being &amp;quot;free.&amp;quot;''&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 5]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>James</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_4&amp;diff=2232</id>
		<title>Module 4</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_4&amp;diff=2232"/>
		<updated>2017-01-17T20:13:39Z</updated>

		<summary type="html">&lt;p&gt;James: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
In Module 4, you will learn the fundamentals of Python, a popular scripting language, and Regular Expressions, which give you power in text processing.&lt;br /&gt;
&lt;br /&gt;
This article contains your assignments for Module 4.&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Python]]&lt;br /&gt;
* [[Regular Expressions]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
=== Learn Python and Regular Expressions ===&lt;br /&gt;
&lt;br /&gt;
Up to this point in CSE 330, you have used only one programming language: PHP.  In Module 4, you will learn a new language: Python.  Before starting this assignment, you should look over the [[Python|online textbook article about Python]].  Additionally, you may find it helpful to look over the [[Regular Expressions|online textbook article about Regular Expressions]].&lt;br /&gt;
&lt;br /&gt;
=== Write some Regular Expressions ===&lt;br /&gt;
&lt;br /&gt;
Please write regular expressions that do each the following:&lt;br /&gt;
&lt;br /&gt;
# Match the string &amp;quot;hello world&amp;quot; in a sentence&lt;br /&gt;
# Find all words in an input string that contain a triple vowel&lt;br /&gt;
# Match an input string that is entirely a flight code, of the format AA####, where '''AA''' is a two-letter uppercase airline code, and '''####''' is a three- or four-digit flight number&lt;br /&gt;
Examples:&lt;br /&gt;
   Regex 1:  Programmers will often write ''[[hello world]]'' as their first project with a programming language.&lt;br /&gt;
   Regex 2:  The ''[[gooey]]'' peanut butter and jelly sandwich was a ''[[beauty]]''.&lt;br /&gt;
   Regex 3:  ''[[AA312]]'' (should match)&lt;br /&gt;
             ''[[AA1298]]'' (should match)&lt;br /&gt;
             ''[[NW1234]]'' (should match)&lt;br /&gt;
             ''[[US443]]'' (should match)&lt;br /&gt;
             US31344 (should NOT match)&lt;br /&gt;
            &lt;br /&gt;
&lt;br /&gt;
Save your regexes to a text file.  The TA will test them in regexpal on Demo Day.&lt;br /&gt;
&lt;br /&gt;
=== Baseball Stats Counter ===&lt;br /&gt;
&lt;br /&gt;
The St. Louis Cardinals are the most legendary baseball team in the national league.  In this exercise, you will be creating a Python script that reads box scores from a file and computes the Cardinals' players' batting averages in a particular season.&lt;br /&gt;
&lt;br /&gt;
==== Tips and Instructions ====&lt;br /&gt;
&lt;br /&gt;
* You should write a Python script file to solve this problem.&lt;br /&gt;
* You should use a regular expression to parse players' names, at-bats, hits, and runs from the input file.&lt;br /&gt;
* You may want to create a class to hold and compute information about each player.&lt;br /&gt;
* Your file should take one command-line argument: the path to an input file.  If no path is given, your program should print a usage message.&lt;br /&gt;
&lt;br /&gt;
==== Input ====&lt;br /&gt;
&lt;br /&gt;
Sample input files may be found here: http://classes.engineering.wustl.edu/cse330/content/cardinals/&lt;br /&gt;
&lt;br /&gt;
The top of the file contains a citation, and what follows is an entire season of Cardinals Baseball box scores.  Each game starts with a title; for example:&lt;br /&gt;
&lt;br /&gt;
 === St.Louis Cardinals vs. Chicago Cubs, 1940-04-19 ===&lt;br /&gt;
&lt;br /&gt;
What follows are the performance of each player in that game.  The format of each line is as follows:&lt;br /&gt;
&lt;br /&gt;
 XXX batted # times with # hits and # runs&lt;br /&gt;
&lt;br /&gt;
where '''XXX''' is the player's name (you may assume that the name is unique), and each '''#''' are integers representing the number of &amp;quot;at bats&amp;quot;, the number of &amp;quot;hits&amp;quot;, and the number of &amp;quot;runs&amp;quot;, respectively.&lt;br /&gt;
&lt;br /&gt;
==== Output ====&lt;br /&gt;
&lt;br /&gt;
Your script needs to output all players' batting average across the season.  A player's batting average is that player's total hits divided by that player's total at-bats throughout the entire season.  For example, Johnny Hopp was at bat 149 times in 1940, and he had 41 hits, so his batting average was 0.275.&lt;br /&gt;
&lt;br /&gt;
Each line in the output should have the format:&lt;br /&gt;
&lt;br /&gt;
 XXX: #.###&lt;br /&gt;
&lt;br /&gt;
where '''XXX''' is the player's name, and '''#.###''' is the player's batting average, '''rounded''' (not truncated) to three decimal places.&lt;br /&gt;
&lt;br /&gt;
The players should be sorted by batting average, with the highest batting average on top.  If two players have the exact same batting average (before rounding occurs), the order between those two players is unimportant.&lt;br /&gt;
&lt;br /&gt;
For example, the correct output for the 1940 season is:&lt;br /&gt;
&amp;lt;!-- Jimmy Brown was 0.280 and Ira Hutchinson was 0.125 --&amp;gt;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;text&amp;quot;&amp;gt;&lt;br /&gt;
Pepper Martin: 0.316&lt;br /&gt;
Walker Cooper: 0.316&lt;br /&gt;
Johnny Mize: 0.314&lt;br /&gt;
Ernie Koy: 0.310&lt;br /&gt;
Enos Slaughter: 0.306&lt;br /&gt;
Joe Medwick: 0.304&lt;br /&gt;
Terry Moore: 0.304&lt;br /&gt;
Joe Orengo: 0.286&lt;br /&gt;
Jimmy Brown: 0.280&lt;br /&gt;
Marty Marion: 0.279&lt;br /&gt;
Don Gutteridge: 0.276&lt;br /&gt;
Johnny Hopp: 0.275&lt;br /&gt;
Creepy Crespi: 0.273&lt;br /&gt;
Mickey Owen: 0.265&lt;br /&gt;
Bill DeLancey: 0.250&lt;br /&gt;
Don Padgett: 0.242&lt;br /&gt;
Stu Martin: 0.238&lt;br /&gt;
Eddie Lake: 0.222&lt;br /&gt;
Hal Epps: 0.214&lt;br /&gt;
Lon Warneke: 0.209&lt;br /&gt;
Harry Walker: 0.185&lt;br /&gt;
Max Lanier: 0.179&lt;br /&gt;
Bill McGee: 0.178&lt;br /&gt;
Carl Doyle: 0.174&lt;br /&gt;
Mort Cooper: 0.157&lt;br /&gt;
Clyde Shoun: 0.145&lt;br /&gt;
Carden Gillenwater: 0.130&lt;br /&gt;
Bob Bowman: 0.067&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 50 points total.&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. ''' &lt;br /&gt;
&lt;br /&gt;
Upload your baseball code, a file with your Regular expressions, and a screenshot of your python output onto bitbucket, and we will use the time-stamps to determine late-penalties.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-201343)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
# '''Regular Expressions (15 Points):'''&lt;br /&gt;
#* Regular Expression 1 Correct (5 points)&lt;br /&gt;
#* Regular Expression 2 Correct (5 points)&lt;br /&gt;
#* Regular Expression 3 Correct (5 points)&lt;br /&gt;
# '''Baseball Stats Counter (35 Points):'''&lt;br /&gt;
#* Solution is written entirely in Python, except with permission from the instructor (8 points)&lt;br /&gt;
#* Correct usage of a regular expression to parse each line of the input file (8 points)&lt;br /&gt;
#* Script prints a usage message if a command line argument is not present (4 points)&lt;br /&gt;
#* Output is correct for the 1940 test case (15 points)&lt;br /&gt;
#*: ''This includes sorting and rounding.''&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 4]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>James</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_3&amp;diff=2231</id>
		<title>Module 3</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_3&amp;diff=2231"/>
		<updated>2017-01-17T20:12:16Z</updated>

		<summary type="html">&lt;p&gt;James: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__&lt;br /&gt;
In Module 3, you will learn about MySQL, a web application database.&lt;br /&gt;
&lt;br /&gt;
This article contains your assignments for Module 3.&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Introduction to MySQL]]&lt;br /&gt;
* [[MySQL Schema and State]]&lt;br /&gt;
* [[PHP and MySQL]]&lt;br /&gt;
* [[Web Application Security, Part 2]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
You will create a simple grades database containing four tables.&lt;br /&gt;
&lt;br /&gt;
'''IMPORTANT:''' The individual assignment is to be done by writing queries by hand.  (You can use phpMyAdmin to run the queries, but '''do not let phpMyAdmin write your queries for you!''')  Writing your own queries gives you a greater understanding of the underlying mechanisms and databases in general.  Additionally, having SQL knowledge and experience is a very marketable trait.&lt;br /&gt;
&lt;br /&gt;
=== Install MySQL and phpMyAdmin ===&lt;br /&gt;
&lt;br /&gt;
Before you start, '''you need to install MySQL''' on your EC2 instance.  You may also install phpMyAdmin, a web frontend to MySQL, if you choose to do so.&lt;br /&gt;
&lt;br /&gt;
=== Set Up a Database ===&lt;br /&gt;
&lt;br /&gt;
You may find the following article to be very helpful: [[Introduction to MySQL]]&lt;br /&gt;
&lt;br /&gt;
# Create a database named '''wustl''' &lt;br /&gt;
# Create a user named '''wustl_inst''' and give them the password '''wustl_pass'''&lt;br /&gt;
&lt;br /&gt;
=== Create Tables ===&lt;br /&gt;
&lt;br /&gt;
You may find the following article to be very helpful: [[MySQL Schema and State]]&lt;br /&gt;
&lt;br /&gt;
When creating tables, keep the following items in mind:&lt;br /&gt;
&lt;br /&gt;
* You should create all tables such that they use the InnoDB storage engine, since we wish to make use of its support of foreign keys. In other database engines, foreign key constraints are not enforced.  (If you mess up, you can use ALTER TABLE to change the storage engine.)&lt;br /&gt;
* Where it is appropriate, you should take advantage of the ability to define fields NOT NULL so that you do not inadvertently insert incomplete data for a row.&lt;br /&gt;
&lt;br /&gt;
Create the following tables:&lt;br /&gt;
&lt;br /&gt;
# Create a table named '''students''' with the following fields:&lt;br /&gt;
#* '''id''' of an appropriately-sized unsigned integer type (we will never need to process more than a million students)&lt;br /&gt;
#* '''first_name''' of type '''VARCHAR(50)'''&lt;br /&gt;
#* '''last_name''' of type '''VARCHAR(50)'''&lt;br /&gt;
#* '''email_address''' of type '''VARCHAR(50)'''&lt;br /&gt;
#: The primary key should be on the '''id''' field.&lt;br /&gt;
# Create a table named '''departments''' with the following fields:&lt;br /&gt;
#* '''school_code''' of type '''ENUM''' (e.g. &amp;quot;L&amp;quot; for ArtSci and &amp;quot;E&amp;quot; for Engineering).  The options are as follows:&lt;br /&gt;
#*: 'L', 'B', 'A', 'F', 'E', 'T', 'I', 'W', 'S', 'U', 'M'&lt;br /&gt;
#* '''dept_id''' of an appropriately-sized unsigned integer type (in the foreseeable future there will never be more than 200 departments in a school)&lt;br /&gt;
#* '''abbreviation''' of type '''VARCHAR(9)''' (e.g. CSE, ChemE, etc)&lt;br /&gt;
#* '''dept_name''' of type '''VARCHAR(200)''' (e.g. Computer Science and Engineering)&lt;br /&gt;
#: The primary key should be on two fields: '''school_code''' and '''dept_id'''&lt;br /&gt;
#: '''Note:''' Why not just use the department ID for the primary key? The ID numbers are sometimes reused across schools. For instance, department 33 in The College of Arts and Sciences is Psychology while department 33 in The School of Engineering and Applied Sciences is Energy, Environmental and Chemical Engineering. Thus we must also include the school code to differentiate them  such that the record for  E33 is distinct from that of L33.&lt;br /&gt;
# Create a table named '''courses''' with the following fields:&lt;br /&gt;
#* '''school_code''' of type '''ENUM'''&lt;br /&gt;
#*: This should have the same letters in the same order as the '''school_code''' '''ENUM''' field in the '''departments''' table.&lt;br /&gt;
#* '''dept_id''' of the same size of integer as in the '''departments''' table&lt;br /&gt;
#* '''course_code''' of type '''CHAR(5)''' (this will hold course codes; e.g., '330S', '131', '2960')&lt;br /&gt;
#* '''name''' of type '''VARCHAR(150)'''&lt;br /&gt;
#: The appropriate fields in this table should make a foreign key reference to the corresponding fields in '''department'''.&lt;br /&gt;
#: In addition, it is up to you to determine the field(s) for the primary key.&lt;br /&gt;
#: '''Note:''' If you are unsure which fields to make the foreign keys and feel the need to beg your friends or the TAs to give you the answer, bang your head on your desk whilst repeating &amp;quot;I WILL EXERCISE REASON AND COMMON SENSE AND I WILL CURTAIL MY DESIRE TO BLINDLY FOLLOW DIRECTIONS&amp;quot;&lt;br /&gt;
#: ''Disclaimer: don't actually bang your head on your desk, the resulting head trauma may in fact make it harder for you to determine which fields should have associated foreign keys.''&lt;br /&gt;
# Create a table named '''grades''' with the following fields:&lt;br /&gt;
#* '''pk_grade_ID''' of an appropriately-sized unsigned integer type (should be larger than the one you chose for the '''students''' table)&lt;br /&gt;
#*: You should declare this field to be '''auto_increment''' and make it the primary key.&lt;br /&gt;
#*: This is called a ''surrogate key'' as opposed to a ''natural key'' because it doesn't arise &amp;quot;naturally&amp;quot; from the data; that is to say that it is not derived from application data. The use of surrogate keys vs. natural keys is a polemic issue amongst database designers.  For a decently unbiased take on the issue, see this page: http://www.agiledata.org/essays/keys.html#Comparison&lt;br /&gt;
#*: '''Food for thought:''' Aside from simply exposing you to the concept, can you think of any reasons why a surrogate key might be preferable for this table?  Alternatively, what attributes, if any, could you use as a natural key, and what might be the drawbacks of doing so?&lt;br /&gt;
#* '''student_id''' of the same integer (unsigned) type that you chose in the '''students''' table&lt;br /&gt;
#* '''grade''' of type '''decimal(5,2)'''&lt;br /&gt;
#* '''school_code''' of type '''ENUM'''&lt;br /&gt;
#*: Can you guess what entries to use for the enum?&lt;br /&gt;
#* '''dept_id''' of the same integer type that you've used for this field in other tables&lt;br /&gt;
#* '''course_code''' of the same type you chose for the course code in the '''courses''' table&lt;br /&gt;
#: The '''grades''' table should have foreign keys to both the '''students''' table and the '''courses''' table.&lt;br /&gt;
&lt;br /&gt;
=== Populate Tables ===&lt;br /&gt;
&lt;br /&gt;
Now, populate the tables by downloading the text files given below and loading them into the appropriate tables.&lt;br /&gt;
&lt;br /&gt;
'''Note:''' Do not insert all the values manually; instead, use the MySQL's ability to load in data from text files.&lt;br /&gt;
&lt;br /&gt;
You may find the following article to be very helpful: [[MySQL Schema and State]]&lt;br /&gt;
&lt;br /&gt;
The files containing the data are:&lt;br /&gt;
* students: http://classes.engineering.wustl.edu/cse330/content/students_data.txt&lt;br /&gt;
* courses: http://classes.engineering.wustl.edu/cse330/content/courses.txt&lt;br /&gt;
* departments: http://classes.engineering.wustl.edu/cse330/content/departments_data.txt&lt;br /&gt;
* grades: http://classes.engineering.wustl.edu/cse330/content/grades_data.txt&lt;br /&gt;
&lt;br /&gt;
=== Insert More Data ===&lt;br /&gt;
&lt;br /&gt;
Insert the following data into the tables that you have created and populated:&lt;br /&gt;
&lt;br /&gt;
# Insert an entry for CSE 330S&lt;br /&gt;
#: ''If you don't know CSE's department code, how can you find out using the tables in the database?''&lt;br /&gt;
# Insert the grades given for the students named below.  You may choose to make the entries for whichever classes you like, with the one condition that all of the students must have a grade for CSE 330S (who wouldn't want to take that class: I hear the professor and TAs are amazing!)&lt;br /&gt;
#* '''Ben Harper'''&lt;br /&gt;
#** E-mail: '''bharper@ffym.com'''&lt;br /&gt;
#** Student ID: '''88'''&lt;br /&gt;
#** Grades:&lt;br /&gt;
#*** 35.5 (CSE 330S grade)&lt;br /&gt;
#*** 0&lt;br /&gt;
#*** 95&lt;br /&gt;
#* '''Matt Freeman'''&lt;br /&gt;
#** E-mail: '''mfreeman@kickinbassist.net'''&lt;br /&gt;
#** Student ID: '''202'''&lt;br /&gt;
#** Grades:&lt;br /&gt;
#*** 100 (CSE 330S grade)&lt;br /&gt;
#*** 90.5&lt;br /&gt;
#*** 94.8&lt;br /&gt;
#* '''Marc Roberge'''&lt;br /&gt;
#** E-mail: '''mroberge@ofarevolution.us'''&lt;br /&gt;
#** Student ID: '''115'''&lt;br /&gt;
#** Grades:&lt;br /&gt;
#*** 75 (CSE 330S grade)&lt;br /&gt;
#*** 37&lt;br /&gt;
#*** 45.5&lt;br /&gt;
#: You may choose any 3 classes you'd like for them to be enrolled in, with at least one class, &amp;quot;CSE 330S&amp;quot;, in which they are all enrolled.&lt;br /&gt;
&lt;br /&gt;
=== Querying Your Database ===&lt;br /&gt;
&lt;br /&gt;
Now that you have a fully-functional, populated database, let's do some queries on it!&lt;br /&gt;
&lt;br /&gt;
Please take a screenshot of running the following '''select''' queries and show them to a TA (be sure to include your query command and the response:&lt;br /&gt;
&lt;br /&gt;
# Select the entire grades table.&lt;br /&gt;
# Select all fields describing the courses offered in the school of arts and sciences (school code L).&lt;br /&gt;
# The names, student IDs, and grades of the students who are in CSE330S.&lt;br /&gt;
#: '''Note:''' This query should involve joins.  You don't need to use any aggregation functions.&lt;br /&gt;
# The names, e-mails, and average grades of any student with an average below 50 so that the dean can send them an email notification that they are now on academic probation.&lt;br /&gt;
#: ''You should be able to do this in only one query, without making any temporary tables.  You will need to use aggregation functions and the '''having''' keyword.''&lt;br /&gt;
# An individual report card for Jack Johnson, consisting of his student ID, e-mail address, and average grade.&lt;br /&gt;
#: ''Again, you should be able to do this in just one query, using the correct combination of aggregation functions and joins.''&lt;br /&gt;
#: '''Note:''' Your query must look for students with the name Jack Johnson instead of hard-coding the student ID.&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
You will work in pairs on this project.  You may work with the same partner from Module 2, or change to someone else.&lt;br /&gt;
&lt;br /&gt;
'''Important Reminder:''' frequently commit your work to your Git repository as a backup!&lt;br /&gt;
&lt;br /&gt;
=== Simple News Web Site ===&lt;br /&gt;
&lt;br /&gt;
'''Examples:'''&lt;br /&gt;
* http://digg.com/&lt;br /&gt;
* http://slashdot.org/&lt;br /&gt;
&lt;br /&gt;
You should use '''PHP''' unless you get permission to use another web technology from the instructor.  You may also use phpMyAdmin to help set up databases.&lt;br /&gt;
&lt;br /&gt;
You may find this wiki article helpful: [[PHP and MySQL]]&lt;br /&gt;
&lt;br /&gt;
==== Requirements ====&lt;br /&gt;
&lt;br /&gt;
* Users can register for accounts and then log in to the website.&lt;br /&gt;
* Accounts should have both a username and a ''secure'' password.  '''NEVER store plaintext passwords in a database!'''&lt;br /&gt;
*: For more information on password security, refer to [[Web Application Security, Part 2#Password Security|the Web Application Security guide]].&lt;br /&gt;
* Registered users can submit story commentary.&lt;br /&gt;
*: A link can be associated with each story, and they should be stored in a separate database field from the story&lt;br /&gt;
* Registered users can comment on any story.&lt;br /&gt;
* Unregistered users can only view stories and comments.&lt;br /&gt;
* Registered users can edit and delete their stories and comments.&lt;br /&gt;
* All data must be kept in a MySQL database (user information, stories, comments, and links).&lt;br /&gt;
* Creative Portion&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
No application is finished until much thought is put into web security and best practice.  Throughout this course, we heavily emphasize the dogma of [http://coderesponsibly.org/ responsible] coding.&lt;br /&gt;
&lt;br /&gt;
Read this week's Web Application Security guide: [[Web Application Security, Part 2]].  In particular, your project needs to:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to be secure from SQL injection attacks'''. If you are using prepared queries, you should already be safe on this front.&lt;br /&gt;
* '''Your passwords need to be securely salted''' to prevent rainbow table attacks.&lt;br /&gt;
* '''You should pass tokens in forms''' to prevent CSRF attacks.&lt;br /&gt;
* '''You should check all preconditions on the server side''' to prevent Abuse of Functionality attacks.&lt;br /&gt;
&lt;br /&gt;
You shouldn't forget the practices you learned last week:&lt;br /&gt;
&lt;br /&gt;
* '''Your page should validate''' with no errors through the W3C validator.&lt;br /&gt;
* '''Filter Input and Escape Output''', but not the other way around.&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. ''' &lt;br /&gt;
&lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID1-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-201343-314450) &lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, or share it with cse330, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
________&lt;br /&gt;
&lt;br /&gt;
# '''MySQL Queries (25 Points):'''&lt;br /&gt;
#* A MySQL server is running on your instance (2 points)&lt;br /&gt;
#* Tables fields, including data types, are correct (4 points)&lt;br /&gt;
#* Foreign keys are correct (4 points)&lt;br /&gt;
#* The output of each of the five queries is correct (3 points each)&lt;br /&gt;
# '''News Site (60 Points):'''&lt;br /&gt;
#* '''''User Management (20 Points):'''''&lt;br /&gt;
#** A session is created when a user logs in (3 points)&lt;br /&gt;
#** New users can register (3 points)&lt;br /&gt;
#** Passwords are hashed using salted one-way encryption (3 points)&lt;br /&gt;
#** Users can log out (3 points)&lt;br /&gt;
#** A user can edit and delete his/her own stories and comments but cannot edit or delete the stories or comments of another user (8 points)&lt;br /&gt;
#* '''''Story and Comment Management (20 Points):'''''&lt;br /&gt;
#** Relational database is configured with correct data types and foreign keys (4 points)&lt;br /&gt;
#** Stories can be posted (3 points)&lt;br /&gt;
#** A link can be associated with each story, and they should be stored in a separate database field from the story (3 points)&lt;br /&gt;
#** Comments can be posted in association with a story (4 points)&lt;br /&gt;
#** Stories can be edited and deleted (3 points)&lt;br /&gt;
#** Comments can be edited and deleted (3 points)&lt;br /&gt;
#**: ''Note: Although there are only 6 points allocated for editing/deleting in this section, there are 8 more points at stake in the User Management section that cannot be earned unless editing/deleting is implemented.  Implementing editing but not deleting, or vice-versa, will result in earning half the points.''&lt;br /&gt;
#* '''''Best Practices (15 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (3 points)&lt;br /&gt;
#** Safe from SQL Injection attacks (2 points)&lt;br /&gt;
#** Site follows the FIEO philosophy (3 points)&lt;br /&gt;
#** All pages pass the W3C validator (2 points)&lt;br /&gt;
#** CSRF tokens are passed when creating, editing, and deleting comments and stories (5 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Site is intuitive to use and navigate (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (15 Points)''' (see below)&lt;br /&gt;
#* '''''Make sure you have a README.md file in your group repo with the following:'''''&lt;br /&gt;
#** Names and Student IDs of all the group members&lt;br /&gt;
#** A link to your homepage of the site&lt;br /&gt;
#** A brief description of what you did for your creative portion&lt;br /&gt;
#** Any additional login details needed for the TA&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 3]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>James</name></author>
		
	</entry>
	<entry>
		<id>http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2230</id>
		<title>Module 2</title>
		<link rel="alternate" type="text/html" href="http://classes.engineering.wustl.edu/cse330/index.php?title=Module_2&amp;diff=2230"/>
		<updated>2017-01-17T20:10:07Z</updated>

		<summary type="html">&lt;p&gt;James: /* Grading */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;__NOTOC__ &lt;br /&gt;
Module 2 introduces you to Linux, a command-line environment, the Apache web server, and PHP.  You will create and configure your own cloud instance, install Apache and related software, and then form groups to make a simple file sharing site.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;'''DO NOT WAIT UNTIL THE LAST MINUTE TO START ON THIS (or any) MODULE!'''  The most common reason students perform poorly in this class is procrastination.  You have been warned.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reading ==&lt;br /&gt;
&lt;br /&gt;
The following articles on the online class wiki textbook contain information that will help you complete the assignments.&lt;br /&gt;
&lt;br /&gt;
* [[Linux]]&lt;br /&gt;
* [[Bash]]&lt;br /&gt;
* [[Amazon Web Services]]&lt;br /&gt;
* [[SSH]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
* [[PHP]]&lt;br /&gt;
* [[Workflow]]&lt;br /&gt;
* [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
== Individual Assignments ==&lt;br /&gt;
&lt;br /&gt;
{{RequiredInstructions|content=&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;color:red&amp;quot;&amp;gt;There are a lot of wiki pages that you need to read in order to complete the individual portion of Module 2.  The wiki pages contain an assortment of required steps, optional steps, and information.  To make things easier, we have highlighted the ''required steps'' with a red bar, like you see on the left of this message.  Do not skip anything marked with a red bar, or else you will not have a perfectly configured instance.&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
=== Learn About Linux ===&lt;br /&gt;
&lt;br /&gt;
Linux is an open-source operating system based on UNIX. Linux is highly versatile and is used in a wide range of applications.&lt;br /&gt;
&lt;br /&gt;
If you are not a Linux guru, read the Linux guide to get started: [[Linux]]&lt;br /&gt;
&lt;br /&gt;
=== Install Cygwin: Windows Users Only ===&lt;br /&gt;
&lt;br /&gt;
You will need Cygwin in order to log into and configure your EC2 instance.  Cygwin is already installed on the CEC machines.  Instructions for installing Cygwin on your personal machine are located in [[Workflow#Cygwin|the Workflow guide]].&lt;br /&gt;
&lt;br /&gt;
Mac OS X users should located the &amp;quot;Terminal&amp;quot; application, which is installed by default; you will need this in the coming steps.&lt;br /&gt;
&lt;br /&gt;
=== Create an AWS EC2 Instance ===&lt;br /&gt;
&lt;br /&gt;
Once you understand [[Linux]], you need to set up your Amazon EC2 Instance.  Use the AWS article to guide you through the process: [[Amazon Web Services]]&lt;br /&gt;
&lt;br /&gt;
=== Configure SSH ===&lt;br /&gt;
&lt;br /&gt;
Follow the instructions in [[SSH#SSH Configuration|the SSH guide]] to do the following:&lt;br /&gt;
&lt;br /&gt;
# Create your own SSH key pair&lt;br /&gt;
# Log in as the default user to your EC2 instance&lt;br /&gt;
# Create a new user&lt;br /&gt;
# Give the new user your SSH public key&lt;br /&gt;
&lt;br /&gt;
From now on, when you need to log into your EC2 instance as an administrator, just pop up a terminal and run:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
$ ssh your-username@ec2-xx-xx-xx-xx.compute-1.amazonaws.com&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Install Essential Packages ===&lt;br /&gt;
&lt;br /&gt;
Recall that software installation in Linux instances is usually handled through '''apt''' (Debian) or '''yum''' (RHEL).  For more information, refer to [[Linux#Repository-Based Package Managers|the Linux guide]].&lt;br /&gt;
&lt;br /&gt;
To make sure everything is working properly, '''install your first package(s) according to the ''Essential Packages'' subsection in the Linux guide.'''&lt;br /&gt;
&lt;br /&gt;
=== Set the Timezone ===&lt;br /&gt;
&lt;br /&gt;
'''Set your server to use US Central time (America/Chicago).'''  Instructions are in the Linux guide: [[Linux#Synchronizing Date and Time]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up the Apache Web Server ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install the Apache web server on your EC2 instance'''.  Refer to [[Apache|the Apache guide]].&lt;br /&gt;
&lt;br /&gt;
In order for your web server to be accessible, you need to '''open up Port 80 on your EC2 instance'''.  Instructions are in the AWS guide: [[Amazon Web Services#Enabling Web Access to your EC2 Instance]]&lt;br /&gt;
&lt;br /&gt;
'''Enable the UserDir module in Apache.'''  Instructions are in the Apache guide: [[Apache#The UserDir Module]]&lt;br /&gt;
&lt;br /&gt;
=== Install PHP ===&lt;br /&gt;
&lt;br /&gt;
You need to '''install PHP on your EC2 server'''.  Instructions are at the top of the PHP guide: [[PHP]]&lt;br /&gt;
&lt;br /&gt;
You need to '''configure PHP to show errors'''.  Instructions are immediately below installation in the PHP guide.&lt;br /&gt;
&lt;br /&gt;
=== Learn the PHP Language ===&lt;br /&gt;
&lt;br /&gt;
Before you can continue, you will need to make yourself acquainted with PHP language components.  Read the PHP guide for an overview: [[PHP#PHP Language Components]]&lt;br /&gt;
&lt;br /&gt;
=== Set Up your Workspace ===&lt;br /&gt;
&lt;br /&gt;
You are now ready to set up the workspace that you will be using for the rest of the semester.  Follow the instructions in [[Workflow]] to:&lt;br /&gt;
&lt;br /&gt;
# Make an account on Bitbucket&lt;br /&gt;
# Make a repository for your individual work for CSE 330&lt;br /&gt;
# Install SourceTree&lt;br /&gt;
# '''Windows only:''' Set up Pageant so that SourceTree can conect to Bitbucket&lt;br /&gt;
# Clone your CSE 330 repo from Bitbucket&lt;br /&gt;
# Install Komodo Edit&lt;br /&gt;
# Create a Komodo Edit Project inside of your Git repository&lt;br /&gt;
# Add the ''*.komodoproject'' file to ''.gitignore''&lt;br /&gt;
# Install FileZilla&lt;br /&gt;
# Connect FileZilla to your remote instance&lt;br /&gt;
&lt;br /&gt;
=== Calculator ===&lt;br /&gt;
&lt;br /&gt;
'''Make a calculator using PHP and an HTML form.'''  The form should have two inputs.  The form should submit a GET request either back to the same page or to a different results page.  The calculator should support addition, subtraction, multiplication, and division by means of a radio button group on the page.  (Consider edge cases!)&lt;br /&gt;
&lt;br /&gt;
== Group Project ==&lt;br /&gt;
&lt;br /&gt;
You will work in pairs (that means you and one other person) on this project.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;span style=&amp;quot;font-size:1.3em; line-height:1.2em; color:blue;&amp;quot;&amp;gt;In this module, and all future modules, the group portion builds off of material you learn in the individual portion.  You should therefore complete the individual portions prior to working on the group portions.  (Trust us: it will make your life easier!)&amp;lt;/span&amp;gt;&lt;br /&gt;
&lt;br /&gt;
'''Important Reminder:''' frequently commit your work to your repository as a backup!&lt;br /&gt;
&lt;br /&gt;
=== Simple File Sharing Site ===&lt;br /&gt;
&lt;br /&gt;
You will be making a simple file sharing site that supports uploading, viewing, and deleting files associated with various users.  Details:&lt;br /&gt;
&lt;br /&gt;
* You should have a file named '''users.txt''' stored in a secure place on your filesystem.  It should have at least three usernames, with one username per line.&lt;br /&gt;
*: Passwords add an extra layer of complexity (encryption) that we will cover in Module 3.  You will not earn credit for implementing passwords as your creative portion for this module.&lt;br /&gt;
* Users of the file sharing site should be able to enter their username and then log in.&lt;br /&gt;
*: You may implement logins using session variables, or you may implement them using a GET parameter that is passed between pages.  You will need to always use sessions starting in Module 3.&lt;br /&gt;
* Users should see a list of all files associated with their username after the log in.&lt;br /&gt;
* Users should be able to view, upload, and delete files associated with their username.&lt;br /&gt;
* The URI should NOT reveal the internal file structure of your web site.&lt;br /&gt;
** Example of what not to do:  http://www.example.com/download.php?file=/home/paul/file.txt&lt;br /&gt;
** Another bad example:  http://www.example.com/~user/file.txt&lt;br /&gt;
** Good example: http://www.example.com/view.php?user=music&amp;amp;name=file.txt&lt;br /&gt;
*: In general, don't reveal any internal information about the site.&lt;br /&gt;
*: '''Food for thought:''' Given that Apache processes (with the exception of the main process) do not run as root, but rather as the user apache, how can you allow both your user account and the php scripts to read and write the &lt;br /&gt;
*:necessary files?&lt;br /&gt;
*:: ''Hint:'' You shouldn't be storing the user-uploaded files in public_html (that is only the place for your own web-page files), &lt;br /&gt;
*::''Hint number 2:''  you will need to use chown to change permissions to let user apache (or www-data for Ubuntu) have permissions on the user-files (that '''are not''' in the public_html folder). If you don't know what this does or how to do this, look at the [[Apache]] page&lt;br /&gt;
* You should customize your file sharing site by implementing an additional feature or two as part of the '''creative portion'''.&lt;br /&gt;
&lt;br /&gt;
You will probably find the PHP guide on this wiki to be helpful: [[PHP#Other PHP Tips]]&lt;br /&gt;
&lt;br /&gt;
=== Web Security and Validation ===&lt;br /&gt;
&lt;br /&gt;
Your project needs to demonstrate that thought was put into web security and best practice.  For more information, see this week's Web Application Security guide: [[Web Application Security, Part 1]]&lt;br /&gt;
&lt;br /&gt;
In particular:&lt;br /&gt;
&lt;br /&gt;
* '''Your application needs to follow the conventions of FIEO (Filter Input and Escape Output)'''.  Things you should filter include file names, usernames, and so on.&lt;br /&gt;
* '''Your project must pass the W3C Validator with no errors'''.  For more information, see the HTML and CSS guide: [[HTML and CSS#Validation]]&lt;br /&gt;
&lt;br /&gt;
== Grading ==&lt;br /&gt;
&lt;br /&gt;
We will be grading the following aspects of your work.  There are 100 points total.&lt;br /&gt;
&lt;br /&gt;
'''Assignments must be committed to Bitbucket by the end of class on the due date (commit early and often). Failing to commit by the end of class on the due date will result in a 0. &lt;br /&gt;
#''You must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-201343)&lt;br /&gt;
#''For the group project, you must save your repo as:''&lt;br /&gt;
#*&amp;quot;&amp;lt;Season&amp;gt;&amp;lt;year&amp;gt;-Module&amp;lt;#&amp;gt;-StudentID1-StudentID2&amp;quot; &lt;br /&gt;
#*(ie. Spring2025-Module3-201343-312532) &lt;br /&gt;
#* OR, if you are working alone, put both your individual and group portions in your individual repo&lt;br /&gt;
&lt;br /&gt;
'''If you do not name your repo correctly, or share it with cse330, the TA's are not responsible for grading your assignment. If we cannot find it, you will receive a zero.'''&lt;br /&gt;
&lt;br /&gt;
_____________&lt;br /&gt;
&lt;br /&gt;
# '''Cloud Instance and Web Server (30 Points):'''&lt;br /&gt;
#* You can SSH into your instance using your own custom username and SSH key (15 points)&lt;br /&gt;
#* Your custom username is able to perform SUDO commands (5 points)&lt;br /&gt;
#* The time zone is correct on your instance (5 points)&lt;br /&gt;
#* The UserDir Apache module is working (5 points)&lt;br /&gt;
# '''PHP Calculator (15 Points):'''&lt;br /&gt;
#* The calculator is able to perform all four functions (2 points each, 8 points in total)&lt;br /&gt;
#* Each function is given as a radio button choice (4 points)&lt;br /&gt;
#* The calculator page passes the W3C HTML validator (3 points)&lt;br /&gt;
# '''File Sharing Site (40 Points):'''&lt;br /&gt;
#* '''''File Management (25 Points):'''''&lt;br /&gt;
#** Users should not be able to see any files until they enter a username and log in (4 points)&lt;br /&gt;
#**: ''Remember that users.txt should be stored in a secure location on your filesystem.  That is, '''you should not be able to type any URL into your browser and see the raw users.txt file!'''''&lt;br /&gt;
#** Users can see a list of all files they have uploaded (4 points)&lt;br /&gt;
#** Users can open files they have previously uploaded (5 points)&lt;br /&gt;
#**: ''Note: Users should be able to open not only plain text files but also other file formats: images, spreadsheets, etc.''&lt;br /&gt;
#** Users can upload files (4 points)&lt;br /&gt;
#**: ''Note: Like users.txt, uploaded files should be stored in a secure location on your filesystem.  That is, '''do not keep your uploads directory underneath a directory served by Apache!'''''&lt;br /&gt;
#** Users can delete files.  If a file is &amp;quot;deleted&amp;quot;, it should actually be removed from the filesystem (4 points)&lt;br /&gt;
#** The directory structure is hidden (2 points)&lt;br /&gt;
#** Users can log out (2 points)&lt;br /&gt;
#**: ''Note: If using session variables, you must ''actually'' log out the user by destroying their session; i.e., don't just redirect them to the login screen.''&lt;br /&gt;
#* '''''Best Practices (10 Points):'''''&lt;br /&gt;
#** Code is well formatted and easy to read, with proper commenting (4 points)&lt;br /&gt;
#** The site follows the FIEO philosophy (3 points)&lt;br /&gt;
#** All pages pass the W3C validator (3 points)&lt;br /&gt;
#* '''''Usability (5 Points):'''''&lt;br /&gt;
#** Site is intuitive to use and navigate (4 points)&lt;br /&gt;
#** Site is visually appealing (1 point)&lt;br /&gt;
# '''Creative Portion (15 Points)''' (see below)&lt;br /&gt;
#* '''''Make sure you have a README.md file in your group repo with the following:'''''&lt;br /&gt;
#** An .md file is a plain text file called a markdown file  [https://guides.github.com/features/mastering-markdown/ ] .  &lt;br /&gt;
#***The contents of your README.md file are shown on your repo, making it easier for us to grade&lt;br /&gt;
#*** You may style the page with bolding, hyperlings, images, block quotes and lists&lt;br /&gt;
#*** [http://dillinger.io/ This online markdown editor] makes it easy to learn this format  &lt;br /&gt;
#** Names and Student IDs of all the group members&lt;br /&gt;
#** A link to the front page of your site&lt;br /&gt;
#** A brief description of what you did for your creative portion&lt;br /&gt;
#** Any additional login details needed for the TA&lt;br /&gt;
&lt;br /&gt;
=== Creative Portion ===&lt;br /&gt;
&lt;br /&gt;
This module, and all future modules, will require that you invest some time into creating additional features for your group project.  Plan to invest at least 60 minutes of your time into the creative portion.&lt;br /&gt;
&lt;br /&gt;
* The creative portion is an opportunity for you to learn material of your own interest.&lt;br /&gt;
* You will not earn credit for a creative-portion feature that simply rehashes something you've already done in a previous module.&lt;br /&gt;
&lt;br /&gt;
If you need ideas for a creative portion, or if you want to know whether or not your creative portion idea is &amp;quot;hard enough&amp;quot;, ask a TA.&lt;br /&gt;
&lt;br /&gt;
[[Category:Module 2]]&lt;br /&gt;
[[Category:Modules]]&lt;/div&gt;</summary>
		<author><name>James</name></author>
		
	</entry>
</feed>