Skip to content

Instantly share code, notes, and snippets.

@chriscarlsondev
chriscarlsondev / MuchToDo.md
Created July 20, 2019 00:33
An idea for the capstone project for the web development program at Bloc

Tracking the most important things that I need to get done during the week should be as easy as possible so that I can spend more time doing those things. The MuchToDo App will be a simple to do list tracker app.

@chriscarlsondev
chriscarlsondev / CheckPoint-7-QA.md
Last active July 20, 2019 00:06
Questions and Answers for Check Point 7 - Expiry time

Should the client or the server take more security precautions? Server.

What's the difference between local storage and session storage? Session storage is the same as local storage except that the data doesn't persist outside of the tab (session). The difference between local and session storage is that while local storage is always available in any tab and window of the same machine's browser, session storage isn't. Session storage is only available in the browser tab that the data was saved in, as soon as that tab is closed, the data is gone. As a result, session storage gives us an extra security feature for the frontend.

What problem does a JWT expiry time solve? JWT expiry time restricts the amount of time that an authorization token is valid for. This gives the server more control of the validity of any JWTs it creates instead of relying on the frontend client to ensure tokens aren't stolen.

Is a refresh endpoint protected or public?

@chriscarlsondev
chriscarlsondev / Learning-A-New-Codebase.md
Last active July 17, 2019 18:56
Q&A for the module on Learning a New Codebase

How are the syntaxes async and await useful when writing JavaScript code?

The word “async” before a function means the function always returns a promise and wraps non-promises in it. The keyword await makes JavaScript wait until that promise settles and returns its result. Async Await makes execution sequential.

With respect to Knex, how does the transaction method relate to BEGIN and COMMIT syntax in PostgreSQL?

In PostgreSQL, BEGIN initiates a transaction block. All statements after a BEGIN command will be executed in a single transaction until an explicit COMMIT or ROLLBACK is given.

@chriscarlsondev
chriscarlsondev / NotefulDatabase.md
Last active July 16, 2019 17:33
Sketch and ERD for Noteful database

These are my sketches and entity relationship diagram for the Noteful database.

IMG_6674

noteful-database-erd

-- 1. How many people work in the Sales department?
SELECT
COUNT(e.id)
FROM
employee e
JOIN
department d
ON
e.department = d.id
WHERE
@chriscarlsondev
chriscarlsondev / shopping-list-service.js
Created July 1, 2019 17:40
Service and test for shopping list
const ShoppingListService = {
getAllItems(knex){
return knex.select('*').from('shopping_list')
},
insertItem(knex, newItem) {
return knex
.insert(newItem)
.into('shopping_list')
.returning('*')
.then(rows => {
@chriscarlsondev
chriscarlsondev / drills.js
Created July 1, 2019 16:02
Drill exercises working with shopping list
const knex = require('knex')
require('dotenv').config()
const knexInstance = knex({
client: 'pg',
connection: process.env.DB_URL
})
function searchByName(searchTerm) {
knexInstance
@chriscarlsondev
chriscarlsondev / create.shopping-list.sql
Created July 1, 2019 15:41
SQL statements to create a shopping list table and enum
DROP TYPE IF EXISTS grocery;
CREATE TYPE grocery AS ENUM (
'Main',
'Snack',
'Lunch',
'Breakfast'
);
CREATE TABLE IF NOT EXISTS shopping_list (
id INTEGER PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY,
-- First, remove the table if it exists
drop table if exists bookmarks;
-- Create the table anew
create table bookmarks (
id INTEGER primary key generated by default as identity,
title VARCHAR(50) not null,
URL VARCHAR(50) not null,
description VARCHAR(300),
rating INTEGER not null
@chriscarlsondev
chriscarlsondev / ReadingAPIDocumentationAssignment.md
Last active May 21, 2019 19:53
My answers for the Reading API Documentation Assignment
  1. Visit the YouTube API documentation discussed above and find the subscription list endpoint documentation. List 1 required parameter and 2 optional parameters for this endpoint. For each parameter listed, state the data type and give an example of the allowed values. https://developers.google.com/youtube/v3/docs/subscriptions/list Required parameter:
  • part (data type: string, example value: snippet) Optional parameters:
  • forChannelId (data type: string, example value: comma separated list of channel IDs)
  • order (data type: string, example value: alphabetical)
  1. Visit the Google Maps Geocoding API documentation found here: https://developers.google.com/maps/documentation/geocoding/intro. Construct the full URL for requesting the geographic coordinates of The Statue of Liberty in JSON format. Do the same for your own address.