- Everything in your filesystem is either a file or a directory (a container for files)
- Your file system is organized as a tree structure
- There is a root element
/(AKA the root directory)
- There is a root element
- Hidden files start with a
. - Working with files and directories
pwdPrint working directorymkdirCreate a directorycdMove to a specific directorycd ..Go to the parent directorylsList filestouchCreates an empty filecatShow the contents of a filermDelete files or directories- For directories we'll add the flag
-r(recursive)rm -r directoryIt will work if the directory is emptyrm -rf directoryIf the directory is not empty, ie, it contains files or other directories, we'll need the flag-f(force)
- It needs the recursive flag, because we need to repeat the same operation but for the files and directories within the current directory. Recursion is a type of repetition
- For directories we'll add the flag
- Git workflow
git statusList the current changesgit add filenameAdd a single filegit add .This adds everything in the current directory, but deleted filesgit add -AThis adds everything, even ignored files
git commitSave your changes to git. You'll need to include a message- The default editor is vim
- Press
ito start typing - Once your done, press
esc - To quit the editor press
:wq
- Press
- The default editor is vim
git commit -m "Add examples for HTML forms"Write the message using the-mflaggit commit --amend -m "Fixed message"Fix a previous commit, with a new messagegit logTo see a list with all the commits, including your most recent onegit push origin masterSend your changes to Github
More commands
git fetchGit download. Downloads changes from the remote without aplying them to mty local repogit stashSaves Work in Progress, is similar to commit (temporary save)git stash listShows all the code tha has been stashed
- HTML is markup language. It describes the structure of a document
- The main component of this language is an element
- There's 3 types of elements
- Block level ->
div,p,h1,h6 - Inline elements ->
strong,em,span - Void elements ->
br,meta,hr
- Block level ->
- The parts of an element are
- Tags (
<tag></tag>)- Opening
- Closing (void elements do not have it)
- Attributes (
attribute="value")- They represent properties of the element
- Some are required (
srcin animg), some are optional (class) - Some do not require a value, since it would be redundant (
disabled,readonly)
- Tags (
- Elements are containers
- Elements can have
- no content (empty)
- more elements (children)
- or text (text nodes)
- Elements can have
- Rules
- block within block (valid)
- inline within inline (valid)
- inline within block (valid)
- Some void elements are block elements (
br,hr) - block within inline (invalid)
- A document can be a
- well-formed document
- Have a correct syntax
- mal-formed documents
- Have incorrect syntax. For instance, a non-void element without a closing tag
- invalid document
- It has correct syntax, but does not follow the rules defined by the doctype.
It uses a non-existing tag (
<bananas></bananas>)
- It has correct syntax, but does not follow the rules defined by the doctype.
It uses a non-existing tag (
- valid document
- It has correct syntax
- It follows the rules defined by the doctype
- well-formed document
- What's the HTTP protocol?
- It defines the rules to exchange messages in the Internet
- Communication occurs between a
clientand aserver - They exchange messages
- The client sends a
request - The server returns a
response
- The client sends a
- Types of messages
- Questions
- Commands
- HTTP verbs are used to determine the type of the message
GETrequests are questions (Could you play this song?)POSTrequests are commands (Pay the pizza I ordered)- There are more:
PUT,DELETE,PATCH
- Parts of a message
- Headers
- Meta-information (configuration)
- Status code: 200 OK, 404 Not found, 500 Server error
- Content type: image, audio, video, text, html, pdf
- Meta-information (configuration)
- Body
- The real content
- Headers
- The default method (HTTP verb) for forms is
get - The default type for
inputistext - The default type for
buttonissubmit
- Depending on the method the information is sent to the server within
- The request body if it's a post request
- The request headers if it's a get request (in the query string)
- In any case the format used is the same
name1=value1&name2=value2....
- If you want to send a pre-populated value, then
- for
checkbox,radio, add thecheckedattribute - for
select, add theselectedattribute - for
input, use thevalueattribute
- for
- Inputs of type
checkboxandradioare not sent to server if none is checked - If a form element is
disabledthen is not sent to the server either - If a form element is
readonlyit is sent to the server anyway - A form element without a
nameis not sent to the server
- The unit of work in CSS is a rule
- One or several selectors.
- Declarations
- properties and values
selector { property: value; }
- Types of selectors
- Elements, classes, ids, pseudo-selector
- Combinations of them
- There are 3 ways to include CSS in a page
- Inline. Using the
styleattribute - Embedded. Using the
styleelement - External. Using the
linkelement pointing to an external.cssfile
- Inline. Using the
- Types of positioning
staticis the default positioningabsoluteandrelativepositioning. Mostly used for imagesfixed. Mostly used in main navigation menusfloat. Is used mostly to create columns
- There's 3 main font families
- Serif
- Sans serif
- Monospace
- How to use Google fonts
- Select a font
- Add a link element in your HTML pointing to the font you selected
- Use the font family in your CSS rule
A generalization to create layouts based on columns
- They generally are 12 columns
- We have several general concepts
- Container. It will define the maximum width of the blocks in the page
- Row. It's a container for columns
- Columns. Are usually elements floating with a specific width based on percents
- Got to http://getbootstrap.com/getting-started/
- Copy the first
linktag and add it to the head of your document - Copy the only
scripttag and add it before the end of yourbodyelement - Go to http://code.jquery.com/ and select the link to the minified version of the latest release (3.2.1)
and include the
scripttag before thescriptfor bootstrap
- Copy the first
- Got to http://getbootstrap.com/getting-started/
- Click on the button "Download Bootstrap"
- Extract the contents of the zip file
- Copy the file
css/bootstrap.min.cssto yourcssfolder - Copy the directory
fontsto the root of your project - Create a new directory
jsin your project - Copy the file
js/bootstrap.min.jsto your newjsin your project - link to the CSS and JS files from your HTML (
css/bootstrap.min.cssandboostrap.min.js) - Include jQuery from the CDN before the script for bootstrap
col-xs-3means three columns for extra small devices and bigger (all devices)
-
Introduction to JavaScript
- It was created in 7-10 days
- Its loosely typed
- Variables change type according to its content
-
Statements
- variable declaration
var identifier;- An identifier cannot start with a number
- Cannot include spaces
- Cannot include dashes
- They can include underscores
- assignment
identifier = "value";
- variable declaration
-
Expression
- Is a statement that returns a value
- A variable declaration is NOT a expression
- An assignment IS a expression
- All expressions have types
- a boolean expression
- a numeric expression
- a string expression
- Is a statement that returns a value
-
Javascript will try to convert the values of variables based on the operator
x && y, will try to convert bothxandyto booleans if they have a different typex * y, will try to convert the variables to numbersx + y, is more complicated because+is used for both addition and concatenation, so JS will look at the types of the variables, if one of them is a string, it will be concatenation
-
String Indexes in JavaScript
We start counting from 0
string: "codeup" indexes: 012345- The character at index
0isc - The character at index
3ise
- The character at index
-
Loops Break / Continue
breakwill stop the execution of the whole loop.continuewill skip the current cycle of loop and jump to the next iteration.
- There's 3 main types
- sequential
- conditionals
- loops
- Types of conditionals
- if
- ternary operation
- switch
- if
- Types of loops
- while
- do-while
- for
- Types
- Simple (1 single value)
- booleans, numbers, strings
- Complex (composition, several values)
- array -> groups, sets, collections, of similar things
- name[1], name[0] (key (number) -> value (anything))
- object -> describing the properties of books
- book["title"], book["author"] (key (string) -> value (anything))
- book.title, book.author
- books[0].title "Clean code"
- books[0]["author"] "Robert Martin"
- array -> groups, sets, collections, of similar things
- Simple (1 single value)
- Open your Chrome dev tools
- Switch to the Sources tab
- Click on the file name that contains your JavaScript code
- Add a breakpoint in the first line ypu want to debug (click to left of the line number, the line will become blue-ish)
- Refresh your page
- Use the button "Step over" to move between lines
In simple words
1.2.3->major.minor.patch- major. New stuff yay! Old stuff might not work as before, careful!!!
- minor. New stuff, yay!
- patch. Sorry my bad