Skip to content

Instantly share code, notes, and snippets.

@mdang
mdang / SQL2.md
Last active September 21, 2015 17:21
Lesson: SQL (Continued)

SQL

Lesson Objectives

  • Be able to insert new data into the database
  • Be able to query existing data
  • Be able to update existing data
  • Be able to delete data
  • Explain common keywords within queries and use them
  • Explain inner joins
@mdang
mdang / SQLREF.md
Created May 26, 2015 17:07
SQL Reference

SQL

Admin Notes

  • Notifying instructors if late

Homework Review

10am, 30 minutes

Class Review

10:30, 30 minutes

@mdang
mdang / WORLD.md
Last active April 30, 2021 07:10
Lab: World Database

World Lab

Let's learn a few things about this crazy world!

  1. Start by downloading and copying the contents of the worlds sample database file here
  2. Open up your terminal, then type in psql at the prompt to start the Postgres REPL
  3. Run the command create database world;
  4. Switch to the new database by typing in \c world
  5. Paste the contents of the SQL file you copied from step 1
@mdang
mdang / WORLDANSWERS.md
Last active April 30, 2021 07:16
Answers for the World Lab Exercise

Answers for the World Lab

Exercises:

  • Using count, get the number of cities in the USA
    • SELECT count(*) FROM city WHERE countrycode = 'USA';
  • Find out what the population and average life expectancy for people in Argentina (ARG) is
    • SELECT population, lifeexpectancy FROM country WHERE code = 'ARG';
  • Using the > operator, find the countries where the average life expectancy is greater than 78 years
    • SELECT name FROM country WHERE lifeexpectancy > 78;
  • Using IS NOT NULL, ORDER BY, LIMIT, what country has the highest life expectancy?
@mdang
mdang / STUDENTSSQL.md
Last active September 21, 2015 15:15
Students SQL Exercise

SQL Exercise

15 min

Let's populate the wdi database with some data and get more practice with SQL. Feel free to use psql or pgAdmin.

Insert the following 4 students into the students table.

  • Jill's full name is Jilly Cakes; she's 30 years old, and lives at 123 Webdev Dr. Boston, MA
  • Johns's full name is Johnny Bananas; hes 25 years old, and lives at 555 Five St, Fivetowns, NY
@mdang
mdang / STUDENTCRUD.md
Last active August 29, 2015 14:21
Student CRUD Example
require 'pg'

# Student class
class Student
	@conn

	# Constructor
	def initialize(config)
		@conn = PG.connect(:hostaddr => config[:hostaddr], :port => config[:port], :dbname => config[:dbname])
@mdang
mdang / AUTH.md
Last active September 24, 2015 14:31
Lesson: User Authentication

User Authentication

Learning Objectives

  • Provide a high-level explanation of what authentication is.
  • Explain the difference between authentication and authorization.
  • Describe some basic security measures for handling sensitive data, such as passwords.
  • Explain the difference between encryption and hashing
  • Create a users class that handles user signups
  • Authenticate users using email and password
@mdang
mdang / API_OAUTH.md
Last active March 10, 2016 17:33
Lesson: API's & OAuth

APIs

What's an API?

API's (Application Programming Interface) govern how software programs talk to each other. API's expose internal programming functions (e.g. features) to the outside world in a limited/controlled fashion. It makes it possible for applications to share data and allow users to take action even on different services.

API examples

  • Logging in with Facebook
  • Yelp displaying nearby restaurants on Google Maps
@mdang
mdang / GIPHY.md
Last active October 4, 2016 15:08
Exercise: Giphy API
@mdang
mdang / TESTING.md
Last active August 29, 2015 14:22
Lesson: Testing

Testing

Lesson Objectives

  • Explain why we want to write tests for our code
  • Explain the difference between unit tests and acceptance tests.
  • Explain what TDD is
  • Explain what BDD is
  • Explain what RSpec is and why it's useful
  • Describe how to write good specs