Skip to content

Instantly share code, notes, and snippets.

@QuocCao-dev
QuocCao-dev / authen.js
Last active April 30, 2024 03:58
authentication
import express from "express";
import { PrismaClient } from "@prisma/client";
import { hash, compare } from "bcrypt";
import jwt from "jsonwebtoken";
const prisma = new PrismaClient();
const app = express();
app.use(express.json());
@QuocCao-dev
QuocCao-dev / main.js
Created April 25, 2024 14:02
TodoProjectList
class Todo {
constructor(text, finished) {
this.id = String(Date.now());
this.text = text;
this.finished = finished;
}
}
class InputDOM {
constructor() {
// Name, email, phone, location, age, picture
// Events listener: click (generate user)
const btnTag = document.querySelector("#generate");
function fetchUser() {
fetch("https://randomuser.me/api")
.then((response) => response.json())
.then((data) => {
const randomUser = data.results[0];
let randomUser;
fetch("https://randomuser.me/api")
.then((response) => {
return response.json();
})
.then((data) => {
randomUser = data.results[0];
console.log(randomUser);
@QuocCao-dev
QuocCao-dev / index.js
Last active March 26, 2024 14:21
shop list
const itemForm = document.getElementById("item-form");
const itemInput = document.getElementById("item-input");
const itemList = document.getElementById("item-list");
const clearBtn = document.getElementById("clear");
const filterInput = document.getElementById("filter");
const liInItems = document.querySelectorAll(".items > li");
function createElement(tag, className, text) {
const elm = document.createElement(tag);
const express = require("express");
// Create express instance
const app = express();
// accept json data
app.use(express.json());
// Http Method
/**
@QuocCao-dev
QuocCao-dev / index.html
Created September 10, 2023 16:06
Grand Hotel
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Grand Hotel</title>
<link rel="shortcut icon" type="image/png" href="img/crown.png" />
<link
rel="stylesheet"
@QuocCao-dev
QuocCao-dev / App.tsx
Last active September 9, 2023 14:48
Solution menu
import { useState } from "react";
import Categories from "./Categories";
import Menus from "./Menus";
const menu = [
{
id: 1,
title: "buttermilk pancakes",
category: "breakfast",
price: 15.99,
@QuocCao-dev
QuocCao-dev / 1.Basic-Type.txt
Last active May 6, 2024 16:40
Typescript Exercises
/* *-*-*-*-*-*-*-*-*-*-* Challenge 1 ------------------
Create a variable with the type number and assign it an arbitrary value
*/
// ----------------------------------------------------
// *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-
// ----------------------------------------------------
/* *-*-*-*-*-*-*-*-*-*-* Challenge 2 ------------------
Create a variable with the type string and use the addition operator to put two arbitrary words together
*/
@QuocCao-dev
QuocCao-dev / 1.md
Created June 15, 2023 10:22
New Feature

1. Object Literals

Refactor the code:

var name = "Francis";
var lastname = "Jones"
var age = 23;
var obj
function createObject(name,lastname,age){
 obj = {