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/

How to delete all commit history in GitHub & repush to main?

Create a new Branch:

git checkout --orphan latest_branch

Add your all the files:

git add .

Save the changes with commit:

git commit -m "commit message"

Delete Main Branch:

git branch -D main

Rename latest_branch to main:

git branch -m main

Force update the repo:

git push -f origin main

Saturday, November 19, 2022

Find duplicates in value using SQL command

 SELECT

    username,

    email,

    COUNT(*)

FROM

    users

GROUP BY

    username,

    email

HAVING

    COUNT(*) > 1


or,

SELECT name, COUNT(*) c FROM table GROUP BY name HAVING c > 1;

Wednesday, November 2, 2022

Find All Rows Containing Duplicates using SQL CMD

SELECT

    a.*

FROM

    users a

JOIN(

    SELECT

        username,

        email,

        COUNT(*)

    FROM

        users

    GROUP BY

        username,

        email

    HAVING

        COUNT(*) > 1

) b

ON

    a.username = b.username AND a.email = b.email

ORDER BY

    a.email

Extract Domain from email in Excel or Google sheet

  =TEXTAFTER( A2 , "@") or, =MID(A1, FIND("@", A1) + 1, LEN(A1) - FIND("@", A1))