This file contains hidden or 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
| defined_indexes = Model.index_specifications.map { |s| s.fields.map(&:to_s) }; | |
| existing_indexes = Model.collection.indexes.map { |i| i['key'].keys }; | |
| missing_indexes = defined_indexes - existing_indexes | |
| # => [] | |
| extra_indexes = existing_indexes - defined_indexes - [['_id']] | |
| # => [] | |
| ################################################################################# |
This file contains hidden or 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
| sudo mkdir /Volumes/NTFS | |
| diskutil list | |
| sudo /usr/local/bin/ntfs-3g /dev/disk2s1 /Volumes/NTFS -olocal -oallow_other | |
| rsync -v --progress ~/Downloads/something /Volumes/NTFS/ | |
| sudo umount /Volumes/NTFS |
This file contains hidden or 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
| openssl genrsa -out CAroot.key 2048 | |
| openssl req -new -key CAroot.key -out CAroot.csr # CN should be different from the certificates below | |
| openssl req -x509 -days 1825 -key CAroot.key -in CAroot.csr -out CAroot.crt | |
| cat CAroot.crt CAroot.key > CAroot.pem | |
| openssl genrsa -out mongod.key 2048 | |
| openssl req -new -key mongod.key -out mongod.csr | |
| openssl x509 -req -days 1825 -in mongod.csr -CA CAroot.pem -CAkey CAroot.key -CAcreateserial -out mongod.crt | |
| cat mongod.crt mongod.key > mongod.pem |
This file contains hidden or 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
| sequelize | |
| // .sync({ force: true }) | |
| .sync() | |
| .then(result => { | |
| console.log(result); | |
| app.listen(3000); | |
| }) | |
| .catch(err => { | |
| console.log(err); | |
| }); |
This file contains hidden or 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
| Product.belongsTo(User, { constraints: true, onDelete: 'CASCADE' }); | |
| User.hasMany(Product); |
This file contains hidden or 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 Sequelize = require('sequelize'); | |
| const sequelize = require('../util/database'); | |
| const User = sequelize.define('user', { | |
| id: { | |
| type: Sequelize.INTEGER, | |
| autoIncrement: true, | |
| allowNull: false, | |
| primaryKey: true |
This file contains hidden or 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 Sequelize = require('sequelize'); | |
| const sequelize = new Sequelize('node-complete', 'root', 'nodecomplete', { | |
| dialect: 'mysql', | |
| host: 'localhost' | |
| }); | |
| module.exports = sequelize; |
This file contains hidden or 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
| <% if (prods.length > 0) { %> | |
| <div class="grid"> | |
| <% for (let product of prods) { %> | |
| <article class="card product-item"> | |
| <header class="card__header"> | |
| <h1 class="product__title"> | |
| <%= product.title %> | |
| </h1> | |
| </header> | |
| <div class="card__image"> |
This file contains hidden or 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
| app.use(errorController.get404); | |
| app.use((error, req, res, next) => { | |
| // res.status(error.httpStatusCode).render(...); | |
| res.redirect('/500'); | |
| }); | |
| mongoose | |
| .connect(MONGODB_URI) |
This file contains hidden or 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 url = require('url'); | |
| const path = require('path'); | |
| module.exports = function normalizeRequest(url) { | |
| let idx; | |
| const parsed = url.parse(uri, true); | |
| const pathname = path.join(parsed.pathname, '/'); | |
| pathname = pathname.slice(1, pathname.length - 1); | |
| idx = pathname.lastIndexOf('/'); |