Studies

NPM Commands
npm install  - installs the package at the folder where the command is run.
npm install  --save - installs the package and saves the package entry in package.json
npm install - installs all the packages in package.json


***********************************************************
To save a package to package.json as dev dependencies:

npm install "$package" --save-dev
When you run npm install it will install both devDependencies and dependencies, to avoid install devDependencies run:

npm install --production
***********************************************************
set NODE_ENV=production
Run the above command in production environment.
***********************************************************

npm init - to create package.json

Install package globally. Global packages are usually for executable commands.
$ npm install  -g
# example
$ npm install express -g
# now we can use express to generate a new app
$ express new app


Install package locally. Local packages are for the use of require in the app.
$ cd /path/to/the/project
$ npm install 
# example
$ npm install express
# now you can use `var express = require( 'express' );` in your app



Uninstall global package.
$ npm uninstall  -g
# example
$ npm uninstall express -g



Uninstall local package.
$ cd /path/to/the/project
$ npm uninstall 
# example
$ npm uninstall express


Search package.
npm search 
# example
$ npm search express



List global packages.
$ npm ls -g



List global packages detail.
$ npm ls -gl



List local packages.
$ cd /path/to/the/project
$ npm ls


List local packages detail.
$ cd /path/to/the/project
$ npm ls -l



Update global packages.
$ npm update -g



Update local packages.
$ cd /path/to/the/project
$ npm update
Cool SQL Commands
To know all connections:
USE master
SELECT * FROM sys.sysprocesses WHERE dbid = DB_ID('DBName')



http://www.sqlmatters.com/Articles/sp_who2%20-%20filtering%20and%20sorting%20the%20results.aspx


Take a Database Offline using T-SQL and wait for existing connections to close

ALTER DATABASE AdventureWorks SET OFFLINE
The command waits for existing connections to close and also does not accept any new connections. Use at discretion!


Take a Database Offline Immediately using T-SQL

ALTER DATABASE AdventureWorks
SET OFFLINE WITH ROLLBACK IMMEDIATE

Bring back the Database Online

ALTER DATABASE AdventureWorks
SET ONLINE



To kill existing sql connections, use Activity Monitor. Either by right clicking the server and selecting Activity Monitor.  Opening the Activity Monitor, you can view all process info. You should be able to find the locks for the database you're interested in and kill those locks, which will also kill the connection.

Or Run the below Query:
USE master
GO

DECLARE @kill varchar(8000) = '';
SELECT @kill = @kill + 'kill ' + CONVERT(varchar(5), spid) + ';'
FROM master..sysprocesses 
WHERE dbid = db_id('MyDB')

EXEC(@kill);
Page 4 of 5