Skip to content

Instantly share code, notes, and snippets.

View vanderhoop's full-sized avatar

Travis Vander Hoop vanderhoop

View GitHub Profile

Straight CRUDdin' with PSQL

You now know how to create tables and CRUD using PSQL. Now you just need reps writing and executing sql.

Exercise Objective(s)

  • get comfortable executing basic CRUD commands in psql

Part 1: employees

Postgres Console Commands

From the Terminal

  • psql opens the postgres console
  • psql -d some_database_name -f some_sql_file.sql executes the SQL in the given file within the database specified

Within the Postgres Console

  • \q quits the postgres console
  • \l lists all databases
  • \c database_name connects you to database_name

Common jQuery Methods

You just learned how to create jQuery objects. Now take the next 25 minutes to research and experiment with the following methods, all of which you can call on jQuery objects. (And this is only the beginning, there are many more to be found)!

  • .text()
  • .html()
  • .attr()
  • .addClass()
  • .removeClass()
  • .toggleClass()

OAuth Exploration

We just went step by step through the OAuth workflow for GitHub, but not every provider requires the same params and configuration. Thus, it's important to wrestle with the documentation to find exactly what each service provider requires. And that's exactly what you're going to do now.

Directions

  1. Identify an OAuth2 Provider you have both A) have an account for and B) think you might want to use in a project.
  2. Identify the values (params, headers, and so on) that you'll have to provide the service provider to properly authenticate your users.
  3. Identify values that should be hidden and make them environmental variables.
  4. Implement OAuth, using the github_oauth app as a helpful guide.

HTTP Requests

We've already worked extensively with GET requests and POST requests, but the HTTP spec defines a handful of others, which you're about to learn about.

Directions

  1. Read through the list of HTTP request types at the top of this page.
  2. Read through the plain-english (non-code) explanations of the following request types.
  • GET
  • POST

The DMV

The DMV is notorious for making you fill out numerous forms. You are going to recreate that hellish process for users of the California DMV's web application.

DMV Part 1

  1. Write a route handler for GET requests made to "/first_form". Make this route render a template called first_form.erb.
  2. Within first_form.erb, make a form. Make the form POST to "/first_form".
  • give the form inputs for the user to enter their name and drivers license ID number
  1. Write a route handler for POST requests made to "/first_form".

The Diary That Also Acts as a Sketchbook

You just persisted some diary entries. Now it's time to add some sketches to your diary, like a real person.

Directions

  1. Write a route handler for GET requests made to "/sketches". Make this route render a template called sketches.erb. This template will eventually display a list of sketches, but for now you can leave it blank.
  2. Write a route handler for GET requests made to "/sketches/new". This route handler should render a template that displays a form. Make the form POST to "/sketches".
  3. Give your form two inputs: one a text input and the other a date input.
  • Note: You'll have to give both of these inputs a "name" property

Experimenting with Inputs

You just started playing around with form inputs, gaining exposure to the text input, the select input, the hidden input, and the checkbox. Fortunately for the development community, there are many more to choose from, and most make our lives a whole lot easier.

Directions

Within the form we started writing for the Goggle search engine, add inputs of the following types, making sure to provide each with a 'name' attribute, and wrapping each in a label tag!

  1. An input of the date type.
  2. An input of the file type.

Thinkin' About POSTin'

As a user of the interweb, you probably change data server-side all the time, which means you're using POST requests all the time. This is a thought-exercise meant to clue you in to all the ways in which you interact with the web using POST requests.

Directions

  1. Partner up.
  2. Make a list of 6 different ways in which you or your partner use web applications to change information on a server:
    • Way 1:
  • Way 2:

Bachelorette Profile Pages

This is a partner exercise.

Directions

With your partner, discuss the following questions:

  1. How can we write a single route handler that dynamically handles each of the bachelorette's profile pages.
  • Example usage: if a GET request is made to "/bachelorettes/alissa", the user should see the information for Alissa, while if a GET request is made to "/bachelorettes/nicole", the user should see the information for Nicole.