#100DaysOfCode Round 5

All projects:

R5 Day 25: 2022-02-25 Friday

R5 Day 22: 2022-02-22 Tuesday

Storybook: Getting Started (Pluralsight)

Examples

It’s a tool for creating isolated UI components

May be known as:

How it works:

Getting Started

  1. /components - React components, etc
  2. Add stories (/.storybook) - npx -p @storybook/cli sb init
  3. npm run storybook

R5 Day 21: 2022-02-21 Monday

Phonebook tests repo - Test structure: Arrange, act, assert

R5 Day 19: 2022-02-19 Saturday

Phonebook tests repo - add test fixture

R5 Day 16: 2022-02-16 Wednesday

Promoted to Senior FED 🎉

R5 Day 14: 2022-02-14 Monday

Updated python server & updated code on production to use sqlite3

sudo apt-get update
sudo apt-get upgrade
cd /var/www/distantlife.com/html
sudo systemctl stop distantlife
git pull
sudo systemctl start distantlife

R5 Day 13: 2022-02-13 Sunday

Unit Testing

A unit test doesn’t use:

Phonebook tests repo

R5 Day 12: 2022-02-12 Saturday

DistantLife: change use of cs50 library to sqlite3 for database queries

Was:

from cs50 import SQL

db = SQL("sqlite:///distantlife.db")

Now:

import sqlite3

con = sqlite3.connect("distantlife.db")
con.row_factory = sqlite3.Row # includes column name in return dictionary
db = con.cursor()

Updated:

@app.route("/pets")
@login_required
def pets():
    """Lists all of user's pets"""
    
-   # previously using cs50 db query
-   # pets_owned = db.execute("SELECT pets.id, pet_types.imgsrc, pet_types.pet_type, pets.created, pets.exp, pets.name, users.active_pet_id FROM owners JOIN pets ON pets.id = owners.pet_id JOIN pet_types ON pets.type = pet_types.id JOIN users ON users.id = owners.owner_id WHERE owner_id = ?", session_get_int("user_id"))
-   # [{'id': 15, 'imgsrc': '/pets/034-jackalope.png', 'pet_type': 'Jackalope', 'created': '2021-12-05 18:04:39', 'exp': 0, 'name': 'Unnamed Pet', 'active_pet_id': 15}]    
    
+   # now, updated using .fetchall and rows magic (above)
+   # also required trailing " , " in list of params
+   pets_owned = db.execute("SELECT pets.id, pet_types.imgsrc, pet_types.pet_type, pets.created, pets.exp, pets.name, users.active_pet_id FROM owners JOIN pets ON pets.id = owners.pet_id JOIN pet_types ON pets.type = pet_types.id JOIN users ON users.id = owners.owner_id WHERE owner_id = ?", (session_get_int("user_id"), )).fetchall()
+   # https://itheo.tech/get-column-names-from-sqlite-with-python
+   # print(dict(pets_owned[0]))
+   # {'id': 15, 'imgsrc': '/pets/034-jackalope.png', 'pet_type': 'Jackalope', 'created': '2021-12-05 18:04:39', 'exp': 0, 'name': 'Unnamed Pet', 'active_pet_id': 15}
    return render_template("list.html", pets_owned=pets_owned)

After every UPDATE, INSERT, and DELETE you also need to commit in order to ensure the execution moves from the journal to the database.

Example of updating a row, checking if there was an update with rowcount and committing the update

updateqry = db.execute(
    "UPDATE pets SET exp = ? WHERE id = ?", (exp, active_pet_id))
con.commit()
if (updateqry.rowcount > 0):
    session.get("active_pet")["exp"] = exp
    return exp
else:
    return 0

R5 Day 11: 2022-02-11 Friday

AWS Cert: Introduction to Security and Architecture on AWS

R5 Day 10: 2022-02-10 Thursday

AWS Cert: Introduction to Security and Architecture on AWS

R5 Day 9: 2022-02-09 Wednesday

AWS Cert: Introduction to Security and Architecture on AWS

R5 Day 8: 2022-02-08 Tuesday

AWS Cert: Introduction to Security and Architecture on AWS

R5 Day 7: 2022-02-07 Monday

AWS Cert: Understanding AWS Core Services

R5 Day 6: 2022-02-06 Sunday

AWS Cert: Understanding AWS Core Services

Email: learn and test DMARC (Domain-based Message Authentication, Reporting & Conformance)

R5 Day 5: 2022-02-05 Saturday

AWS Cert: Understanding AWS Core Services

Compute services:

Methods of interacting:

AWS CLI

Setting up AWS CLI, download CLI v2

aws configure --profile ps
AWS Access Key ID [None]: KEY_ID
AWS Secret Access Key [None]: SECRET_KEY
Default region name [None]: us-west-2
Default output format [None]: json

Example, list all S3 buckets:

aws s3 ls --profile ps

R5 Day 4: 2022-02-04 Friday

R5 Day 3: 2022-02-03 Thursday

AWS Cert: Fundamental Cloud Concepts

R5 Day 2: 2022-02-02 Wednesday

AWS Cert: Fundamental Cloud Concepts

R5 Day 1: 2022-02-01 Tuesday

Learned that this SCSS syntax works for compiling font styles: (thanks LauraBoemo!)

.myclass {
  font: { 
    family: $theme-font-regular; 
    size: 16px; 
    weight: 300; 
  }
}

🧧 Round 5 begins 🧧

Ideas for Round 5 starting February 1, 2022