Skip to content

Instantly share code, notes, and snippets.

// Update or edit
app.post('api/course/:id', (req,res) => {
// check the course if it exist
// if not existing, return a 404 status.
//validate
// if invalid, return 404 -bad request
//update course
@edoves
edoves / app.js
Created November 14, 2023 06:44
settiing up nodejs server
const express = require('express')
const cors = require('cors')
const cookieParser = require('cookie-parser')
const app = express()
const postRoute = require('./routes/post.route.js')
const userRoute = require('./routes/user.route.js')
const corsOptions = {
origin: true,
@edoves
edoves / firebase_rules.txt
Created November 5, 2022 08:49
Firebase rules for house marketplace app
// FIRESTORE RULES
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
// Listings
match /listings/{listing} {
allow read;
allow create: if request.auth != null && request.resource.data.imgUrls.size() < 7;
allow delete: if resource.data.userRef == request.auth.uid;
export { default as Navbar } from './Navbar/Navbar';
export { default as Footer } from './Footer/Footer';
export { default as InfoSection } from './InfoSection/InfoSection';
export { default as Pricing } from './Pricing/Pricing';
@edoves
edoves / map.js
Last active October 2, 2022 07:42
map function in pure js rendering HTML
import Rating from '../components/Rating';
import { getProducts } from '../api';
import { parseRequestUrl } from '../utils';
const HomeScreen = {
render: async () => {
const { value } = parseRequestUrl();
const products = await getProducts({ searchKeyword: value });
if (products.error) {
return `<div class="error">${products.error}</div>`;
@edoves
edoves / scss.txt
Created September 24, 2022 01:52
Structuring your Sass Projects
sass/
|
|– abstracts/ (or utilities/)
| |– _variables.scss // Sass Variables
| |– _functions.scss // Sass Functions
| |– _mixins.scss // Sass Mixins
|
|– base/
| |– _reset.scss // Reset/normalize
| |– _typography.scss // Typography rules
@edoves
edoves / package.json
Created September 9, 2022 09:29
static website setup
{
"name": "project",
"version": "0.1.0",
"description": "SASS compile|autoprefix|minimize and live-reload dev server using Browsersync for static HTML",
"main": "public/index.html",
"author": "5t3ph",
"scripts": {
"build:sass": "sass --no-source-map src/sass:public/css",
"copy:html": "copyfiles -u 1 ./src/*.html public",
"copy:js": "copyfiles -u 1 ./src/**/*.js public",
@edoves
edoves / arrayIteration.js
Created February 21, 2021 02:54
Seven Ways to Iterate Over an Array
let arr = [5, 10, 15, 20, 24];
//================ while loop;
let i = 0;
while (i < arr.length) {
console.log(arr[i]);
i++;
}
//================ do while
@edoves
edoves / divisibleby3.js
Created March 20, 2020 08:59
divisibleby3.
Hello; Hello World; World
Write a function that takes an integer and:
If the number is a multiple of 3, return "Hello".
If the number is a multiple of 5, return "World".
If the number is a multiple of both 3 and 5, return "Hello World".
helloWorld(3) ➞ "Hello"
helloWorld(5) ➞ "World"
<!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>Document</title>
<link rel="stylesheet" href="css/style.css" />
</head>
<body>