Skip to content

Instantly share code, notes, and snippets.

View shawnhank's full-sized avatar

Shawn Hank shawnhank

View GitHub Profile

Fundamentals of React

React Fundamental Summary
React
  • A JS library for building dynamic UIs using components.
JSX
  • A syntax extension to JS that looks like HTML and makes defining UIs more intuitive vs. pure JS.
  • JSX emits text in the page when a JS expression is surrounded with curly braces
    <div>{/* JS Expression */}</div>.
  • JSX transpiles into a function call that returns a JS object, thus, JSX can be assigned to variables, passed as arguments to functions, etc.
  • JSX can render an array of components, however, each component needs a key prop with a unique value.
    const catList = cats.map(c => <div key={cat.id}>{cat.name}</div>);.
Components
  • A user interface is defined by a hierarchy of components.
User-Defined Component May be defined as a function or class but must be n

Guide to User-Centric CRUD using Express & Mongoose

Intro

Typically, logged in users interact with an application that results in data being created, updated and deleted.

In almost every case, the application's code will need to ensure that the logged in user can only update/delete data created by them, not the data of other users.

mern-project-template Code-Along Guide

Today's plan to code a mern-project-template that includes JWT authentication and can be used to start any MERN-Stack project, including Project 3!

Initial Project Setup

  1. Create a folder named mern-project-template within the ~/code/ga folder.
  2. cd into the new mern-project-template folder and open it in VS Code.
  3. Open a Terminal in VS Code.
  4. Run npm init -y to create a package.json file.

Guide on How to Build a Browser Game

Intro

Getting started and knowing how to structure the code in an application is one of the most difficult things for students to figure out.

Also, there might be plenty of sources available to learn about how to use a forEach loop, but finding help on how to think like a developer and write code to implement an app's features is difficult at best.

Let's Code Connect-Four!

Intro

So far, we've covered the fundamentals of:

  • HTML
  • CSS
@shawnhank
shawnhank / git-aliases.md
Created April 19, 2025 06:26 — forked from mwhite/git-aliases.md
The Ultimate Git Alias Setup

The Ultimate Git Alias Setup

If you use git on the command-line, you'll eventually find yourself wanting aliases for your most commonly-used commands. It's incredibly useful to be able to explore your repos with only a few keystrokes that eventually get hardcoded into muscle memory.

Some people don't add aliases because they don't want to have to adjust to not having them on a remote server. Personally, I find that having aliases doesn't mean I that forget the underlying commands, and aliases provide such a massive improvement to my workflow that it would be crazy not to have them.

The simplest way to add an alias for a specific git command is to use a standard bash alias.

# .bashrc
@shawnhank
shawnhank / pull-upstream.md
Created April 19, 2025 06:24 — forked from jim-clark/pull-upstream.md
Obtain Updates to Class Repos (Course, Lectures & Assignments)
# Clone the repo
git clone https://github.com/imartinez/privateGPT
cd privateGPT
# Install Python 3.11
pyenv install 3.11
pyenv local 3.11
# Install dependencies
poetry install --with ui,local
@shawnhank
shawnhank / main.py
Created January 23, 2024 22:01 — forked from mberman84/main.py
OpenChat Code
import requests
import json
import gradio as gr
url = "http://localhost:11434/api/generate"
headers = {
'Content-Type': 'application/json',
}
@shawnhank
shawnhank / templogger.sh
Created December 8, 2023 07:24 — forked from i3luefire/templogger.sh
This is a variation of fkleon's temperature.sh script that puts the info in a simple text file instead of an email. It is also my first gist on github. :)
#! /bin/sh
# This is your log filename
LOGFILE=/path/to/temp.log
# Create empty file
touch $LOGFILE
# Define adastat function, which writes drive activity to temp file
adastat () {