- 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
pwd
Print working directorymkdir
Create a directorycd
Move to a specific directorycd ..
Go to the parent directoryls
List filestouch
Creates an empty filecat
Show the contents of a filerm
Delete files or directories- For directories we'll add the flag
-r
(recursive)rm -r directory
It will work if the directory is emptyrm -rf directory
If 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 status
List the current changesgit add filename
Add a single filegit add .
This adds everything in the current directory, but deleted filesgit add -A
This adds everything, even ignored files
git commit
Save your changes to git. You'll need to include a message- The default editor is vim
- Press
i
to 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-m
flaggit commit --amend -m "Fixed message"
Fix a previous commit, with a new messagegit log
To see a list with all the commits, including your most recent onegit push origin master
Send your changes to Github
More commands
git fetch
Git download. Downloads changes from the remote without aplying them to mty local repogit stash
Saves Work in Progress, is similar to commit (temporary save)git stash list
Shows 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 (
src
in 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
client
and 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
GET
requests are questions (Could you play this song?)POST
requests 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
input
istext
- The default type for
button
issubmit
- 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 thechecked
attribute - for
select
, add theselected
attribute - for
input
, use thevalue
attribute
- for
- Inputs of type
checkbox
andradio
are not sent to server if none is checked - If a form element is
disabled
then is not sent to the server either - If a form element is
readonly
it is sent to the server anyway - A form element without a
name
is 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
style
attribute - Embedded. Using the
style
element - External. Using the
link
element pointing to an external.css
file
- Inline. Using the
- Types of positioning
static
is the default positioningabsolute
andrelative
positioning. 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
link
tag and add it to the head of your document - Copy the only
script
tag and add it before the end of yourbody
element - Go to http://code.jquery.com/ and select the link to the minified version of the latest release (3.2.1)
and include the
script
tag before thescript
for 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.css
to yourcss
folder - Copy the directory
fonts
to the root of your project - Create a new directory
js
in your project - Copy the file
js/bootstrap.min.js
to your newjs
in your project - link to the CSS and JS files from your HTML (
css/bootstrap.min.css
andboostrap.min.js
) - Include jQuery from the CDN before the script for bootstrap
col-xs-3
means 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 bothx
andy
to 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
0
isc
- The character at index
3
ise
- The character at index
-
Loops Break / Continue
break
will stop the execution of the whole loop.continue
will 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