Category: General

  • Install PM2 in AWS LightSail, EC2

    Install PM2 in AWS LightSail, EC2

    Install PM2 globally. This is the first step. Execute below commands in AWS terminal.

    sudo npm install pm2@latest -g

    Make PM2 run during startup. This will daemonize pm2 and initialize it on system reboots. This step is very important. This will automatically start pm2 in case we restart our server instance.

    pm2 startup
    

    PM2 commands

    PM2 is a Production Process Manager for Node.js applications
                         with a built-in Load Balancer.
    
                    Start and Daemonize any application:
                    $ pm2 start app.js
    
                    Load Balance 4 instances of api.js:
                    $ pm2 start api.js -i 4
    
                    Monitor in production:
                    $ pm2 monitor
    
                    Make pm2 auto-boot at server restart:
                    $ pm2 startup
    
                    To go further checkout:
                    http://pm2.io/
  • Upgrade NodeJS in AWS LightSail

    We will discuss how to upgrade NodeJS version in an Amazon LightSail instance.

    SSH into your AWS LightSail instance.

    Get the current NodeJS version

    First get the NodeJS version and where its installed.

    node -v

    The above command will display the currently installed node version.

    Now get the where Node JS is installed

    which node

    This will display the node location. We need this later.

    Update Package Lists

    Before installing a new version of Node.js, it’s a good practice to update your package lists.

    sudo apt-get update

    Download and Install Node.js

    We will install the node version 20.0.1. Change this to version of your choice. The below example commands will be using version 20.0.1

    Create a folder to download the files. We will create a folder named temp

    mkdir temp
    cd temp

    Now we have created the directory and opened it

    You can download the Node.js 20.10.0 binary from the official website and install it. Execute below commands one by one.

    # Replace “20.10.0” with the actual version number
    wget https://nodejs.org/dist/v20.10.0/node-v20.10.0-linux-x64.tar.xz

    tar -xf node-v20.10.0-linux-x64.tar.xz

    Now your directory should look like this.

    temp directory contents

    Now we will rename the existing node folder to node-old.

    Navigate to the current node parent installation directory which we got from the above command which node . In our case the parent directory is /opt/bitnami

    sudo mv node node-old
    sudo mkdir node

    Now navigate back to our temp directory and copy the new node files to the new node directory we created above.

    sudo cp -r node-v20.10.0-linux-x64/* /opt/bitnami/node

    New Node version files are copied.

    Verify the Installation

    Verify the new node and npm versions.

    node -v
    npm -v

    Happy Coding…. 🍺

  • WordPress malware ch.trainresistor.cc

    WordPress malware ch.trainresistor.cc

    Issue: WordPress site is not loading properly. Styles are not loading in the page. All requested are redirecting to an external URL ch.trainresistor.cc

    Cause: This is due to a vulnerabilty in a the wordpress plugin – “PublishPress Capabilities – User Role Access, Editor Permissions, Admin” More info on this here

    Resolution: This malware affects files and database. Search for trainresistor in your PHP files contents. Replace it with your site URL.

    Open the database using phpMyAdmin from your server control panel. Select your site database and then select wp_options table.

    Update the fields siteurl and admin_email to your website url and admin email. See below image

    After this open your site. It should work.

    Remove unused plugins and update all plugins which are in use. Restore files and database if you have backup.

  • View WIFI password from command prompt

    Have you forgot your wifi password. You can view it from your command prompt if you know the wifi name. Open command prompt, type below command and press enter key.

    netsh wlan show profile YOUR-WIFI-NAME key=clear


    This will show the WIFI details along with the password.

  • 5 design resources for illustrations

    These are the 5 design resources I mainly use.

    1. humaaans

    An illustration from humaaaans

    Website: https://www.humaaans.com/

    License : CC – Free for commercial or personal use

    As the website name says, the illustrations are mostly related to humans. You can download the assets in png, svg, sketch formats

    Download formats: png, svg, sketch

    2. Undraw

    Website : https://undraw.co/

    License: Free to use for personal and commercial projects, without the need to include attribution.

    Even though its free, whenever possible give credits to the designer/developer. These things needs time and effort.

    Download formats: svg, png

    3. Pixabay

    One of the best sites for free vectors and png files

    Christmas, Background, Snow, Flake, Ball, Winter, Red
    Christmas background from Pixabay

    Website: https://pixabay.com/

    License: mostly Pixabay License – Free for commercial use, No attribution required

    Format: png, svg

    4. FreeVector

    This site has free as well as paid assets

    Hand Drawn Christmas Ornament Vector
    from freevector.com

    License: Attribution required

    Format: svg, png

  • GetSpriteXY

    GetSpriteXY – a tool to find icon position in a CSS sprite

    I was working with some css sprites in a project. There was sprite with lot of small icons. It was difficult finding the position of icons inside the sprite. I used to open the sprite in Photoshop and find the X and Y position of the icon needed. And this position was used in the CSS class. To make the process simpler a tool was created where you can upload the sprite and using mouse draw a box around the icon. The tool will generate the CSS style for you.

    Please check it at
    https://getspritexy.netlify.com/

    The source is available in GitHub, fork/clone and play with it

  • Remove map files in React CRA

    Map files are generated by default when you do a build using webpack.
    If you don’t want .map files in your build you can do the below steps.

    1. Create a new .env in your project root (don’t put it in src folder)
    2. Add GENERATE_SOURCEMAP=false in your .env file
    3. Execute command npm run build, this should build files without any map files.

    Your .env file will look like this.

  • DOS games of 90s

    DOS games of 90s

    These were the DOS games I used to play

    • Wolf 3D
    • Biomenace
    • Pacman
    • Aladdin
  • First computer

    ZX spectrum

    This was my first computer, way back in early 90’s. This does’nt had any monitor, it was connect to our television (the big fat CRT television)

    Used to do programming in BASIC and played some games. Did lot of small programs in BASIC. The source was lost somewhere as there were no much storage devices at that time.

Design a site like this with WordPress.com
Get started