Skip to content

Instantly share code, notes, and snippets.

@kunxin-chor
kunxin-chor / index.js
Created March 11, 2024 02:33
RESTFul API Template
// 1. REQUIRE DEPENDENCIES
const express = require('express');
const mongodb = require('mongodb');
const cors = require('cors');
const app = express();
// enable the use of JSON
app.use(express.json());
@kunxin-chor
kunxin-chor / pet_hospital.mysql
Created September 24, 2023 08:14
MySQL Database for Pet Hospital
-- Check if the database exists, if not, create it
CREATE DATABASE IF NOT EXISTS pet_hospital;
USE pet_hospital;
-- Create the `pets` table
CREATE TABLE IF NOT EXISTS pets (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
species VARCHAR(255) NOT NULL,
breed VARCHAR(255) DEFAULT NULL,
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Book List</title>
<!-- include Bootstrap 5 CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css">
</head>
<body>
<!-- A sample application that demonstrates the major features of ES6, ES7, ES8, ES9, and ES10
@kunxin-chor
kunxin-chor / index.html
Last active June 20, 2023 09:24
ATM DOM
<!DOCTYPE html>
<html>
<head>
<title>ATM Machine</title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<div class="atm">
<div id="display">Insert card to begin</div>
@kunxin-chor
kunxin-chor / db.sql
Last active June 20, 2023 04:59
Pet Hospital Example
CREATE TABLE roles (
role_id INT AUTO_INCREMENT PRIMARY KEY,
role_name VARCHAR(255) NOT NULL
);
CREATE TABLE users (
user_id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) NOT NULL,
password VARCHAR(255) NOT NULL,
first_name VARCHAR(255) NOT NULL,
@kunxin-chor
kunxin-chor / index.js
Created June 19, 2023 07:25
Starting template for Express
const express = require('express');
const ejs = require('ejs');
const app = express();
app.set('view engine', 'ejs');
app.get('/', function(req,res){
res.send("Hello World")
})
@kunxin-chor
kunxin-chor / db.sql
Last active June 22, 2023 01:41
Sample database
CREATE TABLE artists (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
birth_year INT,
country VARCHAR(255)
) engine=innoDB;
ALTER TABLE `artists` ADD `preferred_medium` VARCHAR(255) NULL AFTER `country`;
@kunxin-chor
kunxin-chor / index.html
Created March 31, 2023 08:05
Sample index HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fictional Business</title>
</head>
<body>
<header id="main-header">
<h1>Fictional Business</h1>
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
@kunxin-chor
kunxin-chor / index.js
Created December 5, 2022 12:15
Boilerplate for Express Application with HBS and Wax on
// 1. SETUP EXPRESS
const express = require('express');
const hbs = require('hbs');
const wax = require('wax-on');
// 1a. create the app
const app = express();
// 1b setup our view engine (aka template engine)
// tell Express that we are using hbs