Cannot find name 'require' after upgrading to Angular4

Source: https://stackoverflow.com/questions/43104114/cannot-find-name-require-after-upgrading-to-angular4

The problem (as outlined in typescript getting error TS2304: cannot find name ' require') is that the type definitions for node are not installed.
With a projected genned with @angular/cli 1.x, the specific steps should be:
Step 1: install @types/node with either of the following:
- npm install --save @types/node
- yarn add @types/node
Step 2: - edit your src/tsconfig.app.json file and add the following in place of the empty "types": [], which should already be there:
...
"types": [ "node" ],
"typeRoots": [ "../node_modules/@types" ]
...
If I've missed anything, jot a comment and I'll edit my answer.

Skip Initializing A Git Repository / Skip First Git Commit

Source: https://medium.com/codingthesmartway-com-blog/creating-angular-projects-with-angular-cli-e32b2cb486da

By default a Git repository is created within the Angular project directory. You can skip this step by using the --skip-git option in the following way:
$ ng new [name] --skip-git
If you want to create a Git repository for the newly generated Angular project but only would like to skip the initial commit you can also use flag --skip-commit instead.

NodeJS Express multiple route file through one route file

Source: https://stackoverflow.com/questions/41182313/nodejs-express-multiple-route-file-through-one-route-file?rq=1
https://stackoverflow.com/questions/6059246/how-to-include-route-handlers-in-multiple-files-in-express

I'd do it a bit different than @Shaharyar
routes.js
var express = require('express');
var router = express.Router();

router.get('/', function(req, res) {
  res.send('Welcome to Node JS V1');
});

router.use('/users', require('./users').router);

module.exports.router = router;
users.js
var express = require('express');
var router = express.Router();

router.get('/',function(req, res){    
  res.send('Get all users.');
});

router.post('/', function(req, res) {
  // Create user
  res.send('Some response.');
});

module.exports.router = router;

To simplify it I'd drop the .router on module.exports and do.
router.use('/users', require('./users'));
Also the same for the route.js file, then in your server.js or wherever:
router.use('/api/v1', require('./routes'));
router.use('/api/v2', require('./routes2'));




If you want to put the routes in a separate file, for example routes.js, you can create the routes.js file in this way:
module.exports = function(app){

    app.get('/login', function(req, res){
        res.render('login', {
            title: 'Express Login'
        });
    });

    //other routes..
}
And then you can require it from app.js passing the app object in this way:
require('./routes')(app);
Have also a look at these examples

How to upgrade Angular CLI to the latest version

Source:

After reading some issues reported on the GitHub repository, I found the solution.
In order to update the angular-cli package installed globally in your system, you need to run:
npm uninstall -g angular-cli
npm cache clean or npm cache verify (if npm > 5)
npm install -g @angular/cli@latest
Depending on your system, you may need to prefix the above commands with sudo.
Also, most likely you want to also update your local project version, because inside your project directory it will be selected with higher priority than the global one:
rm -rf node_modules
npm uninstall --save-dev angular-cli
npm install --save-dev @angular/cli@latest
npm install
thanks grizzm0 for pointing this out on GitHub.
After updating your CLI, you probably want to update your Angular version too.
Note: if you are updating to Angular CLI 6+ from an older version, you might need to read this.
Edit: In addition, if you were still on a 1.x version of the cli, you need to convert your angular-cli.json to angular.json, which you can do with the following command:
ng update @angular/cli --from=1.7.4 --migrate-only
(check this for more details).

'ls' in CMD on Windows not recognized

Source: https://stackoverflow.com/questions/42727245/ls-in-cmd-on-windows-not-recognized

echo @dir %* > %systemroot%\system32\ls.bat will allow you to use ls instead of dir, similarly to an alias

MySQL: multiple tables or one table with many columns?

Source: https://stackoverflow.com/questions/9774715/mysql-multiple-tables-or-one-table-with-many-columns

Any time information is one-to-one (each user has one name and password), then it's probably better to have it one table, since it reduces the number of joins the database will need to do to retrieve results. I think some databases have a limit on the number of columns per table, but I wouldn't worry about it in normal cases, and you can always split it later if you need to.
If the data is one-to-many (each user has thousands of rows of usage info), then it should be split into separate tables to reduce duplicate data (duplicate data wastes storage space, cache space, and makes the database harder to maintain).
You might find the Wikipedia article on database normalization interesting, since it discusses the reasons for this in depth:
Database normalization is the process of organizing the fields and tables of a relational database to minimize redundancy and dependency. Normalization usually involves dividing large tables into smaller (and less redundant) tables and defining relationships between them. The objective is to isolate data so that additions, deletions, and modifications of a field can be made in just one table and then propagated through the rest of the database via the defined relationships.
Denormalization is also something to be aware of, because there are cases where repeating data is better (since it reduces the amount of work the database needs to do when reading data). I'd highly recommend making your data as normalized as possible to start out, and only denormalize if you're aware of performance problems in specific queries.

anti-pattern là gì

  Trong công nghệ và lập trình, Anti-pattern (mẫu phản diện) là những giải pháp bề ngoài có vẻ hiệu quả để giải quyết một vấn đề phổ biến, ...