Notes: Install hplip in Ubuntu 22.04 along with plugin

 Commands are as follows:

sudo apt update && sudo apt upgrade -y;

sudo apt install software-properties-common apt-transport-https -y;

sudo add-apt-repository ppa:kelebek333/hplip -y;

sudo apt-get update;

sudo apt-get install hplip hplip-gui -y;


===

Next you need to install respective plugins

Check the version of hplip using command: dpkg -l hplip

Then, download corresponding plugin file & .asc file that matches with version from link https://www.openprinting.org/download/printdriver/auxfiles/HP/plugins/

Then in terminal, type: hp-plugin

Then follow the GUI screen to install plugin.

Notes: Ubuntu-Libreoffice: Uninstall default Libreoffice provided with Ubuntu & install of your own

 Default Libreoffice that come with ubuntu don't have full version, like it don't have Libreoffice base. So one may need to uninstall default version & install full version of their own.

Terminal command to uninstall Libreoffice completely is as follows:

sudo apt-get update;sudo apt update

sudo apt-get -y remove --purge libreoffice* libexttextcat-data* && sudo apt-get -y autoremove

--

Terminal command to install Libreoffice full version after that is as follows

sudo add-apt-repository ppa:libreoffice

sudo apt install libreoffice

--

Verify installed version

libreoffice --version

Postgres-Ubuntu: Restore postgres database using pg_restore

 Command is as follows:

   pg_restore -U postgres -d <database name> -h localhost  <backup_filename>.dump


Potgres-Ubuntu: Bash-script to take backup of list of databases

 #!/bin/bash

declare -a arr=("db1" "db2" "db3" "db4" "db5" "db6")

for i in "${arr[@]}"

do

   echo "$i"

   pg_dump -U postgres -h localhost -Fc "$i" > ~/<folderPath>/"$i".dump

done


Notes: Inverter purchasing calculations for home

 Take a list of items that will run in inverter like 2fans, 1 LED tubelight, 1 laptop, 2 LED TV, etc

Now calcullate sum of their power e.g 2*60+1*20+100+2*100 WH=440 WH

Now add 25% to above power sum e.g 440*125%=550WH

Then multiply it by power factor (most case it's 1/0.8) e.g 550/.08=687.5 WH

For every inverter has its own effeiency say 90%,80%, etc

Therefore, inverter power that has to be purchased = 687.5/90%=763.888 VA

Above is how to calculate inverter power that has to be purchased.

----

Now comes how to choose battery power

Batter power (VA) =  Home Load * Backup (hrs)/Battery Vold

= 687.5WH*2hr/12amp = 114.58

---

This is how you do calculations for purchasing invertor

=========================

Bibliography



Ubuntu Notes: Solve E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem when trying to update ubuntu

This the problem you face when you try to upgrade or update ubuntu using command line, you get this message.

Again when you run 'sudo dpkg --configure -a'  command you get error message like 

dpkg: error: parsing file '/var/lib/dpkg/updates/0019' near line 0:

 newline in field name '#padding'

---
To solve this run command as follows
cd /var/lib/dpkg/updates && sudo rm -rf <refNo>;
sudo dpkg --configure -a;

Like in above question case run command as follows
cd /var/lib/dpkg/updates && sudo rm -rf 0019;
sudo dpkg --configure -a;

==
Thats all & problem will be solved

21 Amazing Hacks That Make Healthy Lifestyle Easier

21 Amazing Hacks to Make Healthy Lifestyle Easier

  1. Sitting in AC & Feeling Dehydrated:
    AC sucks moisture from atmosphere & then from our bodies. To prevent this place potfull of water in the room & then turn the AC on.
  2. Don't peel of skin of potato, sweet potato, pumpkin, cucumber before cooking them:
    Their peel is super rich in vitamins & minerals. Then what to to for pesticine? For this you can wash them in baking soda solution for 10-15 minutes. This will save your time & effort; also give you extra nutrition.
  3. Not sure if vender have served you fresh sugarcane juice?
    Sugarcane Juice
    Property Fresh Not So Fresh
    Color Light Green Darker
    Frothyness More Almost no Frothy
    Image Fresh Not So Fresh
  4. Cucumber that you have cut turns out to be bitter
    Cut the cucumber from the centre, leave it for 15 sec then cut it.
    cucumber
  5. Do you directly soak Lentils in water & throw that water?
    Never make this mistake, this water if full of micro-nutrients.
    Best way is first wash the lentils, then soak it in water in only as much water as you need for cooking.
    After 6-8 hrs you can directly place it for cooking along with that water. This is smatter idea.
  6. Do you avoid soaking split lentils as their cooking time is low?
    You must soak all lentils, pulses, all variant rice, broken wheat before cooking irrespective of their cooking time.
    This is because all these foods gets nutrition rich 100% only when they are soaked.
  7. Do you add normal tap water extra water while preparing curry?
    Never do it. It will increase cooking time & also make curry hard to digest.
    Instead heat the water, & then add it. This way your curry will be much heather & tastier.
  8. More time you knead the dough, the faster Roti will get digested
    Whenever you begin cooking the meal, always first knead the dough, cover it & then keep aside.
    Then prepare you vegetable, & then prepare chapatis at last. This will result in faster digestible & softer chapatis.
  9. Rice should never be eaten at night
    This is said due to extremely cold potency due to which if consumed at night, it can cause problem.
    Hack is to add bay leaves & black pepper when cooking it for dinner, which balances it out.
  10. Have you ever grind thread mishri & try storing it in air-tight container?
    Later you may find it turns hard-stone line. To avoid this problem, after grinding mishri in grinder, let it cool down, then put it in airtight container.
  11. Whenever you prepare herbal drink like lemon water, aloe-vera juice, or giloy juice
    Make sure that you don't add too much water to it. According to ayurveda the quantity of water should be equal to the herbal juice added or at max double
  12. Are you confused, how long you should stick to one herbal juice option?
    According to ayurveda, one herbal juice should be consumed for at least 48 days (i.e 1 mandala) to experience its benefit.
    It should then be discontinued for about 15-20 days else body will get used to it.
    Then if you need it back, you may start again
  13. First & last meal that you consume after waking up & before sleepings respectively holds special significance
    These meals holds special significance in terms of their absorption & effectiveness.
    So herbal concoction are recommended before breakfast & medicinal herbs are prescribed with milk at night.
  14. Should you eat vegetable dalia for weight loss? Also can I eat it for weight gain?
    Yes to both. Broken dalia roasted in ghee is helpful for weight gain (according to ayurveda).
    However when roasted in cold-pressed oil, it helps to shed off excess weight.
  15. To avoid insect specially in the rainy season, put neem leaves in wheat flour, lentil, pluses.
    Also put neem leaves in your clothes. This will keep germs away
  16. Don't discard left over water when you make panir from milk. It can be used as follows
    • For making dough
    • In making curry
    • Added in soups
    • Wash hair & skinflints
    • Good for plants
    • Drink it as it is if your digestive system is weak. Good for intestine
  17. Curd gone sour?
    Rather then using it for consumption (which may increase pit dosa according to ayurveda due to its hot potency), use if for washing hair, skin
  18. Does your stomach bloat everytime you drink milk? Simple hack is to create forth in the milk by pouring it from one glass to another. This will make milk light to digest. Also good for people who suffer from gas
  19. Do you know how refreshing tender coconut water is?
    Purchase economical coconut opener. Just inset on side & enjoy fresh coconut water.
    alt| alt
  20. Do you experience bloating immediately after a meal?
    Hack is not to get up immediately after eating meal, keep sitting for atleast few minutes after eating food.
    You can also sit in bagra-assan for few minutes, it is very rewarding. You will observe difference in just one sitting like this.
  21. Do you've trouble of too many thoughts while sleeping?
    It totally depends on what your mind consumes. Before going to sleep spend sometime reading a book that'll relax you.

There were 21 life hacks that were mentioned in the video mentioned in bibliography, creater beliefs that above tips can make fitness lifestyle easy.
For detailed understanding you may watch the video mentioned in bibliography.


Bibliography

Notes - PostgreSql pgAdmin4: Url for pgadmin4 server in browser

 localhost:<portNo>/pgadmin4

where portNo is the port no for pgadmin4 server

Notes - PostgreSql pgAdmin4: How to solve error when trying to login


To solve this issue Clear browser cookie, refresh page.
This is how I solved this issue in my case

Notes: How to solve Google Plays Keeps Stop working

  1. GoTo Settings->Apps
  2. Open google play services->Clear cache; Memory
  3. Open google play store->Clear cache; memory
  4. Restart Device. Thats All! 

Notes: Java module to create Zipped Folder from list of Files


private static void convertFilesToZip(ArrayList filePaths, String zipFilePath) throws Exception {
        try ( ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFilePath));) {
            for (String filePath : filePaths) {
                File fileToZip = new File(filePath);
                ZipEntry e = new ZipEntry(new File(filePath).getName());
                out.putNextEntry(e);
                Files.copy(fileToZip.toPath(), out);
            }
        }
    }

Notes: Java module to convert list of images to PDF document using Apache PDFBox

 private static void convertImagesToPdf(ArrayList<String> imagesFilePath, String pdfFilePath) throws Exception {

        try ( PDDocument doc = new PDDocument();) {

            for (String imageFilePath : imagesFilePath) {

                PDImageXObject image = PDImageXObject.createFromFile(imageFilePath, doc);

                PDRectangle pageSize = PDRectangle.A4;

                int originalWidth = image.getWidth();

                int originalHeight = image.getHeight();

                float pageWidth = pageSize.getWidth();

                float pageHeight = pageSize.getHeight();

                float ratio = Math.min(pageWidth / originalWidth, pageHeight / originalHeight);

                float scaledWidth = originalWidth * ratio;

                float scaledHeight = originalHeight * ratio;

                float x = (pageWidth - scaledWidth) / 2;

                float y = (pageHeight - scaledHeight) / 2;

                PDPage page = new PDPage(pageSize);

                doc.addPage(page);

                try ( PDPageContentStream contents = new PDPageContentStream(doc, page)) {

                    contents.drawImage(image, x, y, scaledWidth, scaledHeight);

                }

            }

            doc.save(pdfFilePath);

        }

    }

Notes: Java module to merge PDF Documents (with or without password)

import java.io.File;

import java.nio.file.Files;

import java.nio.file.Path;

import java.nio.file.Paths;

import java.time.LocalDate;

import java.time.YearMonth;

import java.time.format.DateTimeFormatter;

import java.time.format.DateTimeFormatterBuilder;

import java.util.ArrayList;

import java.util.Collections;

import java.util.NavigableMap;

import java.util.TreeMap;

import org.apache.commons.io.FileUtils;

import org.apache.commons.lang3.StringUtils;

import org.apache.pdfbox.io.MemoryUsageSetting;

import org.apache.pdfbox.multipdf.PDFMergerUtility;

import org.apache.pdfbox.pdmodel.PDDocument;

import org.apache.pdfbox.pdmodel.PDPage;

import org.apache.pdfbox.pdmodel.encryption.InvalidPasswordException;

import org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination.PDPageDestination;

import org.apache.pdfbox.pdmodel.interactive.documentnavigation.destination.PDPageFitWidthDestination;

import org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDDocumentOutline;

import org.apache.pdfbox.pdmodel.interactive.documentnavigation.outline.PDOutlineItem;



 public static void mergePdfFiles(String destinationFilePath, ArrayList<String> sourceFilesPath) {

        try {

            PDFMergerUtility pdfMerger = new PDFMergerUtility();

            pdfMerger.setDestinationFileName(destinationFilePath);

            for (String sourceFile : sourceFilesPath) {

                System.out.println(sourceFile);

                pdfMerger.addSource(sourceFile);

            }

            pdfMerger.mergeDocuments(MemoryUsageSetting.setupTempFileOnly());

        } catch (Exception e) {

            e.printStackTrace();

        }

    }


    public static void mergePdfFiles(String destinationFilePath, ArrayList<String> sourceFilesPath,

            String password) {

        Path tmpDir = null;

        try {

            tmpDir = Files.createTempDirectory("aaaa");

            ArrayList<String> tmpList = new ArrayList();

            for (String filePath : sourceFilesPath) {

                File file = new File(filePath);

                try ( PDDocument doc = PDDocument.load(file, password)) {

                    doc.setAllSecurityToBeRemoved(true);

                    doc.save(new File(tmpDir.toString() + "/" + file.getName()));

                    tmpList.add(tmpDir.toString() + "/" + file.getName());

                }

            }

            mergePdfFiles(destinationFilePath, tmpList);

        } catch (Exception e) {

            e.printStackTrace();

        } finally {

            try {

                FileUtils.deleteDirectory(new File(tmpDir.toString()));

            } catch (Exception e) {

                e.printStackTrace();

            }

        }

    }

Notes: Java module to convert PDF document to Image_Files

 import java.awt.image.BufferedImage;

import java.io.File;

import java.util.Arrays;

import javax.imageio.ImageIO;

import org.apache.commons.lang3.StringUtils;

import org.apache.pdfbox.pdmodel.PDDocument;

import org.apache.pdfbox.rendering.ImageType;

import org.apache.pdfbox.rendering.PDFRenderer;


private static void convertPdfToImage(String pdfFilePath, String imageFolderPath) throws Exception {

        File file = new File(pdfFilePath);

        String fileExtension = ".jpg";

        int dpi=300;

        try (PDDocument doc = PDDocument.load(file)) {

            PDFRenderer pdfRenderer = new PDFRenderer(doc);

            for (int i = 0; i < doc.getPages().getCount(); i++) {

                BufferedImage img = pdfRenderer.renderImageWithDPI(i, dpi, ImageType.RGB);

                File outputFile = new File(imageFolderPath + StringUtils.removeEnd(file.getName(),".pdf") + "_pgNo" + i + fileExtension);

                outputFile.delete();

                System.out.println(outputFile.getAbsolutePath());

                System.out.println(Arrays.toString(ImageIO.getWriterFormatNames()));

                boolean flg=ImageIO.write(img, "jpg", outputFile);

                System.out.println(flg);

            }


        }

    }

C++ code to connect Postgres Database

/* At first install libpqxx in linux*/

#include <pqxx/pqxx>

using namespace std;
using namespace pqxx;

class GetDbConn
{
public:
    static connection *getPostgresDbConnection(const std::string& conStr)
    {
        pqxx::connection *c=new connection(conStr);
        return c;
    }
};

----------------

/*Code to call this connection is as follows

#include <pqxx/pqxx>
#include "getDbConn.h"

using namespace std;
using namespace pqxx;

class MyDb
{
public:
    static connection * getTradingNseConnection()
    {
        char const *conStr="dbname = <database_name> user = <user_name> password = <db_password> hostaddr = 127.0.0.1 port = 5432";
        pqxx::connection *con=GetDbConn::getPostgresDbConnection(conStr);
        if ((*con).is_open())
        {
            cout << "Opened database successfully: " << (*con).dbname() << endl;
            return con;
        }
        else
        {
            cout << "Can't open database" << endl;
            return NULL;
        }
    }
};

Regarding site Free Browser Tool (https://free-browser-tools.mohitkrgupta.dev) (discussion with google search AI)

Various discussions with Google Search AI regarding site  Free Browser Tool are as below: site free-browser-tools.mohitkrgupta.dev what doe...