Posts

Showing posts from June, 2021

Python: How to use Pyenv ?

Image
Hello, Today I am going to write a small article on how to use pyenv to install your required version of python and set it as globally across sytem or just local to project directory. Installation If you are using Mac, you can simply use brew brew install pyenv For Other operating system you can follow instruction at given Github Repository . I have given them below for CentOS, but they are similar for Debian as well, just adjust your package manager. yum install curl git -y curl https://pyenv.run | bash Paste below lines into your shell profile ~/.bashrc or ~/.zshrc export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init --path)" And restart your shell, you can follow any method available exec $SHELL # or source ~/.bashrc So pyenv installed now in your system. Now Lets see how to use it. To list available commands we c

Python :F-Strings

Image
In Python, to format output statements you can do in several ways as below. 1. Regular print() using parameter data types 2. Using .format() 3. Using F-string I will write small examples using all 3 types. 1. Regular print() using parameter data types In the below example I will define values and print same for 3 most used data types which are int, string, float >>> a = 10 >>> b = "Hello" >>> c = 98.9 >>> print("a value is %d b value is %s c value is %f" %(a, b, c)) a value is 10 b value is Hello c value is 98.900000 If you observe the float this is not what I have defined actually, but we are not without options either, we can restrict how many decimals we want. Check below code >>> print("a value is %d b value is %s c value is %.2f" %(a, b, c)) a value is 10 b value is Hello c value is 98.90 >>> print("a value is %d b value is %s c value is %.3f" %(a, b, c)) a value

How to fix checkPermissions Missing write access to /usr/local/lib/node_modules error ?

Image
If you are working in a Node JS environment and without root access or sudo access, you might get an error as checkPermissions Missing write access to /usr/local/lib/node_modules like below npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules npm ERR! code EACCES npm ERR! syscall access npm ERR! path /usr/local/lib/node_modules npm ERR! errno -13 npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules' npm ERR! [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] { npm ERR! errno: -13, npm ERR! code: 'EACCES', npm ERR! syscall: 'access', npm ERR! path: '/usr/local/lib/node_modules' npm ERR! } npm ERR! one solution to this problem is changing the permission of the folder /usr/local/lib/node_modules for the current user, but thats not recommended and what if its not in your hands to change the permission. One thing we can do to address this problem is modify the

How to install nodejs in CentOS ?

Image
If you choose default yum install of nodejs you will get 6.x release which is very old. To install latest version of nodejs in centos you can execute below command Command 1 curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash - You will get output as below [vagrant@localhost ps-sinonjs]$ curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash - ## Installing the NodeSource Node.js 14.x repo... ## Inspecting system... + rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release + uname -m ## Confirming "el7-x86_64" is supported... + curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_14.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm' ## Downloading release setup RPM... + mktemp + curl -sL -o '/tmp/tmp.KNA1QsAK2D' 'https://rpm.nodesource.com/pub_14.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm' ## Insta

How to launch Sublime text editor from terminal in Macbook ?

As you all know, Sublime is one of the famous and lite weight text editor and can be used for application development for almost every programming language available today. For VS Code to launch editor from terminal, you can use code from terminal. But for Sublime there is no direct method. To achieve this in sublime we can achieve it in 2 methods I believe. Lets see one by one Using Soft Link After creating soft link just type sublime in your terminal and sublime open. ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /usr/local/bin/sublime Using alias Add alias like below in your .bashrc or ~/.bash_profile files subl='/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl' then do load the changes with source source ~/.bashrc Hope this helps. Thanks Raja