Monday, December 5, 2022

Update columns values with column of another table based on condition in SQL command


UPDATE table1 SET price=(SELECT price FROM table2 WHERE table1.id=table2.id);

or,
UPDATE table1 SET table1.price=(SELECT table2.price FROM table2 WHERE table2.id=table1.id AND table2.item=table1.item);

or,
UPDATE event INNER JOIN cualumni ON event.user_id = cualumni.eid SET event.user_id = cualumni.id;


Or,

UPDATE table1 INNER JOIN table2 ON table1.id = table2.id SET table1.Price = table2.price

Sunday, December 4, 2022

Convert a putty .ppk key to an Amazon .pem file on Mac

$ brew install putty

$ puttygen key.ppk -O private-openssh -o key.pem

Or,

$ openssl x509 -in certificatename.cer -outform PEM -out certificatename.pem

Migrate Linux server to AWS EC2

Visit: AWS Replication Agent installation 
https://us-west-2.console.aws.amazon.com/mgn/home?region=us-west-2#/sourceServers/addServers

wget -O ./aws-replication-installer-init.py https://aws-application-migration-service-us-west-2.s3.us-west-2.amazonaws.com/latest/linux/aws-replication-installer-init.py


sudo python3 aws-replication-installer-init.py --region us-west-2

Saturday, December 3, 2022

Reinstall MySQL in virtualmin



sudo apt purge mysql-server mysql-client mysql-common
sudo apt autoremove
sudo mv -iv /var/lib/mysql /var/tmp/mysql-backup
sudo rm -rf /var/lib/mysql*

Then goto webmin dashboard>Server>MySQL Database Server>Install


PHP Laravel Artisan commands


 php artisan config:clear

 php artisan config:cache

 php artisan route:clear

 php artisan view:clear

 php artisan view:cache

 php artisan event:clear

 php artisan event:cache

 php artisan cache:clear

 php artisan optimize:clear

Saturday, November 26, 2022

How to change the default filename when using mPDF

$payStub=new mPDF();

$payStub->SetTitle('My title');
$payStub->WriteHTML($pcTableRows);
$payStub->Output('yourFileName.pdf', 'I');

  1. 'D': download the PDF file
  2. 'I': serves in-line to the browser
  3. 'S': returns the PDF document as a string
  4. 'F': save as file $file_out

Thursday, November 24, 2022

Auto deployment from github to server using FTP

 Step-1: Login the github the go to the project and click on setteings and add FTP Password under Security->Secrets. Then click New repository secret and name

Step - 2:Click Actions menu of repository and create the yml file as follows:

Click on Create a new worklow> set up a workflow yourself

.github/workflows/main.yml

Step - 3: Then add the following code to yml file and save.

on: push
name: 🚀 Deploy website on push
jobs:
web-deploy:
name: 🎉 Deploy
runs-on: ubuntu-latest
steps:
- name: 🚚 Get latest code
uses: actions/checkout@v2

- name: 📂 Sync files
uses: SamKirkland/FTP-Deploy-Action@4.3.2
with:
server: ourdomain.com/IP
username: username@yourdomain.com //or IP
password: ${{ secrets.FTP_PASSWORD }}
# server-dir: /home/dfaserghx/public_html/

Office 2021 Activation using command

  @echo off title Activate Microsoft Office 2021 (ALL versions) for FREE - office.com&cls&echo =====================================...