Sunday, March 11, 2018

NodeJS - npm - search for packages

In NodeJS , to search for packages , we can use the command line utility of npm. Say we want to search for the plotting libraries available with node.

$ npm search plot
NAME                      | DESCRIPTION          | AUTHOR          | DATE       | VERSION  | KEYWORDS                
plot                      | Play your plot…      | =mgg            | 2017-11-10 | 0.0.2    | plot scenario story line
plotly.js                 | The open source…     | =alexcjohnson…  | 2018-03-09 | 1.35.2   | graphing plotting data visualization plotly
@nteract/transform-plotly | Plotly Transform     | =cabhishek…     | 2018-03-07 | 3.1.6    | 
plotly                    | Simple node.js…      | =alexander-dan… | 2015-12-30 | 1.0.6    | plotting graphs interactive data visualization
@superdyzio/plotly.js     | The open source…     | =superdyzio     | 2018-02-06 | 1.33.1   | graphing plotting data visualization plotly
react-plotly.js           | A plotly.js react…   | =plotly         | 2018-03-07 | 1.7.0    | graphing plotting data visualization plotly react
plot-grid                 | Plot grid component  | =dfcreative     | 2017-06-12 | 2.4.2    | plot grid lines axis logarithmic decibels frequency 
colormap                  | Great looking color… | =bpostlethwaite | 2017-09-28 | 2.3.0    | colormap color map color hex rgb color-space cubehel
regl-scatter2d            | Scatter2d plot…      | =dfcreative     | 2018-02-20 | 2.1.17   | regl plotly
chartjs-node              | Create Chart.js…     | =sedouard       | 2018-01-12 | 1.6.1    | Chartjs Charts Plots Graphs
sparkly                   | Generate sparklines… | =sindresorhus   | 2015-12-17 | 3.1.2    | spark sparkly line sparkline sparklines unicode data
@xudafeng/plotjs          | plotjs               | =xudafeng       | 2018-01-02 | 1.0.1    | plot
gerber-plotter            | Transform stream…    | =mcous          | 2016-07-23 | 1.1.0    | PCB Gerber drill circuit board transform stream hard
regl-error2d              | Render error bars…   | =dfcreative     | 2018-01-05 | 2.0.4    | regl plotly
umlplot                   | umlplot              | =xudafeng       | 2018-01-11 | 1.0.1    | plot uml
asciichart                | Nice-looking…        | =x84 =xpl       | 2017-12-10 | 1.5.7    | asciichart ascii chart charting charts console termi
snap-points-2d            | snap round 2d points | =bpostlethwaite… | 2017-08-28 | 3.2.0    | snap round iterated plot 2d data vis
aframe-plot-component     | Renders 3D plots of… | =mikebolt       | 2017-08-30 | 1.1.2    | aframe aframe-component aframe-vr vr mozvr webvr plo
@nteract/plotly           | A minimal version…   | =hasch =jdetle… | 2017-04-11 | 1.0.0    | plotly dist
regl-line2d               | Draw polyline with…  | =dfcreative     | 2018-02-19 | 2.1.5    | regl line2d gl-vis gl webgl polyline plotly
~$ 

There is a long pause initially, if you are searching for the first time this is because npm downloads repository information. There is also an online version:

https://www.npmjs.com/search


NodeJS - server installation - Ubuntu

Step 1: Get node setup file and rename as nodesource_step.sh

~$ wget https://deb.nodesource.com/setup_8.x -O nodesource_setup.sh
--2018-03-11 09:22:15--  https://deb.nodesource.com/setup_8.x
Resolving deb.nodesource.com (deb.nodesource.com)... 52.84.110.132, 52.84.110.18, 52.84.110.122, ...
Connecting to deb.nodesource.com (deb.nodesource.com)|52.84.110.132|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 12546 (12K) [text/plain]
Saving to: ‘nodesource_setup.sh’

nodesource_setup.sh                  100%[===================================================================>]  12.25K  --.-KB/s    in 0s      

2018-03-11 09:22:15 (85.2 MB/s) - ‘nodesource_setup.sh’ saved [12546/12546]

Step 2: Install the PPA to your configuration using the below command:
~$ sudo bash nodesource_setup.sh
[sudo] password for ubuntu: 

## Installing the NodeSource Node.js v8.x LTS Carbon repo...


## Populating apt-get cache...

+ apt-get update
Ign:1 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 http://security.ubuntu.com/ubuntu xenial-security InRelease                                           
Hit:3 http://in.archive.ubuntu.com/ubuntu xenial InRelease                                                  
Hit:4 http://dl.google.com/linux/chrome/deb stable Release              
Hit:5 http://in.archive.ubuntu.com/ubuntu xenial-updates InRelease      
Hit:6 http://in.archive.ubuntu.com/ubuntu xenial-backports InRelease
Hit:8 https://packagecloud.io/slacktechnologies/slack/debian jessie InRelease
Reading package lists... Done

## Confirming "xenial" is supported...

+ wget -qO /dev/null -o /dev/null 'https://deb.nodesource.com/node_8.x/dists/xenial/Release'

## Adding the NodeSource signing key to your keyring...

+ wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -
OK

## Creating apt sources list file for the NodeSource Node.js v8.x LTS Carbon repo...

+ echo 'deb https://deb.nodesource.com/node_8.x xenial main' > /etc/apt/sources.list.d/nodesource.list
+ echo 'deb-src https://deb.nodesource.com/node_8.x xenial main' >> /etc/apt/sources.list.d/nodesource.list

## Running `apt-get update` for you...

+ apt-get update
Ign:1 http://dl.google.com/linux/chrome/deb stable InRelease
Hit:2 http://dl.google.com/linux/chrome/deb stable Release                                                  
Get:3 https://deb.nodesource.com/node_8.x xenial InRelease [4,646 B]                                        
Hit:4 http://security.ubuntu.com/ubuntu xenial-security InRelease                                           
Hit:5 http://in.archive.ubuntu.com/ubuntu xenial InRelease               
Hit:7 http://in.archive.ubuntu.com/ubuntu xenial-updates InRelease
Get:8 https://deb.nodesource.com/node_8.x xenial/main Sources [761 B]
Get:9 https://deb.nodesource.com/node_8.x xenial/main amd64 Packages [1,003 B] 
Hit:10 http://in.archive.ubuntu.com/ubuntu xenial-backports InRelease               
Get:11 https://deb.nodesource.com/node_8.x xenial/main i386 Packages [1,005 B]
Hit:12 https://packagecloud.io/slacktechnologies/slack/debian jessie InRelease
Fetched 7,415 B in 3s (2,177 B/s)
Reading package lists... Done

## Run `apt-get install nodejs` (as root) to install Node.js v8.x LTS Carbon and npm

~$ 

Step 3: Install Node JS:

~$ sudo apt-get install nodejs
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  libllvm4.0 linux-headers-4.10.0-28 linux-headers-4.10.0-28-generic linux-headers-4.13.0-26 linux-headers-4.13.0-26-generic
  linux-image-4.10.0-28-generic linux-image-4.13.0-26-generic linux-image-extra-4.10.0-28-generic linux-image-extra-4.13.0-26-generic
  linux-signed-image-4.10.0-28-generic linux-signed-image-4.13.0-26-generic
Use 'sudo apt autoremove' to remove them.
The following NEW packages will be installed:
  nodejs
0 upgraded, 1 newly installed, 0 to remove and 95 not upgraded.
Need to get 12.7 MB of archives.
After this operation, 61.3 MB of additional disk space will be used.
Get:1 https://deb.nodesource.com/node_8.x xenial/main amd64 nodejs amd64 8.10.0-1nodesource1 [12.7 MB]
Fetched 12.7 MB in 13s (928 kB/s)                                                                                                               
Selecting previously unselected package nodejs.
(Reading database ... 316819 files and directories currently installed.)
Preparing to unpack .../nodejs_8.10.0-1nodesource1_amd64.deb ...
Unpacking nodejs (8.10.0-1nodesource1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up nodejs (8.10.0-1nodesource1) ...
~$ 

Step 4: Check the Node Versions installed :
~$ nodejs -v
v8.10.0
~$ npm -v
5.6.0

Step 5: Install Build Essential:

~$ sudo apt-get install build-essential
Reading package lists... Done
Building dependency tree       
Reading state information... Done
build-essential is already the newest version (12.1ubuntu2).
The following packages were automatically installed and are no longer required:
  libllvm4.0 linux-headers-4.10.0-28 linux-headers-4.10.0-28-generic linux-headers-4.13.0-26 linux-headers-4.13.0-26-generic
  linux-image-4.10.0-28-generic linux-image-4.13.0-26-generic linux-image-extra-4.10.0-28-generic linux-image-extra-4.13.0-26-generic
  linux-signed-image-4.10.0-28-generic linux-signed-image-4.13.0-26-generic
Use 'sudo apt autoremove' to remove them.
0 upgraded, 0 newly installed, 0 to remove and 95 not upgraded.
~$ 


source: https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions

source: https://www.digitalocean.com/community/tutorials/how-to-install-node-js-on-ubuntu-16-04



Thursday, February 22, 2018

NodeJS - server installation

Download the LTS version of NodeJS from the website: https://nodejs.org/en/

Step 1: Download using wget :
ubuntu@ip-172-31-58-211:~$ wget https://nodejs.org/dist/v8.9.4/node-v8.9.4-linux-x64.tar.xz
--2018-02-22 10:03:43--  https://nodejs.org/dist/v8.9.4/node-v8.9.4-linux-x64.tar.xz
Resolving nodejs.org (nodejs.org)... 104.20.22.46, 104.20.23.46, 2400:cb00:2048:1::6814:172e, ...
Connecting to nodejs.org (nodejs.org)|104.20.22.46|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11410120 (11M) [application/x-xz]
Saving to: node-v8.9.4-linux-x64.tar.xz

node-v8.9.4-linux-x64.tar.xz              100%[=====================================================================================>]  10.88M  45.0MB/s    in 0.2s    

2018-02-22 10:03:43 (45.0 MB/s) - node-v8.9.4-linux-x64.tar.xz saved [11410120/11410120]

ubuntu@ip-172-31-58-211:~$ which npm

Step 2: Uncompress the downloaded file
ubuntu@ip-172-31-58-211:~$ tar -xJvf node-v8.9.4-linux-x64.tar.xz 

Step 3: Perform the necessary movements of folders as shown below:
ubuntu@ip-172-31-58-211:~$ sudo mkdir /usr/lib/nodejs
ubuntu@ip-172-31-58-211:~$ sudo mv node-v8.9.4-linux-x64 /usr/lib/nodejs/
ubuntu@ip-172-31-58-211:~$ cd /usr/lib/nodejs
ubuntu@ip-172-31-58-211:/usr/lib/nodejs$ ls
node-v8.9.4-linux-x64
ubuntu@ip-172-31-58-211:/usr/lib/nodejs$ 
ubuntu@ip-172-31-58-211:/usr/lib/nodejs$ sudo mv node-v8.9.4-linux-x64 node-v8.9.4
ubuntu@ip-172-31-58-211:/usr/lib/nodejs$ ls
node-v8.9.4
ubuntu@ip-172-31-58-211:/usr/lib/nodejs$ 

Step 4: Refresh Profile:

ubuntu@ip-172-31-58-211:~$ . ~/.profile
ubuntu@ip-172-31-58-211:~$ which node
/usr/lib/nodejs/node-v8.9.4/bin/node
ubuntu@ip-172-31-58-211:~$ npm -v
5.6.0
ubuntu@ip-172-31-58-211:~$ 

Step 5: Testing our installation:

ubuntu@ip-172-31-58-211:~$ node -v
v8.9.4
ubuntu@ip-172-31-58-211:~$ 


ubuntu@ip-172-31-58-211:~$ npm version
{ npm: '5.6.0',
  ares: '1.10.1-DEV',
  cldr: '31.0.1',
  http_parser: '2.7.0',
  icu: '59.1',
  modules: '57',
  nghttp2: '1.25.0',
  node: '8.9.4',
  openssl: '1.0.2n',
  tz: '2017b',
  unicode: '9.0',
  uv: '1.15.0',
  v8: '6.1.534.50',
  zlib: '1.2.11' }
ubuntu@ip-172-31-58-211:~$ 


reference: https://github.com/nodejs/help/wiki/Installation

Wednesday, January 24, 2018

Python - Install matplotlib in Ubuntu using PIP

To install matplotlib in Ubuntu using PIP - execute the following command:

$ pip install matplotlib
Collecting matplotlib
  Downloading matplotlib-2.1.2-cp27-cp27mu-manylinux1_x86_64.whl (15.0MB)
    100% |████████████████████████████████| 15.0MB 81kB/s 
Collecting pyparsing!=2.0.4,!=2.1.2,!=2.1.6,>=2.0.1 (from matplotlib)
  Downloading pyparsing-2.2.0-py2.py3-none-any.whl (56kB)
    100% |████████████████████████████████| 61kB 3.4MB/s 
Collecting backports.functools-lru-cache (from matplotlib)
  Downloading backports.functools_lru_cache-1.4-py2.py3-none-any.whl
Collecting subprocess32 (from matplotlib)
  Downloading subprocess32-3.2.7.tar.gz (54kB)
    100% |████████████████████████████████| 61kB 4.2MB/s 
Collecting pytz (from matplotlib)
  Downloading pytz-2017.3-py2.py3-none-any.whl (511kB)
    100% |████████████████████████████████| 512kB 1.6MB/s 
Collecting six>=1.10 (from matplotlib)
  Downloading six-1.11.0-py2.py3-none-any.whl
Collecting python-dateutil>=2.1 (from matplotlib)
  Downloading python_dateutil-2.6.1-py2.py3-none-any.whl (194kB)
    100% |████████████████████████████████| 194kB 2.5MB/s 
Collecting cycler>=0.10 (from matplotlib)
  Downloading cycler-0.10.0-py2.py3-none-any.whl
Collecting numpy>=1.7.1 (from matplotlib)
  Downloading numpy-1.14.0-cp27-cp27mu-manylinux1_x86_64.whl (16.9MB)
    100% |████████████████████████████████| 16.9MB 70kB/s 
Building wheels for collected packages: subprocess32
  Running setup.py bdist_wheel for subprocess32 ... done
  Stored in directory: /home/shree/.cache/pip/wheels/7d/4c/a4/ce9ceb463dae01f4b95e670abd9afc8d65a45f38012f8030cc
Successfully built subprocess32
Installing collected packages: pyparsing, backports.functools-lru-cache, subprocess32, pytz, six, python-dateutil, cycler, numpy, matplotlib
Successfully installed backports.functools-lru-cache cycler matplotlib numpy-1.14.0 pyparsing python-dateutil-2.6.1 pytz-2017.3 six-1.11.0 subprocess32
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ 

Tuesday, January 16, 2018

Python - Install Pandas in Ubuntu using PIP

To install Pandas in Ubuntu using PIP - execute the following command:

$ sudo pip install pandas
[sudo] password for ubuntu: 
The directory '/home/ubuntu/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/ubuntu/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pandas
  Downloading pandas-0.22.0-cp27-cp27mu-manylinux1_x86_64.whl (24.3MB)
    100% |████████████████████████████████| 24.3MB 51kB/s 
Collecting pytz>=2011k (from pandas)
  Downloading pytz-2017.3-py2.py3-none-any.whl (511kB)
    100% |████████████████████████████████| 512kB 860kB/s 
Collecting numpy>=1.9.0 (from pandas)
  Downloading numpy-1.14.0-cp27-cp27mu-manylinux1_x86_64.whl (16.9MB)
    100% |████████████████████████████████| 16.9MB 73kB/s 
Requirement already satisfied (use --upgrade to upgrade): python-dateutil in /usr/local/lib/python2.7/dist-packages (from pandas)
Requirement already satisfied (use --upgrade to upgrade): six>=1.5 in /usr/local/lib/python2.7/dist-packages (from python-dateutil->pandas)
Installing collected packages: pytz, numpy, pandas
Successfully installed numpy-1.14.0 pandas-0.22.0 pytz-2017.3
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ 

Monday, January 15, 2018

Python - Install boto3 to connect to AWS in Ubuntu

To install boto3 in Ubuntu - you need to first install PIP:
http://sashankexpresstech.blogspot.in/2018/01/python-install-pip-in-ubuntu.html

After this, execute the following command to install boto3:


~$ sudo pip install boto3
The directory '/home/ubuntu/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/ubuntu/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting boto3
  Downloading boto3-1.5.14-py2.py3-none-any.whl (128kB)
    100% |████████████████████████████████| 133kB 854kB/s 
Collecting jmespath<1.0.0,>=0.7.1 (from boto3)
  Downloading jmespath-0.9.3-py2.py3-none-any.whl
Collecting s3transfer<0.2.0,>=0.1.10 (from boto3)
  Downloading s3transfer-0.1.12-py2.py3-none-any.whl (59kB)
    100% |████████████████████████████████| 61kB 944kB/s 
Collecting botocore<1.9.0,>=1.8.28 (from boto3)
  Downloading botocore-1.8.28-py2.py3-none-any.whl (4.0MB)
    100% |████████████████████████████████| 4.0MB 274kB/s 
Collecting futures<4.0.0,>=2.2.0; python_version == "2.6" or python_version == "2.7" (from s3transfer<0.2.0,>=0.1.10->boto3)
  Downloading futures-3.2.0-py2-none-any.whl
Collecting python-dateutil<3.0.0,>=2.1 (from botocore<1.9.0,>=1.8.28->boto3)
  Downloading python_dateutil-2.6.1-py2.py3-none-any.whl (194kB)
    100% |████████████████████████████████| 194kB 860kB/s 
Collecting docutils>=0.10 (from botocore<1.9.0,>=1.8.28->boto3)
  Downloading docutils-0.14-py2-none-any.whl (543kB)
    100% |████████████████████████████████| 552kB 808kB/s 
Collecting six>=1.5 (from python-dateutil<3.0.0,>=2.1->botocore<1.9.0,>=1.8.28->boto3)
  Downloading six-1.11.0-py2.py3-none-any.whl
Installing collected packages: jmespath, futures, six, python-dateutil, docutils, botocore, s3transfer, boto3
Successfully installed boto3-1.5.14 botocore-1.8.28 docutils-0.14 futures-3.2.0 jmespath-0.9.3 python-dateutil-2.6.1 s3transfer-0.1.12 six-1.11.0
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
~$ 

Python - Install pip in Ubuntu

To Install python pip in Ubuntu open the terminal and execute the following command:

~$ sudo apt-get install python-pip
[sudo] password for ubuntu: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  libpython-all-dev python-all python-all-dev python-pip-whl python-wheel
The following NEW packages will be installed:
  libpython-all-dev python-all python-all-dev python-pip python-pip-whl python-wheel
0 upgraded, 6 newly installed, 0 to remove and 12 not upgraded.
Need to get 1,306 kB of archives.
After this operation, 2,084 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 libpython-all-dev amd64 2.7.11-1 [992 B]
Get:2 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 python-all amd64 2.7.11-1 [978 B]
Get:3 http://in.archive.ubuntu.com/ubuntu xenial/main amd64 python-all-dev amd64 2.7.11-1 [1,000 B]
Get:4 http://in.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 python-pip-whl all 8.1.1-2ubuntu0.4 [1,110 kB]
Get:5 http://in.archive.ubuntu.com/ubuntu xenial-updates/universe amd64 python-pip all 8.1.1-2ubuntu0.4 [144 kB]
Get:6 http://in.archive.ubuntu.com/ubuntu xenial/universe amd64 python-wheel all 0.29.0-1 [48.0 kB]
Fetched 1,306 kB in 2s (558 kB/s)      
Selecting previously unselected package libpython-all-dev:amd64.
(Reading database ... 190040 files and directories currently installed.)
Preparing to unpack .../libpython-all-dev_2.7.11-1_amd64.deb ...
Unpacking libpython-all-dev:amd64 (2.7.11-1) ...
Selecting previously unselected package python-all.
Preparing to unpack .../python-all_2.7.11-1_amd64.deb ...
Unpacking python-all (2.7.11-1) ...
Selecting previously unselected package python-all-dev.
Preparing to unpack .../python-all-dev_2.7.11-1_amd64.deb ...
Unpacking python-all-dev (2.7.11-1) ...
Selecting previously unselected package python-pip-whl.
Preparing to unpack .../python-pip-whl_8.1.1-2ubuntu0.4_all.deb ...
Unpacking python-pip-whl (8.1.1-2ubuntu0.4) ...
Selecting previously unselected package python-pip.
Preparing to unpack .../python-pip_8.1.1-2ubuntu0.4_all.deb ...
Unpacking python-pip (8.1.1-2ubuntu0.4) ...
Selecting previously unselected package python-wheel.
Preparing to unpack .../python-wheel_0.29.0-1_all.deb ...
Unpacking python-wheel (0.29.0-1) ...
Processing triggers for man-db (2.7.5-1) ...
Setting up libpython-all-dev:amd64 (2.7.11-1) ...
Setting up python-all (2.7.11-1) ...
Setting up python-all-dev (2.7.11-1) ...
Setting up python-pip-whl (8.1.1-2ubuntu0.4) ...
Setting up python-pip (8.1.1-2ubuntu0.4) ...
Setting up python-wheel (0.29.0-1) ...

To confirm the installation:

~$ which pip
/usr/bin/pip
~$