A Pen by Brad Traversy on CodePen.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
exports.getNewProblemsList = async (req, res, next) => { | |
const page = req.params.page || 1; | |
const limit = 10; | |
const skip = page * limit - limit; | |
const problemPromise = Problem.find() | |
.populate('author hardware repairsV', 'name') | |
.skip(skip) | |
.limit(limit) | |
.sort({ created: 1 }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Spread to remove field | |
const user = { | |
firstName: 'John', | |
lastName: 'Doe', | |
city: 'Here' | |
} | |
const { city, ...userWIthoutCity} = user | |
city // here | |
userWIthoutCity // {firstName: 'John', lastName: 'Doe'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// It splits by comma then map and trim each emai, then check each email pass the test, keeping the ones that do not pass the test. | |
// If any email do not pass the regex test show it to the user, otherwise continue (return) | |
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; | |
export default emails => { | |
const invalidEmails = emails | |
.split(',') | |
.map(email => email.trim()) | |
.filter(email => re.test(email) === false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Start my project at 1.0.0 in package.json | |
Initial dev work | |
Push to develop branch | |
Push to master branch | |
Tag as v1.0.0 | |
Dev | |
Push to 'feature/name-of-feature' or 'bug/name-of-bug' branches | |
Merge pull request of feature and bug branches into develop | |
When it's ready for release, determine the version number (1.0.1 or 1.1.0) and update package.json | |
Push package.json to develop branch |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const multer = require('multer'); | |
const multerS3 = require('multer-s3'); | |
const uuid = require('uuid'); | |
const AWS = require('aws-sdk'); | |
const sharp = require('sharp'); | |
AWS.config.update({ | |
accessKeyId: process.env.AWS_ACCESS, | |
secretAccessKey: process.env.AWS_SECRET_KEY | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Declare second integer, double, and String variables. | |
let secondInteger, secondDouble, secondString | |
// Read and save an integer, double, and String to your variables. | |
/* Using readline and parsing the input into the variables declared previously */ | |
secondInteger = parseInt(readLine()); | |
secondDouble = parseFloat(readLine()); | |
secondString = readLine(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
p= store.description.split(' ').slice(0, 25).join(' ') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const serialport = require('serialport'); | |
/* serialport.list(function(err, result) { | |
console.log('error: ', err); | |
console.log('result: ', result); | |
}); | |
*/ | |
const port = new serialport('COM9'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 1. Zombie Game | |
* ------------- | |
* A. Write Scenarios | |
* B. Store a list of possible scenarios | |
* C. Alert a random scenario from the list | |
* | |
* A. Create a list of weapons | |
* B. Save a list of weapons | |
* C. Alert which weapon the player finds |