Skip to content

Instantly share code, notes, and snippets.

@coreycartercodes
Last active August 7, 2020 09:11
Show Gist options
  • Save coreycartercodes/d2836dbcdf98f7853d2cf0e7da1c48da to your computer and use it in GitHub Desktop.
Save coreycartercodes/d2836dbcdf98f7853d2cf0e7da1c48da to your computer and use it in GitHub Desktop.

B2 Intermission Work

Answer these Check for Understanding questions as you work through the assignments.

HTML

What is HTML?

  • Hyper-Text-Markup-Language. The standard markup language for websites and describes the structure of the site.

What is an HTML element?

  • Tells the browser how to display the content.

What is an HTML attribute?

  • used to provide additional information about HTML elements

What is the difference between a class and an id? When would you use one vs. the other?

  • Class: points to a class name in a style sheet. Used by javascript to access/manipulate elements with the specific class name. Would use when you want a collection of elements to be styled similarly.
  • ID: Specifies unique ID for an HTML element. Used to style a single element.

What HTML would you write to create a form for a new dog with a "name" and an "age"?

<!DOCTYPE html>
<html>
<body>

<h2>HTML Forms</h2>

<form action="/action_page.php" method="get">
  <label for="name">name:</label><br>
  <input type="text" id="name" name="name" value="Rover"><br>
  <label for="age">age:</label><br>
  <input type="text" id="age" name="age" value="3"><br><br>
  <input type="submit" value="Submit">
</form> 

</body>
</html>

What are semantic tags? When would you use them over a div?

Semantic tags are more about structure than navigation as a <div> would be. Semantic elements define different parts of the page and their placement, where thematic elements are similar. Semantic elements also tell more info about their content whereas <div> just says "Division here"

Explain what each of the following HTML tags do and when you would use them

<h1>, <h2>, etc.: various sized headings, h1 being largest and "most important" <p>: shows a new paragraph and adds hard returns <body>: shows that this is the information that should be displayed on the page <a> and the href attribute: <a> shows that this is a link while the <href> tells the destination. <img> and the src attribute: shows that this is an image retrieved from a source file (src) <div>: starts a new line and takes up the whole width of the page <section>: defines a section of the page with similar thematic elements <ul>, <ol>, and <li>: Unordered List (use for "bullets") Ordered List(use for numbered/lettered), List Item (used as items within the other two tags) <form> <input>

CSS

What is CSS?

  • Cascading Style Sheets: used to describe how HTML elements should be displayed

What is a CSS selector? How do you use the ID selector? The class selector?

  • A selector points to the element you want to style. For instance using p { property: value} will style all paragraphs in this manner.
  • An ID selector is the individual element ID such as #para1 for "paragraph 1"
  • A class selector uses .class to style all elements with that class designation.

What are the three ways to include CSS in your HTML documents? What are the pros and cons of each?

  1. External:
  • Pros - Only have to change one file.
  • Cons - external storage could lead to loading errors? Only last style sheet read is used.
  1. Internal:
  • Pros - Used for unique pages.
  • Cons - Won't scale if project expands
  1. Inline:
  • Pros - Used for unique elements. Quick. Priority style sheet.
  • Cons - Won't scale and can get easily lost.

What is the Box Model? Describe each component of the Box Model.

  • Used to describe the area around every HTML element consisting of (from inside out):
  1. Content - content of the element: text, images, etc...
  2. Padding - clears an area around the content. Transparent.
  3. Border - goes around padding and content.
  4. Margin - clears area outside of the border. Transparent

SQL

Jumpstart Lab Tutorial

What is a database?

  • our means of storing, fetching, calculating, and sorting data

What is SQL?

  • Structured Query Language: how we interact with most databases

What is SQLite3?

  • a database system used for experiments and local development; built in to MasOS

What is a Table?

  • a way of representing data in a row x column format

What is a primary key?

  • a unique ID to the pieces of data which are imported directly

What is a foreign key?

  • an ID which references data in another table

Explain what each of the following SQL commands do:

insert - inserts data into a table select - gathers data based on specifications where - limits returned values to those meeting specified attributes order by - sorts data by given attribute inner join - creates a new table by joining others referencing a ON key

PG Exercises

How can you limit which columns you select from a table?

  • by using the name after the SELECT command

How can you limit which rows you select from a table?

  • by adding attributes after the WHERE command

How can you give a selected column a different name in your output?

  • SELECT column AS new_name

How can you sort your output from a SQL statement?

  • ORDER BY column

What is joining? When do you need to join?

  • combining data from multiple tables which share a key value
  • needed when one table does not contain all the necessary information

What is an aggregate function?

  • computes a single result from multiple input rows

List three aggregate functions and what they do.

  • COUNT: counts number of rows which meet criteria
  • MAX: finds maximum value of given column
  • AVG: calculates average of given column

What does the group statement do?

  • batches data into groups

How does the group statement relate to aggregates?

  • using a GROUP BY in conjunction will run the aggregate function on the GROUP BY indicated

Rails Tutorial: Task Manager

Define CRUD.

  • C: Create (a request)
  • R: Read (or retrieve data)
  • U: Update (or change data)
  • D: Delete (retrieved/altered data)

Define MVC.

  • Model: assembled data to fit view
  • View: the end expected result which user receives
  • Controler: where the view is requested from; gathers info

What three files would you need to create/modify for a Rails application to respond to a GET request to /tasks, assuming you have a Task model.

  1. routes
  2. controller
  3. index

What are params? Where do they come from?

  • parameters stored as a hash with specific key-value pairs; come from user input using a form.

Check out your routes. Why do we need two routes each for creating a new Task and editing an existing Task?

  • They are two different methods, one applied to create an object from the data tables, and one applied to an already existing object, adding into the existing data table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment