<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Sandip Basnet</title>
    <description>The latest articles on Forem by Sandip Basnet (@sandipbasnet).</description>
    <link>https://forem.com/sandipbasnet</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F143290%2F2067dec7-05ad-48dc-b12d-f123ad45646d.jpg</url>
      <title>Forem: Sandip Basnet</title>
      <link>https://forem.com/sandipbasnet</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sandipbasnet"/>
    <language>en</language>
    <item>
      <title>How to find twitter accounts with similar profile picture?</title>
      <dc:creator>Sandip Basnet</dc:creator>
      <pubDate>Mon, 09 Jan 2023 09:26:57 +0000</pubDate>
      <link>https://forem.com/sandipbasnet/how-to-find-twitter-accounts-with-similar-profile-picture-19e9</link>
      <guid>https://forem.com/sandipbasnet/how-to-find-twitter-accounts-with-similar-profile-picture-19e9</guid>
      <description>&lt;p&gt;I want to build a service that can tell us what profiles on Twitter have a particular profile picture(Sample: &lt;a href="https://www.nftinspect.xyz/twitter-search/nft?chain=ETH&amp;amp;token=4081&amp;amp;contract=0x8a90cab2b38dba80c64b7734e58ee1db38b8992e"&gt;https://www.nftinspect.xyz/twitter-search/nft?chain=ETH&amp;amp;token=4081&amp;amp;contract=0x8a90cab2b38dba80c64b7734e58ee1db38b8992e&lt;/a&gt;), I have gone through all references of Twitter APIs (&lt;a href="https://developer.twitter.com/en/docs/api-reference-index"&gt;https://www.nftinspect.xyz&lt;/a&gt;) but was not able to find one to resolve my problem, and thought about scanning via search but that doesn't sound scalable, any folks with previous or similar experiences? I would really appreciate the help :)&lt;br&gt;
Note, I have found one tool(&lt;a href="https://www.nftinspect.xyz"&gt;https://www.nftinspect.xyz&lt;/a&gt;), but unfortunately, it is shutting down on 17th Jan.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>node</category>
      <category>twitter</category>
    </item>
    <item>
      <title>Create user with read only permission in PostgreSQL</title>
      <dc:creator>Sandip Basnet</dc:creator>
      <pubDate>Tue, 03 Jan 2023 10:35:14 +0000</pubDate>
      <link>https://forem.com/sandipbasnet/create-user-with-read-only-permission-in-postgresql-1g4h</link>
      <guid>https://forem.com/sandipbasnet/create-user-with-read-only-permission-in-postgresql-1g4h</guid>
      <description>&lt;p&gt;Steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;create role:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;CREATE ROLE readaccess;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;grant access to existing tables:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;GRANT USAGE ON SCHEMA public TO readaccess;&lt;br&gt;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;grant access to future tables:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create user with password:&lt;br&gt;
&lt;br&gt;
&lt;code&gt;CREATE USER grafana WITH PASSWORD 'secretpass@dev';&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;grant access to user: &lt;code&gt;GRANT readaccess TO grafana;&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>performance</category>
      <category>cloud</category>
      <category>discuss</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Migrating postgres db from CLI</title>
      <dc:creator>Sandip Basnet</dc:creator>
      <pubDate>Fri, 23 Dec 2022 02:56:07 +0000</pubDate>
      <link>https://forem.com/sandipbasnet/migrating-postgres-db-from-cli-2lkj</link>
      <guid>https://forem.com/sandipbasnet/migrating-postgres-db-from-cli-2lkj</guid>
      <description>&lt;p&gt;Migrating postgres db within same/different server via cli.&lt;br&gt;
1) Export dump from existing db: &lt;code&gt;pg_dump -U postgres -h &amp;lt;host_address&amp;gt; -p 5432 &amp;lt;db_name&amp;gt; &amp;gt; &amp;lt;dump/backup_file_name&amp;gt;.sql&lt;/code&gt;&lt;br&gt;
2) Import dump to new db: &lt;code&gt;psql -h &amp;lt;new_db_host_address&amp;gt; -d &amp;lt;new_db_name&amp;gt; -U postgres -f &amp;lt;dump/backup_file_name&amp;gt;.sql&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Note, __In both of the cases you will be prompted with password input.&lt;/p&gt;

</description>
      <category>postgres</category>
      <category>migration</category>
      <category>pgdump</category>
    </item>
    <item>
      <title>Create a new post from WP REST API</title>
      <dc:creator>Sandip Basnet</dc:creator>
      <pubDate>Tue, 06 Sep 2022 03:00:16 +0000</pubDate>
      <link>https://forem.com/sandipbasnet/create-a-new-post-from-wp-rest-api-4app</link>
      <guid>https://forem.com/sandipbasnet/create-a-new-post-from-wp-rest-api-4app</guid>
      <description>&lt;p&gt;&lt;a href="https://youtube.com/clip/UgkxIB3V8weS6qWODa09RI9TxcdJXFgZtLsj"&gt;Create a new post from WP REST API&lt;/a&gt;&lt;/p&gt;

</description>
      <category>wordpress</category>
      <category>wprestapi</category>
      <category>rest</category>
      <category>authentication</category>
    </item>
    <item>
      <title>NodeJs CRUD</title>
      <dc:creator>Sandip Basnet</dc:creator>
      <pubDate>Sat, 20 Aug 2022 00:30:00 +0000</pubDate>
      <link>https://forem.com/sandipbasnet/nodejs-crud-5545</link>
      <guid>https://forem.com/sandipbasnet/nodejs-crud-5545</guid>
      <description>&lt;p&gt;We will be building REST APIS using node express and sequelize.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;create folder: &lt;code&gt;mkdir workshop &amp;amp;&amp;amp; cd workshop&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;initialize the project: &lt;code&gt;npm init&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Install required dependencies: &lt;code&gt;npm install express sequelize pg pg-hstore cors --save&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Setup express web server: 
in the root folder create &lt;code&gt;app.js&lt;/code&gt; file and add:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const express = require("express");
const bodyParser = require("body-parser");
const cors = require("cors");
const app = express();
var corsOptions = {
  origin: "*"
};
app.use(cors(corsOptions));
// parse requests of content-type - application/json
app.use(express.json());
// parse requests of content-type - application/x-www-form-urlencoded
app.use(express.urlencoded({ extended: true }));
// simple route
app.get("/", (req, res) =&amp;gt; {
  res.json({ message: "Hello World!." });
});
// set port, listen for requests
const PORT = process.env.PORT || 5000;
app.listen(PORT, () =&amp;gt; {
  console.log(`Server is running on port ${PORT}.`);
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;where:&lt;br&gt;
Express: this module is used for building the Rest apis.&lt;br&gt;
cors: provides Express middleware to enable CORS with various options.&lt;br&gt;
body-parser: parse the request body&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;connect database:
create config folder and add db.config.js file and add:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = {
  HOST: "localhost",
  PORT: 5432,
  USER: "postgres",
  PASSWORD: "postgres",
  DB: "testdb",
  dialect: "postgres",
  pool: {
    max: 5,
    min: 0,
    acquire: 30000,
    idle: 10000
  }
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;where pool is optional, it will be used for Sequelize connection pool configuration:&lt;/p&gt;

&lt;p&gt;max: maximum number of connection in pool&lt;br&gt;
min: minimum number of connection in pool&lt;br&gt;
idle: maximum time, in milliseconds, that a connection can be idle before being released&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Initialize Sequelize
create database/models and add index.js with:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const dbConfig = require("../config/db.config.js");
const Sequelize = require("sequelize");
const sequelize = new Sequelize(dbConfig.DB, dbConfig.USER, dbConfig.PASSWORD, {
  host: dbConfig.HOST,
  port: dbConfig.PORT,
  dialect: dbConfig.dialect,
  operatorsAliases: false,
  pool: {
    max: dbConfig.pool.max,
    min: dbConfig.pool.min,
    acquire: dbConfig.pool.acquire,
    idle: dbConfig.pool.idle
  }
});
const db = {};
db.Sequelize = Sequelize;
db.sequelize = sequelize;
db.plans = require("./plan.model.js")(sequelize, Sequelize);
module.exports = db;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;and update app.js with (put is just below the &lt;code&gt;const app = express();&lt;/code&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const db = require("./database/models");
db.sequelize.sync()
  .then(() =&amp;gt; {
    console.log("Synced db.");
  })
  .catch((err) =&amp;gt; {
    console.log("Failed to sync db: " + err.message);
  });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In development, you may need to drop existing tables and re-sync database. Just use force: true as following code:&lt;br&gt;
&lt;code&gt;db.sequelize.sync({ force: true }).then(() =&amp;gt; {&lt;br&gt;
  console.log("Drop and re-sync db.");&lt;br&gt;
});&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Define the Sequelize Model
In models folder, create plan.model.js file like this:
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = (sequelize, Sequelize) =&amp;gt; {
  const Plan = sequelize.define("plan", {
    title: {
      type: Sequelize.STRING
    },
    description: {
      type: Sequelize.STRING
    },
    completed: {
      type: Sequelize.BOOLEAN
    }
  });
  return Plan;
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;This Sequelize Model represents paln table in PostgreSQL database. These columns will be generated automatically: id, title, description, completed, createdAt, updatedAt.&lt;/p&gt;

&lt;p&gt;After initializing Sequelize, we don’t need to write CRUD functions, Sequelize supports all of them:&lt;/p&gt;

&lt;p&gt;create a new plan: create(object)&lt;br&gt;
find a Plan by id: findByPk(id)&lt;br&gt;
get all Plans: findAll()&lt;br&gt;
update a Plan by id: update(data, where: { id: id })&lt;br&gt;
remove a Plan: destroy(where: { id: id })&lt;br&gt;
remove all Plans: destroy(where: {})&lt;br&gt;
find all Plans by title: findAll({ where: { title: ... } })&lt;br&gt;
These functions will be used in our Controller.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Add controllers
create controllers folder and add &lt;code&gt;plan.controller.js&lt;/code&gt; file with following functions: &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;create&lt;br&gt;
findAll&lt;br&gt;
findOne&lt;br&gt;
update&lt;br&gt;
delete&lt;br&gt;
deleteAll&lt;br&gt;
findAllCompleted&lt;br&gt;
i.e.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const db = require("../database/models");
const Plans = db.plans;
const Op = db.Sequelize.Op;
// Create and Save a new Plan
exports.create = (req, res) =&amp;gt; {

};
// Retrieve all P from the database.
exports.findAll = (req, res) =&amp;gt; {

};
// Find a single Plan with an id
exports.findOne = (req, res) =&amp;gt; {

};
// Update a Plan by the id in the request
exports.update = (req, res) =&amp;gt; {

};
// Delete a Plan with the specified id in the request
exports.delete = (req, res) =&amp;gt; {

};
// Delete all Plans from the database.
exports.deleteAll = (req, res) =&amp;gt; {

};
// Find all completed Plans
exports.findAllCompleted = (req, res) =&amp;gt; {

};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Implementations:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;create:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exports.create = (req, res) =&amp;gt; {
    // Validate request
    if (!req.body.title) {
        res.status(400).send({
            message: "Title can not be empty!"
        });
        return;
    }
    // Create a Plan
    const plan = {
        title: req.body.title,
        description: req.body.description,
        completed: req.body.completed ? req.body.completed : false
    };
    // Save plan in the database
    Plans.create(plan)
        .then(data =&amp;gt; {
            res.send(data);
        })
        .catch(err =&amp;gt; {
            res.status(500).send({
                message:
                    err.message || "Some error occurred while creating the plan."
            });
        });
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;retrive
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exports.findAll = (req, res) =&amp;gt; {
    const title = req.query?.title;
    var condition = title ? { title: { [Op.iLike]: `%${title}%` } } : null;
    Plans.findAll({ where: condition })
        .then(data =&amp;gt; {
            res.send(data);
        }).catch(err =&amp;gt; {
            res.status(500).send({
                message:
                    err.message || "Some error occurred while retrieving plans."
            });
        });
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Retrieve a single object
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exports.findOne = (req, res) =&amp;gt; {
    const id = req.params.id;
    Plans.findByPk(id)
        .then(data =&amp;gt; {
            if (data) {
                res.send(data);
            } else {
                res.status(404).send({
                    message: `Cannot find Plan with id = ${id}.`
                });
            }
        }).catch(err =&amp;gt; {
            res.status(500).send({
                message: "Error retrieving Plan with id=" + id
            });
        });
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Update an object
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exports.update = (req, res) =&amp;gt; {
    const id = req.params.id;
    Plans.update(req.body, {
        where: { id: id }
    })
        .then(num =&amp;gt; {
            if (num == 1) {
                res.send({
                    message: "Plan was updated successfully."
                });
            } else {
                res.send({
                    message: `Cannot update Plan with id=${id}. Maybe Plan was not found or req.body is empty!`
                });
            }
        }).catch(err =&amp;gt; {
            res.status(500).send({
                message: "Error updating Plan with id=" + id
            });
        });
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Delete an object
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exports.delete = (req, res) =&amp;gt; {
    const id = req.params.id;
    Plans.destroy({
        where: { id: id }
    })
        .then(num =&amp;gt; {
            if (num == 1) {
                res.send({
                    message: "Plan was deleted successfully!"
                });
            } else {
                res.send({
                    message: `Cannot delete Plan with id=${id}. Maybe Plan was not found!`
                });
            }
        }).catch(err =&amp;gt; {
            res.status(500).send({
                message: "Could not delete Plan with id=" + id
            });
        });
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Delete all objects
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exports.deleteAll = (req, res) =&amp;gt; {
    Plans.destroy({
        where: {},
        truncate: false
    })
        .then(nums =&amp;gt; {
            res.send({
                message: `${nums} Plans were deleted successfully!})`
            }).catch(err =&amp;gt; {
                res.status(500).send({
                    message:
                        err.message || "Some error occurred while removing all plans."
                });
            });
        });
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Find all objects by condition
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;exports.findAllCompleted = (req, res) =&amp;gt; {
    Plans.findAll({ where: { completed: true } })
        .then(data =&amp;gt; {
            res.send(data);
        }).catch(err =&amp;gt; {
            res.status(500).send({
                message:
                    err.message || "Some error occurred while retrieving Plans."
            });
        });
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;*&lt;em&gt;Define Routes&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
When a client sends request for an endpoint using HTTP request (GET, POST, PUT, DELETE), we need to determine how the server will response by setting up the routes.&lt;/p&gt;

&lt;p&gt;These are our routes:&lt;/p&gt;

&lt;p&gt;/api/plans: GET, POST, DELETE&lt;br&gt;
/api/plans/🆔 GET, PUT, DELETE&lt;br&gt;
/api/plans/completed: GET&lt;/p&gt;

&lt;p&gt;Create a plan.routes.js inside routes folder with content like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module.exports = app =&amp;gt; {
    const plans = require("../controllers/plan.controller.js");
    var router = require("express").Router();

    // Create a new Plan
    router.post("/", plans.create);

    // Retrieve all Plans
    router.get("/", plans.findAll);

    // Retrieve all completed Plans
    router.get("/completed", plans.findAllCompleted);

    // Retrieve a single Plan with id
    router.get("/:id", plans.findOne);

    // Update a Plan with id
    router.put("/:id", plans.update);

    // Delete a Plan with id
    router.delete("/:id", plans.delete);

    // Create a new Plan
    router.delete("/", plans.deleteAll);

    app.use('/api/plans', router);
};

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can see that we use a controller from /controllers/plan.controller.js.&lt;/p&gt;

&lt;p&gt;We also need to include routes in app.js (right before app.listen()):&lt;/p&gt;

&lt;p&gt;&lt;code&gt;require("./routes/plan.route")(app);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Test the APIs&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
Run our NodeJs application with command: node app.js.&lt;/p&gt;

&lt;p&gt;Using Postman, we’re gonna test all the APIs above&lt;/p&gt;

&lt;p&gt;References:&lt;br&gt;
1) &lt;a href="https://www.bezkoder.com/node-express-sequelize-postgresql/"&gt;https://www.bezkoder.com/node-express-sequelize-postgresql/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Code repository: &lt;a href="https://github.com/mondyfy/nodejs-workshop-kist"&gt;https://github.com/mondyfy/nodejs-workshop-kist&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>worskhop</category>
      <category>cruds</category>
    </item>
    <item>
      <title>Sending Emails from NestJs Using the Mailgun API</title>
      <dc:creator>Sandip Basnet</dc:creator>
      <pubDate>Wed, 20 Jul 2022 08:49:14 +0000</pubDate>
      <link>https://forem.com/sandipbasnet/sending-emails-from-nestjs-using-the-mailgun-api-5266</link>
      <guid>https://forem.com/sandipbasnet/sending-emails-from-nestjs-using-the-mailgun-api-5266</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwyebgl42o9dwhsjh661h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwyebgl42o9dwhsjh661h.png" alt="Sending Emails from NestJs Using the Mailgun API" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I had set up the mailing with nodemailer with mailgun few months back, that was working fine but I had got few recurring issues, that's why I have switched the implementation from SMTP to API, and I found it quite simpler than that of the SMTP as no extra library need to be used, apart from the request client axios.&lt;/p&gt;

&lt;p&gt;The snippet of the implementation goes like this:&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;&lt;code&gt;public async sendMail(mail: IMail) {&lt;br&gt;
        const mailOptions: MailInput = {&lt;br&gt;
            from: `SON &amp;lt;${configService.get('SENDER_EMAIL')}&amp;gt;`,&lt;br&gt;
            to: mail.to,&lt;br&gt;
            subject: mail.subject,&lt;br&gt;
        }&lt;br&gt;
        if (mail.template) {&lt;br&gt;
            const emailTemplateSource = fs.readFileSync(path.join(__dirname, `../../templates/${mail.template}.hbs`), "utf8")&lt;br&gt;
            const template = handlebars.compile(emailTemplateSource);&lt;br&gt;
            const htmlToSend = template(mail.templateVariables)&lt;br&gt;
            mailOptions.html = htmlToSend&lt;br&gt;
        } else {&lt;br&gt;
            mailOptions.text = mail.text;&lt;br&gt;
        }&lt;br&gt;
        try {&lt;br&gt;
            const body = Object.keys(mailOptions).map((key, index) =&amp;gt; `${key}=${encodeURIComponent(mailOptions[key])}`).join('&amp;amp;');&lt;br&gt;
            const response = await axios.post(`https://api.mailgun.net/v3/${configService.get('MAILGUN_DOMAIN')}/messages`,&lt;br&gt;
                body,&lt;br&gt;
                {&lt;br&gt;
                    auth: {&lt;br&gt;
                        username: 'api',&lt;br&gt;
                        password: configService.get('MAILGUN_API_KEY')&lt;br&gt;
                    },&lt;br&gt;
                    headers: {&lt;br&gt;
                        "Content-Type": "application/x-www-form-urlencoded"&lt;br&gt;
                    }&lt;br&gt;
                });&lt;br&gt;
            Logger.log(`Email successfully sent to: ${mail.to}.`)&lt;br&gt;
            return response;&lt;br&gt;
        } catch (error) {&lt;br&gt;
            Logger.warn(`Problem in sending email: ${error}`);&lt;br&gt;
            throw error;&lt;br&gt;
        }&lt;br&gt;
    }&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

</description>
      <category>mailgunapi</category>
      <category>netsjs</category>
      <category>emailing</category>
      <category>node</category>
    </item>
    <item>
      <title>HLS Audio Streaming in NodeJS</title>
      <dc:creator>Sandip Basnet</dc:creator>
      <pubDate>Wed, 29 Jun 2022 18:05:08 +0000</pubDate>
      <link>https://forem.com/sandipbasnet/hls-audio-streaming-in-nodejs-3k2d</link>
      <guid>https://forem.com/sandipbasnet/hls-audio-streaming-in-nodejs-3k2d</guid>
      <description>&lt;p&gt;In this article, I will discuss the working mechanism of HLS and how we can use HLS(HTTP Live Streaming) for audio/music streaming in NodeJs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is HLS?&lt;/strong&gt;&lt;br&gt;
According to Wikipedia: HLS is an HTTP-based adaptive bitrate streaming communications protocol developed by Apple Inc. It was released in 2009. Support for the protocol is widespread in media players, web browsers, mobile devices, and streaming media servers.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why HLS?&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Fast&lt;/strong&gt;:&lt;br&gt;
As one large file is divided into segments a few segments in length and those files are fetched on respective player time with the help of the manifest/index file.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Adaptive Bitrate Streaming&lt;/strong&gt;:&lt;br&gt;
It has the ability to adjust video quality in the middle of a stream as network conditions change. This ability allows videos to keep playing even if network conditions get worse; conversely, it also maximizes video quality to be as high as the network can support.&lt;br&gt;
If the network slows down, the user’s video player detects this, and adaptive bitrate streaming lowers the quality of the stream so that the video does not stop playing. If more network bandwidth becomes available, adaptive bitrate streaming improves the quality of the stream.&lt;br&gt;
Adaptive bitrate streaming is possible because HLS creates several duplicate segmented streams at different quality levels during the segmentation process. The user’s video player can switch from one of those streams to another one during video playback.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs3vfs58dgdi6gwr04da9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs3vfs58dgdi6gwr04da9.png" alt="fig: Illustration of Adaptive bitrate streaming. source cloudinary.com."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Unwanted i.e unwatched or unlistened portions of the file(audio/video) won’t be downloaded.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Less server and client configuration uses HTTP Protocol.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;How does HLS work?&lt;/strong&gt;&lt;br&gt;
Server: An HLS stream originates from a server where (in on-demand streaming) the media file is stored, or where (in live streaming) the stream is created. Because HLS is based on HTTP, any ordinary web server can originate the stream.&lt;/p&gt;

&lt;p&gt;Two main processes take place on the server:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Encoding&lt;/strong&gt;: The audio/video data is reformatted so that any device can recognize and interpret the data. HLS must use H.264 or H.265 encoding.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Segmenting&lt;/strong&gt;: The audio/video is divided up into segments a few seconds in length.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;In addition to dividing the audio/video into segments, HLS creates an index file of the audio/video segments to record the order they belong in.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HLS will also create several duplicate sets of segments at different quality levels: 480p, 720p, 1080p, and so on.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Distribution&lt;/strong&gt;: The encoded video segments are pushed out to client devices over the Internet when client devices request the stream. Typically, a CDN or OFS like s3 will help distribute the stream to geographically diverse areas.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Client devices&lt;/strong&gt;: The client device is the device that receives the stream and plays the video — for instance, a user's smartphone or laptop. The client device uses the index file(.m3u8) as a reference for assembling the audio/video in order, and it switches from higher quality to lower quality pictures (and vice versa) as needed.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1t1fa3eqpk3iydkokjro.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1t1fa3eqpk3iydkokjro.png" alt="fig: HLS workflow"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fot1j9rkhcs1hps5z3ok9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fot1j9rkhcs1hps5z3ok9.png" alt="fig: HLS different levels of manifests, source https://www.streamingmedia.com/"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example: HLS Audio streaming(NodeJs)&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;MP3 to chunks:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;First of all, initiate a project with npm init and add utils/mp3tochunks.js, the contents of mp2tochunks.js should be:&lt;br&gt;
`const util = require('util');&lt;br&gt;
const exec = util.promisify(require('child_process').exec);&lt;br&gt;
const fs = require('fs');&lt;br&gt;
const path = require('path');&lt;/p&gt;

&lt;p&gt;const dir = path.join(&lt;strong&gt;dirname, '../songs');&lt;br&gt;
const dest = path.join(&lt;/strong&gt;dirname, '../temp/chunks');&lt;/p&gt;

&lt;p&gt;const startTime = new Date();&lt;br&gt;
console.info('&amp;gt; Start reading files', startTime);&lt;/p&gt;

&lt;p&gt;fs.readdir(dir, (readDirError, files) =&amp;gt; {&lt;br&gt;
    if (readDirError) {&lt;br&gt;
        console.error(readDirError);&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    return;
}

const countFiles = files.length;
files.map(async (file, index) =&amp;gt; { 
    const fileName = path.join(dir, file);

    const { err, stdout, stderr } =
        await exec(`ffmpeg -i ${fileName} -profile:v baseline -level 3.0 -s 640x360 -start_number 0 -hls_time 10 -hls_list_size 0 -f hls  ${dest}/${index}.m3u8`);

    if (err) {
        console.log(err);
    }

    if (countFiles - 1 === index) {
        const endTime = new Date();
        console.info('&amp;lt; End Preparing files', endTime);
    }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;});`&lt;/p&gt;

&lt;p&gt;In the above snippet, I have made a song folder that contains mp3 files that will later be converted into chunks and those chunks are stored on the temp/chunks directory.&lt;/p&gt;

&lt;p&gt;The main task in this util is done by ffmpeg, which should be installed on your machine.&lt;/p&gt;

&lt;p&gt;Command used:&lt;br&gt;
&lt;code&gt;ffmpeg -i ${fileName} -profile:v baseline -level 3.0 -s 640x360 -start_number 0 -hls_time 10 -hls_list_size 0 -f hls  ${dest}/${index}.m3u8&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;where,&lt;br&gt;
-i : specifies the input file audio/video,&lt;br&gt;
-profile: sets the audio/video encoding codec profiles, setting baseline, as it supports lower-cost applications with limited computing resources,&lt;br&gt;
-level: level as mentioned in Annex A of the H.264 standard,&lt;br&gt;
-s: sets frame size,&lt;br&gt;
-start_number: Set the index of the file matched by the image file pattern to start to read from, the default value is 0.&lt;br&gt;
-hls_time: segment duration in seconds,&lt;br&gt;
-hls_list_size: Set the maximum number of playlist entries. If set to 0 the list file will contain all the segments. The default value is 5,&lt;br&gt;
-f: Set the file format,&lt;br&gt;
${dest}/${index}.m3u8: Sets Path of the chunks generated and manifest file m3u8&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The content of the m3u8 file should be something like this:&lt;/p&gt;

&lt;p&gt;`#EXTM3U&lt;/p&gt;

&lt;h1&gt;
  
  
  EXT-X-VERSION:3
&lt;/h1&gt;

&lt;h1&gt;
  
  
  EXT-X-TARGETDURATION:10
&lt;/h1&gt;

&lt;h1&gt;
  
  
  EXT-X-MEDIA-SEQUENCE:0
&lt;/h1&gt;

&lt;h1&gt;
  
  
  EXTINF:10.008778,
&lt;/h1&gt;

&lt;p&gt;00.ts&lt;/p&gt;

&lt;h1&gt;
  
  
  EXTINF:10.008778,
&lt;/h1&gt;

&lt;p&gt;01.ts&lt;/p&gt;

&lt;h1&gt;
  
  
  EXTINF:9.985556,
&lt;/h1&gt;

&lt;p&gt;02.ts&lt;/p&gt;

&lt;h1&gt;
  
  
  EXTINF:10.008778,
&lt;/h1&gt;

&lt;p&gt;03.ts&lt;/p&gt;

&lt;h1&gt;
  
  
  EXTINF:10.008778,
&lt;/h1&gt;

&lt;p&gt;04.ts&lt;/p&gt;

&lt;h1&gt;
  
  
  EXTINF:9.985556,
&lt;/h1&gt;

&lt;p&gt;05.ts&lt;/p&gt;

&lt;h1&gt;
  
  
  EXTINF:10.008778,
&lt;/h1&gt;

&lt;p&gt;06.ts&lt;/p&gt;

&lt;h1&gt;
  
  
  EXTINF:10.008778,
&lt;/h1&gt;

&lt;p&gt;07.ts&lt;/p&gt;

&lt;h1&gt;
  
  
  EXTINF:9.985556,
&lt;/h1&gt;

&lt;p&gt;08.ts&lt;/p&gt;

&lt;h1&gt;
  
  
  EXTINF:10.008778,
&lt;/h1&gt;

&lt;p&gt;09.ts&lt;/p&gt;

&lt;h1&gt;
  
  
  EXTINF:10.008778,
&lt;/h1&gt;

&lt;p&gt;010.ts&lt;/p&gt;

&lt;h1&gt;
  
  
  EXTINF:9.985556,
&lt;/h1&gt;

&lt;p&gt;011.ts&lt;/p&gt;

&lt;h1&gt;
  
  
  EXT-X-ENDLIST`
&lt;/h1&gt;

&lt;p&gt;where,&lt;br&gt;
&lt;strong&gt;EXTM3U&lt;/strong&gt;: this indicates that the file is an extended m3u file. Every HLS playlist must start with this tag.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EXT-X-VERSION&lt;/strong&gt;: indicates the compatibility version of the Playlist file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EXT-X-TARGETDURATION&lt;/strong&gt;: this specifies the maximum duration of the media file in seconds.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EXT-X-MEDIA-SEQUENCE&lt;/strong&gt;: indicates the sequence number of the first URL that appears in a playlist file. Each media file URL in a playlist has a unique integer sequence number. The sequence number of a URL is higher by 1 than the sequence number of the URL that preceded it. The media sequence numbers have no relation to the names of the files.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EXTINF&lt;/strong&gt;: tag specifies the duration of a media segment. It should be followed by the URI of the associated media segment — this is mandatory. You should ensure that the EXTINF value is less than or equal to the actual duration of the media file that it is referring to.&lt;/p&gt;

&lt;p&gt;Once the manifest file is generated, we have to host it, lets add a node server and test it on hls player i.e. add &lt;em&gt;main.js&lt;/em&gt; file that should have:&lt;br&gt;
`var http = require('http');&lt;br&gt;
var fs = require('fs');&lt;/p&gt;

&lt;p&gt;const port = 8000&lt;/p&gt;

&lt;p&gt;http.createServer(function (request, response) {&lt;br&gt;
    console.log('request starting...');&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var filePath = './temp/chunks' + request.url;

fs.readFile(filePath, function(error, content) {
    response.writeHead(200, { 'Access-Control-Allow-Origin': '*' });
    if (error) {
        if(error.code == 'ENOENT'){
            fs.readFile('./404.html', function(error, content) {
                response.end(content, 'utf-8');
            });
        }
        else {
            response.writeHead(500);
            response.end('Sorry, check with the site admin for error: '+error.code+' ..\n');
            response.end(); 
        }
    }
    else {
        response.end(content, 'utf-8');
    }
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;}).listen(port);&lt;br&gt;
console.log(&lt;code&gt;Server running at http://127.0.0.1:${port}/&lt;/code&gt;);&lt;br&gt;
`&lt;/p&gt;

&lt;p&gt;This basically takes the request URL and looks for the corresponding URL if that is generated in chunks, if that is generated it will respond with the contents of the file. for example: for request &lt;a href="http://127.0.0.1:8000/0.m3u8" rel="noopener noreferrer"&gt;http://127.0.0.1:8000/0.m3u8 &lt;/a&gt; the manifest file will be downloaded, here to test the file you have to add one browser extension i.e. &lt;a href="https://chrome.google.com/webstore/detail/native-hls-playback/emnphkkblegpebimobpbekeedfgemhof" rel="noopener noreferrer"&gt;Native HLS Playback&lt;/a&gt;, that should play the media you have used. In the meantime, you can inspect the file sequence chunks requested by the client/browser from the server after every 10 seconds the chunk has been loaded.&lt;/p&gt;

&lt;p&gt;That sums up the HLS audio/video streaming with nodejs. Here all the files are served locally, in an ideal case they are served through some online file storage service like AWS s3, for that, I have added uploadchunkstos3.js file in the &lt;a href="https://github.com/mondyfy/hls_demo" rel="noopener noreferrer"&gt;repository of this article&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;References&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;a href="https://github.com/mondyfy/hls_demo" rel="noopener noreferrer"&gt;https://github.com/mondyfy/hls_demo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://blog.boot.dev/javascript/hls-video-streaming-node/" rel="noopener noreferrer"&gt;https://blog.boot.dev/javascript/hls-video-streaming-node/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://hls-js.netlify.app/demo/" rel="noopener noreferrer"&gt;https://hls-js.netlify.app/demo/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/video-dev/hls.js/" rel="noopener noreferrer"&gt;https://github.com/video-dev/hls.js/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://scanskill.com/programming/how-to-use-hlsjs-for-video-streaming/" rel="noopener noreferrer"&gt;https://scanskill.com/programming/how-to-use-hlsjs-for-video-streaming/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.cloudflare.com/learning/video/what-is-http-live-streaming/" rel="noopener noreferrer"&gt;https://www.cloudflare.com/learning/video/what-is-http-live-streaming/&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://medium.com/sharma02gaurav/adaptive-bitrate-streaming-hls-vod-service-in-nodejs-8df0d91d2eb4" rel="noopener noreferrer"&gt;https://medium.com/sharma02gaurav/adaptive-bitrate-streaming-hls-vod-service-in-nodejs-8df0d91d2eb4&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.mediacoderhq.com/h264-profiles-and-levels/" rel="noopener noreferrer"&gt;http://blog.mediacoderhq.com/h264-profiles-and-levels/&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;

</description>
      <category>hlsaudiostreaming</category>
      <category>hls</category>
      <category>streaming</category>
      <category>node</category>
    </item>
    <item>
      <title>Steps to run any laravel project.</title>
      <dc:creator>Sandip Basnet</dc:creator>
      <pubDate>Wed, 25 May 2022 01:38:57 +0000</pubDate>
      <link>https://forem.com/sandipbasnet/steps-to-run-any-laravel-project-gd7</link>
      <guid>https://forem.com/sandipbasnet/steps-to-run-any-laravel-project-gd7</guid>
      <description>&lt;p&gt;1) Clone repository&lt;br&gt;
2) composer install&lt;br&gt;
3) copy .env.example to .env &lt;code&gt;cp .env.example .env&lt;/code&gt; (if needed) &lt;br&gt;
3) php artisan key:generate&lt;br&gt;
4) php artisan migrate&lt;br&gt;
5) php artisan db:seed  (seeders if any)&lt;br&gt;
6) php artisan serve&lt;/p&gt;

</description>
      <category>laravel</category>
      <category>projectsetup</category>
      <category>seeders</category>
      <category>migrations</category>
    </item>
    <item>
      <title>Backup MySQL database locally</title>
      <dc:creator>Sandip Basnet</dc:creator>
      <pubDate>Tue, 24 May 2022 10:06:49 +0000</pubDate>
      <link>https://forem.com/sandipbasnet/backup-mysql-database-locally-1gbm</link>
      <guid>https://forem.com/sandipbasnet/backup-mysql-database-locally-1gbm</guid>
      <description>&lt;p&gt;1) Make sure remote connection is enabled :&lt;a href="https://dev.to/sandipbasnet/remote-access-of-mysql-from-cli-47p"&gt;MySQL remote access&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;2) If remote access is allowed:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mysqldump --host &amp;lt;host_address or ip&amp;gt; -P &amp;lt;Port Number(3306)&amp;gt; -u &amp;lt;db username&amp;gt; -p &amp;lt;database_name&amp;gt; &amp;gt; offgrid.sql

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>mysqldump</category>
      <category>mysqlcli</category>
      <category>connection</category>
      <category>backup</category>
    </item>
    <item>
      <title>Remote access of MySQL from CLI</title>
      <dc:creator>Sandip Basnet</dc:creator>
      <pubDate>Tue, 24 May 2022 09:53:13 +0000</pubDate>
      <link>https://forem.com/sandipbasnet/remote-access-of-mysql-from-cli-47p</link>
      <guid>https://forem.com/sandipbasnet/remote-access-of-mysql-from-cli-47p</guid>
      <description>&lt;p&gt;1) Check if remote access is allowed for user:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT User, Host FROM mysql.user;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if user has &lt;code&gt;%&lt;/code&gt; (wildcard just as * ) in host then this user can establish connection from anywhere, you can update this wildcard or specific ip as&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;UPDATE mysql.user SET HOST='%' WHERE User='&amp;lt;your_username&amp;gt;';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and then flush privileges with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;FLUSH PRIVILEGES;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2) If MySQL is installed on a Ubuntu, you will have to access the file at this location: &lt;code&gt;cd /etc/mysql/mysql.conf.d/mysqld.cnf&lt;br&gt;
&lt;/code&gt;&lt;br&gt;
Open the file and comment the binded-address i.e.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;change: bind-address = 127.0.0.1 to: #bind-address = 127.0.0.1 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;to bring changes on effect restart the mysql or reboot the system itself: &lt;br&gt;
i.e. restart:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo service mysql restart
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3) Access from cli: &lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

mysql -u &amp;lt;user_name&amp;gt; -h &amp;lt;host or ip addrsss&amp;gt; -p
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>remoteaccess</category>
      <category>mysqlcli</category>
      <category>connection</category>
    </item>
    <item>
      <title>List the size of the database and tables: MySQL CLI</title>
      <dc:creator>Sandip Basnet</dc:creator>
      <pubDate>Tue, 24 May 2022 09:29:40 +0000</pubDate>
      <link>https://forem.com/sandipbasnet/list-the-size-of-the-database-and-tables-mysql-cli-36lj</link>
      <guid>https://forem.com/sandipbasnet/list-the-size-of-the-database-and-tables-mysql-cli-36lj</guid>
      <description>&lt;p&gt;1) Size of the database (in GB):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT table_schema AS "Database", SUM(data_length + index_length) / 1024 / 1024 / 1024 AS "Size (GB)" FROM information_schema.TABLES GROUP BY
table_schema;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2) Size of the database (in MB):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT table_schema AS "Database", SUM(data_length + index_length) / 1024 / 1024 AS "Size (MB)" FROM information_schema.TABLES GROUP BY table_schema;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3) Size of the tables of a database (in MB):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SELECT table_name AS "Table", ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)" FROM information_schema.TABLES WHERE table_schema = "&amp;lt;db_name&amp;gt;" ORDER BY (data_length + index_length) DESC;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>mysql</category>
      <category>table</category>
      <category>database</category>
      <category>size</category>
    </item>
    <item>
      <title>Server side implementation of Biometric in NodeJs</title>
      <dc:creator>Sandip Basnet</dc:creator>
      <pubDate>Mon, 24 Aug 2020 08:25:57 +0000</pubDate>
      <link>https://forem.com/sandipbasnet/server-side-implementation-of-biometric-in-nodejs-5ii</link>
      <guid>https://forem.com/sandipbasnet/server-side-implementation-of-biometric-in-nodejs-5ii</guid>
      <description>&lt;div class="ltag__stackexchange--container"&gt;
  &lt;div class="ltag__stackexchange--title-container"&gt;
    
      &lt;div class="ltag__stackexchange--title"&gt;
        &lt;h1&gt;
          &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7Gn-iPj_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackoverflow-logo-b42691ae545e4810b105ee957979a853a696085e67e43ee14c5699cf3e890fb4.svg" alt=""&gt;
            &lt;a href="https://stackoverflow.com/questions/63557134/server-side-implementation-of-biometric-authentication" rel="noopener noreferrer"&gt;
               Server side implementation of Biometric Authentication
            &lt;/a&gt;
        &lt;/h1&gt;
        &lt;div class="ltag__stackexchange--post-metadata"&gt;
          &lt;span&gt;Aug 24 '20&lt;/span&gt;
            &lt;span&gt;Comments: 1&lt;/span&gt;
            &lt;span&gt;Answers: 0&lt;/span&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;a class="ltag__stackexchange--score-container" href="https://stackoverflow.com/questions/63557134/server-side-implementation-of-biometric-authentication" rel="noopener noreferrer"&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Y9mJpuJP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackexchange-arrow-up-eff2e2849e67d156181d258e38802c0b57fa011f74164a7f97675ca3b6ab756b.svg" alt=""&gt;
        &lt;div class="ltag__stackexchange--score-number"&gt;
          2
        &lt;/div&gt;
        &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wif5Zq3z--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev.to/assets/stackexchange-arrow-down-4349fac0dd932d284fab7e4dd9846f19a3710558efde0d2dfd05897f3eeb9aba.svg" alt=""&gt;
      &lt;/a&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--body"&gt;
    
&lt;p&gt;We have a microservice-based system and currently users are authenticated by keycloack(jwt) and we need to add biometrics login in this existing system
At first, we have designed a biometrics authentication flow as below:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Generate Asymmetric Key Pair at the client end(mobile app).&lt;/li&gt;
&lt;li&gt;Share the public key with backend server.&lt;/li&gt;
&lt;li&gt;…&lt;/li&gt;
&lt;/ol&gt;
    
  &lt;/div&gt;
  &lt;div class="ltag__stackexchange--btn--container"&gt;
    
      &lt;a href="https://stackoverflow.com/questions/63557134/server-side-implementation-of-biometric-authentication" rel="noopener noreferrer"&gt;Open Full Question&lt;/a&gt;
    
  &lt;/div&gt;
&lt;/div&gt;


</description>
    </item>
  </channel>
</rss>
