- Add avgRating property to PostSchema (/models/post.js)
const PostSchema = new Schema({
title: String,
price: String,
description: String,
images: [ { url: String, public_id: String } ],
location: String,
coordinates: Array,| let maximum = parseInt(prompt("Enter the maximum number!")); | |
| while (!maximum) { | |
| maximum = parseInt(prompt("Enter a valid number!")); | |
| } | |
| const targetNum = Math.floor(Math.random() * maximum) + 1; | |
| let guess = parseInt(prompt("Enter your first guess!")); | |
| let attempts = 1; |
| const axios = require('axios') | |
| const cheerio = require('cheerio') | |
| async function getPrice(symbol) { | |
| try { | |
| let { data } = await axios.get(`https://finance.yahoo.com/quote/${symbol}?p=${symbol}&.tsrc=fin-srch`) | |
| let $ = cheerio.load(data) | |
| // use this one for bitcoin | |
| // console.log(`The current price of ${symbol} is:`, '$' + $('span[data-reactid="33"]').eq(1).text()) | |
| // use this one for aftermarket hours |
| // FS docs: https://nodejs.org/api/fs.html | |
| const fs = require('fs'); | |
| fs.readdir('.', (err, files) => { | |
| if(err) console.log(err); | |
| let counter = 0; | |
| files.forEach(file => { | |
| // // match and delete thumbnails | |
| // if(file.match(/\d\dx\d\d/) | |
| // || file.match(/\d\d\dx\d\d\d/) |
| const shell = require('shelljs'); | |
| const rp = require('request-promise'); | |
| async function testWifi() { | |
| let count = 0; | |
| try { | |
| const result = await rp('http://www.google.com'); | |
| if (result) { | |
| console.log('wifi working'); | |
| } | |
| } catch(err) { |
| index: async (req, res, next) => { | |
| let posts, filters, query; | |
| // define escapeRegex function for search feature | |
| const escapeRegex = (text) => { | |
| return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); | |
| }; | |
| // check if filters exist | |
| if (req.query.post) filters = Object.values(req.query.post).join('') ? true : false; | |
| // check if request has filter(s) | |
| if (filters) { |
| DROP DATABASE IF EXISTS ig_clone; | |
| CREATE DATABASE ig_clone; | |
| USE ig_clone; | |
| CREATE TABLE users ( | |
| id INTEGER AUTO_INCREMENT PRIMARY KEY, | |
| username VARCHAR(255) UNIQUE NOT NULL, | |
| created_at TIMESTAMP DEFAULT NOW() | |
| ); |
| killall mongod | |
| sudo apt-get purge -y mongodb-org* | |
| sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5 | |
| echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list | |
| sudo apt-get update | |
| sudo apt-get install -y mongodb-org | |
| rm -rf mongod | |
| echo "mongod --dbpath=data --nojournal" > mongod | |
| chmod a+x mongod |